ANNA Suite  2020b
Multipurpose development suite for Telco applications
functions.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_core_functions_hpp
10 #define anna_core_functions_hpp
11 
12 #include <stdlib.h>
13 
17 
22 
23 #include <anna/core/DataBlock.hpp>
24 
25 
26 #include <time.h>
27 #include <sys/time.h>
28 #include <string>
29 #include <vector>
30 
31 
32 //------------------------------------------------------------------------------
33 //---------------------------------------------------------------------- #define
34 //------------------------------------------------------------------------------
35 #define s_REGEXP_IPv4_ADDRESSES "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"
36 //#define s_REGEXP_IPv6_ADDRESSES "s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})))(%.+)?\\s*"
37 #define s_REGEXP_IPv6_ADDRESSES "s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})\
38 (\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\
39 \\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(\
40 25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\\d|[01]?\
41 \\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2\
42 [0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:\
43 ((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-\
44 5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\\d|[01]?\\d{1,2})(\\.(25[\
45 0-5]|2[0-4]\\d|[01]?\\d{1,2})){3})))(%.+)?\\s*"
46 
47 // Helpers for alarm parsing parameters:
48 #define STRING_WITH_QUOTATION_MARKS__C_STR(x) ((anna::functions::addQuotationMarks(x)).c_str())
49 #define ANNA_AS_STRING__C_STR(x) ((anna::functions::asString(x)).c_str())
50 
51 
52 
53 namespace anna {
54 
55 class DataBlock;
56 
57 #ifdef __CYGWIN__
58 #define CLOCK_PROCESS_CPUTIME_ID CLOCK_PROCESS_CPUTIME
59 #endif
60 
61 
65 struct functions {
72  static const int DateTimeSizeString = 21;
73 
77  static std::string getVersion() ;
78 
82  static std::string getArchitecture() ;
83 
87  static const int intBitSize = sizeof(int) * 8;
88 
89  /*
90  * Indica el nĂºmero de bits de un entero largo.
91  */
92  static const int int64BitSize = sizeof(S64) * 8;
93 
98  static std::string asString(const int number) ;
99 
104  static std::string asString(const unsigned int number) ;
105 
110  static std::string asString(const S64 number) ;
111 
116  static std::string asString(const U64 number) ;
117 
122  static const char* asString(const bool _bool) { return (_bool == true) ? "true" : "false"; }
123 
130  static std::string asString(const DataBlock& dataBlock, const int characterByLine = 16) ;
131 
138  static std::string asString(const double v, const char* format = "%e") ;
139 
146  static std::string asString(const float v, const char* format = "%f") ;
147 
153  static std::string asText(const char* comment, const int number)
154  {
155  std::string result(comment);
156  return result += asString(number);
157  }
158 
164  static std::string asText(const char* comment, const S64 number)
165  {
166  std::string result(comment);
167  return result += asString(number);
168  }
169 
175  static std::string asText(const char* comment, const bool _bool)
176  {
177  std::string result(comment);
178  return result += asString(_bool);
179  }
180 
187  static std::string asText(const char* comment, const DataBlock& dataBlock, const int characterByLine = 16)
188  {
189  std::string result(comment);
190  return result += asString(dataBlock, characterByLine);
191  }
192 
199  static std::string asText(const char* comment, const float value, const char* format = "%f")
200  {
201  std::string result(comment);
202  return result += asString(value, format);
203  }
204 
211  static std::string asText(const char* comment, const double value, const char* format = "%e")
212  {
213  std::string result(comment);
214  return result += asString(value, format);
215  }
216 
221  static std::string asHexString(const int number) ;
222 
227  static std::string asHexString(const S64 number) ;
228 
233  static std::string asHexString(const U64 number) { return asHexString((S64) number); }
234 
240  static std::string asHexText(const char* comment, const int number)
241  {
242  std::string result(comment);
243  return result += asHexString(number);
244  }
245 
251  static std::string asHexText(const char* comment, const S64 number)
252  {
253  std::string result(comment);
254  return result += asHexString(number);
255  }
256 
264  static std::string asHexString(const DataBlock& dataBlock) ;
265 
272  static DataBlock& fromHexString(const std::string& hexString, DataBlock& target) noexcept(false);
273 
281  static std::string asDateTime(const Second &second) ;
282 
293  static const char* asDateTime(const Second &second, char* result) ;
294 
299  static S64 hash(const char* str) ;
300 
305  static S64 hash(const std::string& str) { return hash(str.c_str()); }
306 
317  static std::string asString(const char* format, ...) ;
318 
329  template <typename T> static std::string asString(const T* t)
330  {
331  if(t == NULL) {
332  std::string result(T::className());
333  result += " { <null> }";
334  return result;
335  }
336 
337  return t->asString();
338  }
339 
346  static const std::string& asString(const std::string& str) { return str; }
347 
353  static void sleep(const Millisecond &millisecond) ;
354 
359  static Second second() {
360  Second result(::time(NULL));
361  return result;
362  }
363 
369  struct timeval tv;
370  gettimeofday(&tv, NULL);
371  Microsecond result((Microsecond::type_t)1000000 * tv.tv_sec + tv.tv_usec);
372  return result;
373  }
374 
380  struct timeval tv;
381  gettimeofday(&tv, NULL);
382  Millisecond result((Millisecond::type_t)1000 * tv.tv_sec + tv.tv_usec / 1000);
383  return result;
384  }
385 
391  timespec ts;
392  //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); // DONT works (original)
393  //clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); // DONT works
394  //clock_gettime(CLOCK_MONOTONIC, &ts); // works
395  // Note that CLOCK_MONOTONIC is subject to discontinuities from system time
396  // adjustment in Linux. CLOCK_MONOTONIC_RAW was defined to get around this
397  // (gets hardware time not adjusted by NTP).
398  clock_gettime(CLOCK_MONOTONIC, &ts); // works
399 
400  Microsecond result((Microsecond::type_t)1000000 * ts.tv_sec + ts.tv_nsec / 1000);
401  return result;
402  }
403 
414  static bool asBool(const char* str) noexcept(false);
415 
420  static int asInteger(const char* str) { return atoi(str); }
421 
426  static S64 asInteger64(const char* str) ;
427 
433  static pthread_t getCurrentThread() ;
434 
440  static bool supportMultithread() {
441  WHEN_SINGLETHREAD(return false);
442  WHEN_MULTITHREAD(return true);
443  }
444 
453  static bool isLike(const char* pattern, const std::string& value) noexcept(false);
454 
460  static int bitsize(const int n) { return (n == 0) ? 1 : functions::log2(n) + 1; }
461 
467  static int bitsize(const S64 n) {
468  int aux = n >> intBitSize;
469  return (aux != 0) ? (bitsize(aux) + intBitSize) : bitsize((int) n);
470  }
471 
482  static S64 merge(const char* whatis, const int n1, const int n2, const int bitShift) noexcept(false);
483 
489  static int log2(const unsigned int v) ;
490 
491 
492 
493 
495  // Text format resources /////////////////////////////////////////////////////////////////////////
498  enum _v {
499  None = -1, // Initialized
506  };
507  };
508 
510  enum _v {
511  None = -1, // Initialized
514  Right
515  };
516  };
517 
540  static std::string entriesAsString(int number, const char * wordForSingular = NULL, const char * wordForPlural = NULL) ;
541 
551  static std::string justify(const std::string & title, TextJustifyMode::_v mode = TextJustifyMode::Left, char filler = ' ') ;
552 
563  static std::string highlight(const std::string & title, TextHighlightMode::_v mode = TextHighlightMode::Underline, char filler = '-', bool appendCR = true) ;
564 
577  static std::string highlightJustify(const std::string & title, TextHighlightMode::_v hMode = TextHighlightMode::OverAndUnderline, TextJustifyMode::_v jMode = TextJustifyMode::Center, char highlightFiller = '=', char justifyFiller = ' ', bool appendCR = true) {
578  return(highlight(justify(title, jMode, justifyFiller), hMode, highlightFiller, appendCR));
579  }
580 
587  static std::string tab(const std::string & text, int tabSpaces = 3) ;
588 
589 
591  // Conversions and helpers ///////////////////////////////////////////////////////////////////////
593 
605  template <typename T> static T* componentByName(const char *className, const char* fromFile, const int fromLine)
606  noexcept(false) {
608  T* result = static_cast <T*>(cm.find(className));
609 
610  if(result == NULL) {
611  std::string msg(className);
612  msg += " | Unregistered component";
613  throw RuntimeException(msg, fromFile, fromLine);
614  }
615 
616  return result;
617  }
618 
633  template <typename T> static T* component(const char* fromFile, const int fromLine)
634  noexcept(false) {
635  return functions::componentByName<T> (T::getClassName(), fromFile, fromLine);
636  }
637 
646  static bool endsWith(const std::string & pattern, const std::string & suffix) {
647  std::string dummy;
648  return endsWith(pattern, suffix, dummy);
649  }
650 
654  static bool endsWith(const std::string & pattern, const std::string & suffix, std::string & preffix) ;
655 
664  static bool startsWith(const std::string & pattern, const std::string & preffix) {
665  std::string dummy;
666  return startsWith(pattern, preffix, dummy);
667  }
668 
672  static bool startsWith(const std::string & pattern, const std::string & preffix, std::string & suffix) ;
673 
685  static std::string replace(const std::string & text, const char *item, const char *target, bool all = true) ;
686 
690  static std::string addQuotationMarks(const std::string & str) ;
691  static std::string addQuotationMarks(const char * str) ;
692  static std::string addQuotationMarks(const int & integer) ;
693 
698  static std::string vectorToStringRepresentation(const std::vector<int> & v, const char separator = ' ') ;
699 
704  static std::string vectorToStringRepresentation(const std::vector<std::string> & v, const char separator = ' ') ;
705 
709  static std::string socketLiteralAsString(const std::string & address, int port) ;
710 
720  static std::string asAsciiString(const char * buffer, int size, bool & isFullyPrintable) ;
721 
725  static std::string asAsciiString(const char * buffer, int size) {
726  bool isFullyPrintable;
727  return asAsciiString(buffer, size, isFullyPrintable);
728  }
729 
733  static std::string asAsciiString(const DataBlock & db, bool & isFullyPrintable) {
734  return asAsciiString(db.getData(), db.getSize(), isFullyPrintable);
735  }
736 
740  static std::string asAsciiString(const DataBlock & db) {
741  bool isFullyPrintable;
742  return asAsciiString(db.getData(), db.getSize(), isFullyPrintable);
743  }
744 
745 
761  static DataBlock rawIpPresentationAsRaw(const std::string & rawPresentation) noexcept(false);
762 
763 
780  static std::string rawIpPresentationToIpAsString(const std::string & rawPresentation, bool normalize = false) noexcept(false) {
781  return rawIpAsString(rawIpPresentationAsRaw(rawPresentation), normalize);
782  }
783 
784 
798  static std::string rawIpAsRawIpPresentation(const DataBlock & db) noexcept(false);
799 
800 
806  static std::string getHostname() ;
807 
813  static std::string getDomainname() ;
814 
823  static std::string getFQDN(const char *hostname = NULL, const char *domainname = NULL) ;
824 
830  static std::string getHostnameIP() ;
831 
832 
833 
835  // IP Address resources //////////////////////////////////////////////////////////////////////////
837 
841  struct IPv4Type {
842  enum _v {
843  Estrict = -1, // Initialized,
845  Mapped
846  };
847  };
848 
857  static bool isIPv4(const std::string & ip, IPv4Type::_v ipv4Type = IPv4Type::Estrict) ;
858 
866  static bool isIPv6(const std::string & ip) ;
867 
875  static std::string IPv4To6(const std::string & ipv4) noexcept(false);
876 
888  static std::string normalizeIP(const std::string & ip) noexcept(false);
889 
898  static bool sameIP(const std::string & ip1, const std::string & ip2) noexcept(false);
899 
908  static bool matchIPv6(const std::string & ipv6, const std::string & preffixedIpv6) noexcept(false);
909 
917  static DataBlock ipAsRaw(const std::string & ip) noexcept(false);
918 
927  static std::string rawIpAsString(const DataBlock & db, bool normalize = false) noexcept(false) {
928  return (rawIpAsString(db.getData(), db.getSize(), normalize));
929  }
930 
940  static std::string rawIpAsString(const char *buffer, int bufferLength, bool normalize = false) noexcept(false);
941 
953  static std::string abbreviateIP(const std::string & ip) noexcept(false) {
954  return (rawIpAsString(ipAsRaw(ip)));
955  }
956 
957 
958 
959 
960  // socket literal description typedef, vectors and conversion tools
961 
969  static void getAddressAndPortFromSocketLiteral(const std::string &literal, std::string &address, int &port) ;
970 
977  static socket_v getSocketVectorFromString(const std::string & list) ;
978 
986  static std::string socketVectorAsString(const socket_v & socketVector) ;
987 
988 
994  static bool littleEndian() ;
995 
1002  static const char* codeInteger(char* result, const int n) ;
1003 
1010  static const char* codeShort(char* result, const short int n) ;
1011 
1018  static const char* codeInteger64(char* result, const S64 n) ;
1019 
1026  static const char* codeFloat(char* result, const float n) ;
1027 
1034  static const char* codeDouble(char* result, const double n) ;
1035 
1041  static int decodeInteger(const char* data) ;
1042 
1048  static short int decodeShort(const char* data) ;
1049 
1055  static S64 decodeInteger64(const char* data) ;
1056 
1062  static float decodeFloat(const char* data) ;
1063 
1069  static double decodeDouble(const char* data) ;
1070 
1071 
1080  static void decodeIsupNumber(const char *buffer, int length, isup_number_t & isupNumber, bool calledOrCalling) noexcept(false);
1081 
1090  static void codeIsupNumber(const isup_number_t & isupNumber, bool calledOrCalling, char * buffer, int & length) noexcept(false);
1091 
1099  static void codeIsupNumber(const isup_number_t & isupNumber, bool calledOrCalling, std::string & target) noexcept(false);
1100 
1108  static std::string encodeBase64(const U8* buf, unsigned int bufLen);
1109  static std::string encodeBase64(const std::string & str)
1110  {
1111  return encodeBase64((const U8 *)str.c_str(), str.size());
1112  }
1113 
1121  static std::string decodeBase64(const std::string & encodedString);
1122 
1123 
1124  /*
1125  * Reads a file into passed string
1126  *
1127  * @param pathfile Path file to read
1128  * @param content String where file content is dump
1129  *
1130  * @return success for read operation
1131  */
1132  static bool getContentFromFile(const std::string &pathfile, std::string &content) noexcept(false);
1133 };
1134 
1135 }
1136 
1137 #endif
1138 
static const char * codeFloat(char *result, const float n)
static std::string vectorToStringRepresentation(const std::vector< int > &v, const char separator=' ')
_v
Definition: functions.hpp:510
Definition: Millisecond.hpp:24
S64 type_t
Definition: Microsecond.hpp:24
static int asInteger(const char *str)
Definition: functions.hpp:420
#define WHEN_MULTITHREAD(a)
Definition: defines.hpp:96
static bool isIPv6(const std::string &ip)
static bool getContentFromFile(const std::string &pathfile, std::string &content) noexcept(false)
Definition: functions.hpp:509
static std::string tab(const std::string &text, int tabSpaces=3)
static void codeIsupNumber(const isup_number_t &isupNumber, bool calledOrCalling, char *buffer, int &length) noexcept(false)
Definition: ComponentManager.hpp:29
static std::string decodeBase64(const std::string &encodedString)
static std::string entriesAsString(int number, const char *wordForSingular=NULL, const char *wordForPlural=NULL)
static socket_v getSocketVectorFromString(const std::string &list)
static DataBlock & fromHexString(const std::string &hexString, DataBlock &target) noexcept(false)
Definition: functions.hpp:513
static std::string asText(const char *comment, const int number)
Definition: functions.hpp:153
static S64 merge(const char *whatis, const int n1, const int n2, const int bitShift) noexcept(false)
static const char * codeShort(char *result, const short int n)
static std::string highlightJustify(const std::string &title, TextHighlightMode::_v hMode=TextHighlightMode::OverAndUnderline, TextJustifyMode::_v jMode=TextJustifyMode::Center, char highlightFiller='=', char justifyFiller=' ', bool appendCR=true)
Definition: functions.hpp:577
static std::string rawIpAsString(const DataBlock &db, bool normalize=false) noexcept(false)
Definition: functions.hpp:927
const char * getData() const
Definition: DataBlock.hpp:86
static bool supportMultithread()
Definition: functions.hpp:440
static bool isIPv4(const std::string &ip, IPv4Type::_v ipv4Type=IPv4Type::Estrict)
static std::string asAsciiString(const char *buffer, int size, bool &isFullyPrintable)
static S64 decodeInteger64(const char *data)
Definition: Second.hpp:25
static std::string normalizeIP(const std::string &ip) noexcept(false)
static DataBlock rawIpPresentationAsRaw(const std::string &rawPresentation) noexcept(false)
static int bitsize(const S64 n)
Definition: functions.hpp:467
static std::string getFQDN(const char *hostname=NULL, const char *domainname=NULL)
int64_t S64
Definition: defines.hpp:84
static const int DateTimeSizeString
Definition: functions.hpp:72
static const char * codeDouble(char *result, const double n)
Definition: functions.hpp:497
static std::string asText(const char *comment, const S64 number)
Definition: functions.hpp:164
static std::string asString(const int number)
static const char * codeInteger64(char *result, const S64 n)
static Millisecond millisecond()
Definition: functions.hpp:379
static S64 asInteger64(const char *str)
#define WHEN_SINGLETHREAD(a)
Definition: defines.hpp:97
static std::string asText(const char *comment, const double value, const char *format="%e")
Definition: functions.hpp:211
static std::string encodeBase64(const std::string &str)
Definition: functions.hpp:1109
static std::string highlight(const std::string &title, TextHighlightMode::_v mode=TextHighlightMode::Underline, char filler='-', bool appendCR=true)
Definition: functions.hpp:841
static std::string getArchitecture()
static int decodeInteger(const char *data)
static bool startsWith(const std::string &pattern, const std::string &preffix)
Definition: functions.hpp:664
static bool asBool(const char *str) noexcept(false)
static std::string getDomainname()
static std::string getVersion()
Definition: functions.hpp:843
static std::string socketLiteralAsString(const std::string &address, int port)
static std::string rawIpPresentationToIpAsString(const std::string &rawPresentation, bool normalize=false) noexcept(false)
Definition: functions.hpp:780
static void sleep(const Millisecond &millisecond)
int getSize() const
Definition: DataBlock.hpp:78
static std::string IPv4To6(const std::string &ipv4) noexcept(false)
static const char * asString(const bool _bool)
Definition: functions.hpp:122
static bool isLike(const char *pattern, const std::string &value) noexcept(false)
static bool sameIP(const std::string &ip1, const std::string &ip2) noexcept(false)
static std::string asAsciiString(const DataBlock &db, bool &isFullyPrintable)
Definition: functions.hpp:733
Definition: functions.hpp:65
static std::string getHostname()
static S64 hash(const char *str)
static bool littleEndian()
Definition: defines.hpp:152
unsigned char U8
Definition: defines.hpp:62
static const char * codeInteger(char *result, const int n)
static Microsecond microsecond()
Definition: functions.hpp:368
static std::string asText(const char *comment, const DataBlock &dataBlock, const int characterByLine=16)
Definition: functions.hpp:187
static std::string socketVectorAsString(const socket_v &socketVector)
static std::string rawIpAsRawIpPresentation(const DataBlock &db) noexcept(false)
static std::string asHexText(const char *comment, const S64 number)
Definition: functions.hpp:251
static std::string asHexString(const int number)
static int bitsize(const int n)
Definition: functions.hpp:460
static const int intBitSize
Definition: functions.hpp:87
static void decodeIsupNumber(const char *buffer, int length, isup_number_t &isupNumber, bool calledOrCalling) noexcept(false)
Definition: app.hpp:12
uint64_t U64
Definition: defines.hpp:81
S64 type_t
Definition: Millisecond.hpp:26
static std::string asHexText(const char *comment, const int number)
Definition: functions.hpp:240
static T * component(const char *fromFile, const int fromLine) noexcept(false)
Definition: functions.hpp:633
static std::string abbreviateIP(const std::string &ip) noexcept(false)
Definition: functions.hpp:953
static const std::string & asString(const std::string &str)
Definition: functions.hpp:346
static bool endsWith(const std::string &pattern, const std::string &suffix)
Definition: functions.hpp:646
_v
Definition: functions.hpp:842
static std::string asAsciiString(const DataBlock &db)
Definition: functions.hpp:740
static pthread_t getCurrentThread()
static std::string getHostnameIP()
static bool matchIPv6(const std::string &ipv6, const std::string &preffixedIpv6) noexcept(false)
static std::string addQuotationMarks(const std::string &str)
static short int decodeShort(const char *data)
static T * componentByName(const char *className, const char *fromFile, const int fromLine) noexcept(false)
Definition: functions.hpp:605
static std::string asText(const char *comment, const bool _bool)
Definition: functions.hpp:175
static std::string asString(const T *t)
Definition: functions.hpp:329
std::vector< socket_t > socket_v
Definition: defines.hpp:109
Definition: functions.hpp:512
static std::string asHexString(const U64 number)
Definition: functions.hpp:233
static std::string encodeBase64(const U8 *buf, unsigned int bufLen)
static std::string justify(const std::string &title, TextJustifyMode::_v mode=TextJustifyMode::Left, char filler=' ')
static std::string asText(const char *comment, const float value, const char *format="%f")
Definition: functions.hpp:199
static const int int64BitSize
Definition: functions.hpp:92
Definition: RuntimeException.hpp:23
static std::string asAsciiString(const char *buffer, int size)
Definition: functions.hpp:725
static Microsecond hardwareClock()
Definition: functions.hpp:390
static ComponentManager & instantiate()
Definition: Singleton.hpp:81
static void getAddressAndPortFromSocketLiteral(const std::string &literal, std::string &address, int &port)
static int log2(const unsigned int v)
Definition: functions.hpp:844
Definition: functions.hpp:499
Definition: DataBlock.hpp:24
static DataBlock ipAsRaw(const std::string &ip) noexcept(false)
static std::string replace(const std::string &text, const char *item, const char *target, bool all=true)
_v
Definition: functions.hpp:498
Component * find(const char *className)
Definition: Microsecond.hpp:22
static double decodeDouble(const char *data)
static float decodeFloat(const char *data)
static S64 hash(const std::string &str)
Definition: functions.hpp:305
static std::string asDateTime(const Second &second)
static Second second()
Definition: functions.hpp:359