Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Parameters.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
12 #include "Parameters.h"
13 
14 using namespace kome::objects;
15 
16 
17 #include <crtdbg.h>
18 #ifdef _DEBUG
19  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
20  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
21 #endif // _DEBUG
22 
23 
24 // constructor
26 }
27 
28 // destructor
30 }
31 
32 // get the number of parameters
34  return m_parameters.size();
35 }
36 
37 // get parameter name
38 const char* Parameters::getName( unsigned int index ) {
39  // check index
40  if( index >= m_parameters.size() ) {
41  return NULL;
42  }
43 
44  return m_parameters[index].c_str();
45 }
46 
47 // get parameter value
48 Variant& Parameters::getValue( const char* name ) {
49  // creating string object
50  std::string s( NVL( name, "" ) );
51 
52  // check the map
53  if( m_parameterMap.find( s ) == m_parameterMap.end() ) { // new parameter
54  m_parameters.push_back( s );
55  }
56 
57  // return value
58  return m_parameterMap[ s ];
59 }
60 
61 // judge whether there is the parameter with the specified name.
62 bool Parameters::hasParameter( const char* name ) {
63  // creating string object
64  std::string s( NVL( name, "" ) );
65 
66  // check the map
67  return ( m_parameterMap.find( s ) != m_parameterMap.end() );
68 }
Parameters()
constructor
Definition: Parameters.cpp:25
Variant & getValue(const char *name)
gets parameter value
Definition: Parameters.cpp:48
std::vector< std::string > m_parameters
Definition: Parameters.h:74
std::map< std::string, Variant > m_parameterMap
Definition: Parameters.h:77
unsigned int getNumberOfParameters()
gets the number of parameters
Definition: Parameters.cpp:33
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
virtual ~Parameters()
destructor
Definition: Parameters.cpp:29
#define NULL
Definition: CoreMacros.h:18
class that treats data of various types
Definition: Variant.h:26
bool hasParameter(const char *name)
gets wheter there is parameter with the specified name.
Definition: Parameters.cpp:62
const char * getName(unsigned int index)
gets parameter name
Definition: Parameters.cpp:38
interfaces of Parameters class