16 #include <boost/bind.hpp>
19 using namespace kome::core;
24 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
25 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
41 std::string k =
NVL( key,
"" );
42 std::string v =
NVL( value,
"" );
45 for(
unsigned int i = 0; i <
m_props.size(); i++ ) {
46 if( k.compare(
m_props[ i ].first ) == 0 ) {
53 m_props.push_back( std::make_pair( k, v ) );
58 setValue( key, FMT(
"%d", value ).c_str() );
63 setValue( key, FMT(
"%f", value ).c_str() );
68 setValue( key, value ?
"true" :
"false" );
74 if( values ==
NULL || size <= 0 ) {
81 for(
int i = 0; i < size; i++ ) {
85 val.append( FMT(
"%d", values[ i ] ) );
95 std::string s =
NVL( key,
"" );
98 for(
unsigned int i = 0; i <
m_props.size(); i++ ) {
99 if( s.compare(
m_props[ i ].first ) == 0 ) {
110 std::string s =
NVL( key,
"" );
113 for(
unsigned int i = 0; i <
m_props.size(); i++ ) {
114 if( s.compare(
m_props[ i ].first ) == 0 ) {
115 return m_props[ i ].second.c_str();
140 std::vector<int> &values
143 std::vector<std::string> tokens;
144 std::list< std::string > strValues;
151 for (
unsigned int i = 0; i< tokens.size(); i++) {
153 if(
isint( tokens[i].c_str(), 10, &val ) ) {
154 values.push_back(val);
167 if( index >=
m_props.size() ) {
171 return m_props[ index ].first.c_str();
177 if( index >=
m_props.size() ) {
181 return m_props[ index ].second.c_str();
187 std::string k = std::string(
NVL( key,
"" ) );
191 for(
unsigned int i = 0; i <
m_props.size() && idx < 0; i++ ) {
192 if( k.compare(
m_props[ i ].first ) == 0 ) {
208 const char* defaultString
215 || *s ==
'\0' || *prefix ==
'\0' || *suffix ==
'\0' ) {
216 return std::string(
NVL( s,
"" ) );
220 char* buff =
new char[ strlen( s ) + 1 ];
221 memcpy( buff, s, strlen( s ) + 1 );
225 bool keyFlag =
false;
229 char* cc = strstr( c, suffix );
231 str.append( prefix );
232 str += std::string( c );
235 std::string key = std::string( c, cc );
236 if(
hasKey( key.c_str() ) ) {
240 str.append(
NVL( defaultString,
"" ) );
247 c = ( cc ==
NULL ) ?
NULL : ( cc + strlen( suffix ) );
250 char* cc = strstr( c, prefix );
252 str += std::string( c );
255 str += std::string( c, cc );
259 c = ( cc ==
NULL ) ?
NULL : ( cc + strlen( prefix ) );
void setBoolValue(const char *key, bool value)
sets parameter value
std::vector< std::pair< std::string, std::string > > m_props
int getIntValue(const char *key, int defaultValue)
gets parameter value converted to integer
void setValue(const char *key, const char *value)
sets parameter value
bool tobool(const char *s, bool dfVal)
get true or false from character string.
int toint(const char *s, const int radix, const int dfval)
convert string into integer
void setIntValue(const char *key, int value)
sets parameter value
const char * getValue(const unsigned int index)
gets the parameter value
void setIntValues(const char *key, int *values, int size)
set integer values
bool getBoolValue(const char *key, bool defaultValue)
gets parameter value converted to bool
std::string replaceString(const char *s, const char *prefix, const char *suffix, const char *defaultString)
replaces string "(prefix)(Property Key)(suffix)" to "(Property Value)"
unsigned int getNumberOfProperties()
gets the number of Properties
unsigned int stringtoken(const char *s, const char *delim, std::vector< std::string > &tokens)
get tokens from string
bool isint(const char *s, const int radix, int *val)
judge whether sutisfied character string shows integer number.
#define NVL(checkVal, replaceVal)
void deleteParameter(const char *key)
deletes parameter
const char * getKey(const unsigned int index)
gets the name of parameter
bool hasKey(const char *key)
judges whether this object has specified parameter key
double todouble(const char *s, const double dfval)
convert string into double
const char * getStringValue(const char *key, const char *defaultValue)
gets parameter value
interfaces of Properties class
void getIntValues(const char *key, std::vector< int > &values)
gets integer values from comma separated values
virtual ~Properties()
destructor
double getDoubleValue(const char *key, double defaultValue)
gets parameter value converted to double
void setDoubleValue(const char *key, double value)
sets parameter value