32 #define OM_PATH_MAX (FILENAME_MAX < PATH_MAX ? FILENAME_MAX : PATH_MAX)
36 #define OM_PATH_MAX (FILENAME_MAX < _MAX_PATH ? FILENAME_MAX : _MAX_PATH)
38 #define OM_PATH_MAX (FILENAME_MAX < 4096 ? FILENAME_MAX : 4096)
42#define OM_STRLEN_MAX INT_MAX
43#define OM_STR_DB_MAX 32000
44#define OM_CODE_DB_MAX 32
45#define OM_NAME_DB_MAX 255
46#define OM_DESCR_DB_MAX 255
47#define OM_OPTION_DB_MAX 32000
48#define OM_SQL_EXPR_DB_MAX 2048
49#define OM_MAX_BUILTIN_TYPE_ID 100
51#define OM_STATE_SAVE_TIME 1811L
52#define OM_STATE_BEAT_TIME 1823L
57 extern void toLower(std::string & io_str,
const std::locale & i_locale = std::locale(
""));
60 extern void toLower(
char * io_str,
const std::locale & i_locale = std::locale(
""));
63 extern void toUpper(std::string & io_str,
const std::locale & i_locale = std::locale(
""));
66 extern void toUpper(
char * io_str,
const std::locale & i_locale = std::locale(
""));
69 extern int compareNoCase(
const char * i_left,
const char * i_right,
size_t i_length = 0);
72 extern bool equalNoCase(
const char * i_left,
const char * i_right,
size_t i_length = 0);
78 extern bool endWithNoCase(
const std::string & i_str,
const char * i_end);
81 extern std::string
trimLeft(
const std::string & i_str,
const std::locale & i_locale = std::locale(
""));
84 extern std::string
trimRight(
const std::string & i_str,
const std::locale & i_locale = std::locale(
""));
87 extern std::string
trim(
const std::string & i_str,
const std::locale & i_locale = std::locale(
""));
93 extern const std::string
toQuoted(
const std::string & i_str,
char i_quote =
'\'');
96 extern const std::string
toUnQuoted(
const std::string & i_str,
char i_quote =
'\'',
const std::locale & i_locale = std::locale(
""));
99 extern const std::string
toString(
double i_val);
102 extern const std::string
toAlphaNumeric(
const std::string & i_str,
int i_maxSize = 0);
105 extern const std::string
cleanPathChars(
const std::string & i_str,
int i_maxSize = 0);
108 extern const std::string
replaceAll(
const std::string & i_src,
const char * i_oldValue,
const char * i_newValue);
111 extern bool isBoolType(
const char * i_typeName);
122 extern bool isIntType(
const char * i_typeName,
int i_typeId);
131 extern bool isTimeType(
const char * i_typeName);
154 ptrdiff_t
memCopyTo(uint8_t * io_dst, ptrdiff_t i_offset,
const void * i_src,
size_t i_size);
157 extern const std::string
makeDateTime(
const std::chrono::system_clock::time_point & i_time);
160 extern const std::string
makeTimeStamp(
const std::chrono::system_clock::time_point & i_time);
166 extern void formatTo(
size_t i_size,
char * io_buffer,
const char * i_format, va_list io_args);
172 extern const char *
elliptString(
const char * i_src,
size_t i_size,
char * io_buffer);
191 const std::string & i_values,
const char * i_delimiters =
",",
bool i_isUnquote =
false,
char i_quote =
'\''
207 const std::string & i_values,
208 std::list<std::string> & io_resultLst,
209 const char * i_delimiters =
",",
210 bool i_isUnquote =
false,
212 const std::locale & i_locale = std::locale(
""));
217 bool operator() (
const std::string & i_left,
const std::string & i_right)
const
224 typedef std::map<std::string, std::string, LessNoCase>
NoCaseMap;
257 template <
class ResourceHolder>
269 cleanup(i_cleanupFnc)
276 if (!isHold) (holder->*cleanup)();
282 void hold(
void)
noexcept { isHold =
true; }
286 ResourceHolder *
const holder;
simple resource exit guard implementation
Definition: omHelper.h:259
void hold(void) noexcept
hold resource on exit instead of relesing it
Definition: omHelper.h:282
void(ResourceHolder::* CleanupHandler)(void)
resource release method of resource holder class
Definition: omHelper.h:263
~exit_guard(void) noexcept
release resource if exit guard hold() was not called
Definition: omHelper.h:273
exit_guard(ResourceHolder *const i_holder, CleanupHandler i_cleanupFnc)
create resource guard to release resource on block exit
Definition: omHelper.h:266
openM++ namespace
Definition: log.h:32
std::string formatToString(const char *i_format,...)
format message into string result using vsnprintf()
Definition: helper.cpp:421
ptrdiff_t memCopyTo(uint8_t *io_dst, ptrdiff_t i_offset, const void *i_src, size_t i_size)
copy bytes source into destination and return next destination offset
Definition: helper.cpp:347
const std::string makeDateTime(const std::chrono::system_clock::time_point &i_time)
make date-time string, ie: 2012-08-17 16:04:59.148
const char * elliptString(const char *i_src, size_t i_size, char *io_buffer)
if source string exceed max size than return ellipted copy into the buffer
Definition: helper.cpp:440
const std::string toAlphaNumeric(const std::string &i_str, int i_maxSize=0)
replace all non [A-Z,a-z,0-9] by _ underscore and remove repetitive underscores.
bool isBoolValid(const char *i_str)
return true if lower case of source string one of: "yes" "1" "true" "no" "0" "false"
Definition: helper.cpp:325
std::string trimLeft(const std::string &i_str, const std::locale &i_locale=std::locale(""))
trim leading blank and space characters
bool isIntValid(const char *i_value)
return true if i_value string represent valid integer constant
Definition: helper.cpp:308
bool isBoolTrue(const char *i_str)
return true if lower case of source string one of: "yes" "1" "true"
Definition: helper.cpp:319
std::string trimRight(const std::string &i_str, const std::locale &i_locale=std::locale(""))
trim trailing blank and space characters
bool isStringType(const char *i_typeName)
return true if model type is string (varchar)
Definition: helper.cpp:266
const std::string makeTimeStamp(const std::chrono::system_clock::time_point &i_time)
make timestamp string, ie: 2012_08_17_16_04_59_148
int boolStringToInt(const char *i_value)
convert i_value string represnting boolean option and return one of: return 1 if i_value is one of: ...
Definition: helper.cpp:336
std::list< std::string > splitCsv(const std::string &i_values, const char *i_delimiters=",", bool i_isUnquote=false, char i_quote='\'')
split and trim comma-separated list of values (other delimiters can be used too, ie: semicolon).
int compareNoCase(const char *i_left, const char *i_right, size_t i_length=0)
case neutral string comparison
Definition: helper.cpp:64
bool isBigIntType(const char *i_typeName)
return true if model type is bigint (64 bit)
Definition: helper.cpp:272
void blankCrLf(std::string &io_str)
replace all <cr> or <lf> with blank space character
std::list< IRowBaseUptr > IRowBaseList
db rows: list of unique pointers to db row
Definition: omHelper.h:242
bool startWithNoCase(const std::string &i_str, const char *i_start)
check if string start with i_start, using case neutral string comparison
std::unique_ptr< IRowBase > IRowBaseUptr
unique pointer to db row
Definition: omHelper.h:236
void formatTo(size_t i_size, char *io_buffer, const char *i_format, va_list io_args)
format message into supplied buffer using vsnprintf()
Definition: helper.cpp:406
const std::string toString(double i_val)
convert float type to string: exist to fix std::to_string conversion losses.
Definition: helper.cpp:182
bool isIntType(const char *i_typeName, int i_typeId)
return true if model type is integer: not float, string, boolean, bigint (if type is not a built-in t...
Definition: helper.cpp:283
bool isFloatType(const char *i_typeName)
return true if model type is float (float, real, double or time)
Definition: helper.cpp:293
bool isFloatValid(const char *i_value)
return true if i_value string represent valid floating point constant
Definition: helper.cpp:314
const std::string toUnQuoted(const std::string &i_str, char i_quote='\'', const std::locale &i_locale=std::locale(""))
make unquoted string using sql single ' quote by default, ie: 'O''Brien' into O'Brien
const std::string normalizeLanguageName(const std::string &i_srcLanguage)
normalize language name by removing encoding part, replace _ by - and lower case: "en-ca" from "en_CA...
const std::list< std::string > splitLanguageName(const std::string &i_srcLanguage)
normalize language name and split it into list of prefered languages: en_CA => [en-ca,...
bool isBuiltInType(int i_typeId)
return true if model type id is built-in type id, ie: int, double, logical
Definition: helper.cpp:290
void toLower(std::string &io_str, const std::locale &i_locale=std::locale(""))
convert string to lower case
std::map< std::string, std::string, LessNoCase > NoCaseMap
map of key-value strings with case neutral key search
Definition: omHelper.h:224
std::string trim(const std::string &i_str, const std::locale &i_locale=std::locale(""))
trim leading and trailing blank and space characters
bool isTimeType(const char *i_typeName)
return true if model type is Time
Definition: helper.cpp:302
void toUpper(std::string &io_str, const std::locale &i_locale=std::locale(""))
convert string to upper case
bool equalNoCase(const char *i_left, const char *i_right, size_t i_length=0)
case neutral string equal comparison
Definition: helper.cpp:71
const std::string toDateTimeString(const std::string &i_timestamp)
make date-time string from timestamp string, ie: 2012_08_17_16_04_59_148 => 2012-08-17 16:04:59....
bool endWithNoCase(const std::string &i_str, const char *i_end)
check if string end with i_end, using case neutral string comparison
const std::string toQuoted(const std::string &i_str, char i_quote='\'')
make quoted string using sql single ' quote by default, ie: 'O''Brien'
std::vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:239
bool isBoolType(const char *i_typeName)
return true if model type is boolean (logical)
Definition: helper.cpp:260
const std::string replaceAll(const std::string &i_src, const char *i_oldValue, const char *i_newValue)
replace all occurence of i_oldValue by i_newValue, both old and new values must be not empty
std::set< std::string, LessNoCase > NoCaseSet
set of strings with case neutral key search
Definition: omHelper.h:227
const std::string cleanPathChars(const std::string &i_str, int i_maxSize=0)
replace all non non-printable and any of "'`$}{><:|?*&^;/\ by _ underscore.
final model run state public interface: thread safe
Definition: omHelper.h:246
virtual bool isError(void)=0
return true if status is an error
virtual bool isFinal(void)=0
return true if status is one of exiting: done, exit, error
db-row abstract base
Definition: omHelper.h:231
case neutral less comparator for strings
Definition: omHelper.h:216