Yate
yateclass.h
1 
22 #ifndef __YATECLASS_H
23 #define __YATECLASS_H
24 
25 #ifndef __cplusplus
26 #error C++ is required
27 #endif
28 
29 #include <limits.h>
30 #include <sys/types.h>
31 #include <stddef.h>
32 #include <unistd.h>
33 #include <errno.h>
34 #include <stdarg.h>
35 
36 #ifndef _WORDSIZE
37 #if defined(__arch64__) || defined(__x86_64__) \
38  || defined(__amd64__) || defined(__ia64__) \
39  || defined(__alpha__) || defined(__sparcv9) || defined(__mips64)
40 #define _WORDSIZE 64
41 #else
42 #define _WORDSIZE 32
43 #endif
44 #endif
45 
46 #ifndef _WINDOWS
47 #if defined(WIN32) || defined(_WIN32)
48 #define _WINDOWS
49 #endif
50 #endif
51 
52 #ifdef _WINDOWS
53 
54 #include <windows.h>
55 #include <io.h>
56 #include <direct.h>
57 
61 typedef signed __int8 int8_t;
62 typedef unsigned __int8 u_int8_t;
63 typedef unsigned __int8 uint8_t;
64 typedef signed __int16 int16_t;
65 typedef unsigned __int16 u_int16_t;
66 typedef unsigned __int16 uint16_t;
67 typedef signed __int32 int32_t;
68 typedef unsigned __int32 u_int32_t;
69 typedef unsigned __int32 uint32_t;
70 typedef signed __int64 int64_t;
71 typedef unsigned __int64 u_int64_t;
72 typedef unsigned __int64 uint64_t;
73 
74 typedef int pid_t;
75 typedef int socklen_t;
76 typedef unsigned long in_addr_t;
77 
78 #ifndef strcasecmp
79 #define strcasecmp _stricmp
80 #endif
81 
82 #ifndef strncasecmp
83 #define strncasecmp _strnicmp
84 #endif
85 
86 #define vsnprintf _vsnprintf
87 #define snprintf _snprintf
88 #define strdup _strdup
89 #define strtoll _strtoi64
90 #define open _open
91 #define dup2 _dup2
92 #define read _read
93 #define write _write
94 #define close _close
95 #define getpid _getpid
96 #define chdir _chdir
97 #define mkdir(p,m) _mkdir(p)
98 #define unlink _unlink
99 
100 #define O_RDWR _O_RDWR
101 #define O_RDONLY _O_RDONLY
102 #define O_WRONLY _O_WRONLY
103 #define O_APPEND _O_APPEND
104 #define O_BINARY _O_BINARY
105 #define O_EXCL _O_EXCL
106 #define O_CREAT _O_CREAT
107 #define O_TRUNC _O_TRUNC
108 #define O_NOCTTY 0
109 
110 #define S_IRUSR _S_IREAD
111 #define S_IWUSR _S_IWRITE
112 #define S_IXUSR 0
113 #define S_IRWXU (_S_IREAD|_S_IWRITE)
114 
115 #ifdef LIBYATE_EXPORTS
116 #define YATE_API __declspec(dllexport)
117 #else
118 #ifndef LIBYATE_STATIC
119 #define YATE_API __declspec(dllimport)
120 #endif
121 #endif
122 
123 #define FMT64 "%I64d"
124 #define FMT64U "%I64u"
125 
126 #else /* _WINDOWS */
127 
128 #include <sys/time.h>
129 #include <sys/socket.h>
130 
131 #if defined(__FreeBSD__)
132 #include <netinet/in_systm.h>
133 #endif
134 
135 #include <netinet/in.h>
136 #include <netinet/ip.h>
137 #include <netinet/tcp.h>
138 #include <arpa/inet.h>
139 #include <netdb.h>
140 
144 #ifndef SOCKET
145 typedef int SOCKET;
146 #endif
147 #ifndef HANDLE
148 typedef int HANDLE;
149 #endif
150 
151 #ifndef O_BINARY
152 #define O_BINARY 0
153 #endif
154 
155 #if _WORDSIZE == 64 && !defined(__APPLE__)
156 #define FMT64 "%ld"
157 #define FMT64U "%lu"
158 #else
159 #define FMT64 "%lld"
160 #define FMT64U "%llu"
161 #endif
162 
163 #endif /* ! _WINDOWS */
164 
165 #ifndef LLONG_MAX
166 #ifdef _I64_MAX
167 #define LLONG_MAX _I64_MAX
168 #else
169 #define LLONG_MAX 9223372036854775807LL
170 #endif
171 #endif
172 
173 #ifndef LLONG_MIN
174 #ifdef _I64_MIN
175 #define LLONG_MIN _I64_MIN
176 #else
177 #define LLONG_MIN (-LLONG_MAX - 1LL)
178 #endif
179 #endif
180 
181 #ifndef ULLONG_MAX
182 #ifdef _UI64_MAX
183 #define ULLONG_MAX _UI64_MAX
184 #else
185 #define ULLONG_MAX 18446744073709551615ULL
186 #endif
187 #endif
188 
189 #ifndef O_LARGEFILE
190 #define O_LARGEFILE 0
191 #endif
192 
193 #ifndef IPTOS_LOWDELAY
194 #define IPTOS_LOWDELAY 0x10
195 #define IPTOS_THROUGHPUT 0x08
196 #define IPTOS_RELIABILITY 0x04
197 #endif
198 #ifndef IPTOS_MINCOST
199 #define IPTOS_MINCOST 0x02
200 #endif
201 #ifndef IPPROTO_SCTP
202 #define IPPROTO_SCTP 132
203 #endif
204 
205 #ifndef YATE_API
206 #define YATE_API
207 #endif
208 
209 #ifdef _WINDOWS
210 #undef RAND_MAX
211 #define RAND_MAX 2147483647
212 #endif
213 
217 namespace TelEngine {
218 
219 #ifdef HAVE_GCC_FORMAT_CHECK
220 #define FORMAT_CHECK(f) __attribute__((format(printf,(f),(f)+1)))
221 #else
222 #define FORMAT_CHECK(f)
223 #endif
224 
225 #define YIGNORE(v) while (v) { break; }
226 
227 #ifdef HAVE_BLOCK_RETURN
228 #define YSTRING(s) (*({static const String str("" s);&str;}))
229 #define YATOM(s) (*({static const String* str(0);str ? str : String::atom(str,"" s);}))
230 #else
231 #define YSTRING(s) ("" s)
232 #define YATOM(s) ("" s)
233 #endif
234 
235 #define YSTRING_INIT_HASH ((unsigned) -1)
236 
241 YATE_API void abortOnBug();
242 
247 YATE_API bool abortOnBug(bool doAbort);
248 
255  DebugFail = 0,
256  DebugTest = 1,
257  DebugCrit = 2,
258  DebugGoOn = DebugCrit,
259  DebugConf = 3,
260  DebugStub = 4,
261  DebugWarn = 5,
262  DebugMild = 6,
263  DebugNote = 7,
264  DebugCall = 8,
265  DebugInfo = 9,
266  DebugAll = 10
267 };
268 
273 YATE_API int debugLevel();
274 
280 YATE_API int debugLevel(int level);
281 
287 YATE_API bool debugAt(int level);
288 
295 YATE_API const char* debugColor(int level);
296 
302 YATE_API const char* debugLevelName(int level);
303 
309 class YATE_API DebugEnabler
310 {
311 public:
317  inline DebugEnabler(int level = TelEngine::debugLevel(), bool enabled = true)
318  : m_level(DebugFail), m_enabled(enabled), m_chain(0), m_name(0)
319  { debugLevel(level); }
320 
321  inline ~DebugEnabler()
322  { m_name = 0; m_chain = 0; }
323 
328  inline int debugLevel() const
329  { return m_chain ? m_chain->debugLevel() : m_level; }
330 
336  int debugLevel(int level);
337 
342  inline bool debugEnabled() const
343  { return m_chain ? m_chain->debugEnabled() : m_enabled; }
344 
349  inline void debugEnabled(bool enable)
350  { m_enabled = enable; m_chain = 0; }
351 
356  inline const char* debugName() const
357  { return m_name; }
358 
364  bool debugAt(int level) const;
365 
370  inline bool debugChained() const
371  { return m_chain != 0; }
372 
377  inline void debugChain(const DebugEnabler* chain = 0)
378  { m_chain = (chain != this) ? chain : 0; }
379 
384  void debugCopy(const DebugEnabler* original = 0);
385 
386 protected:
391  inline void debugName(const char* name)
392  { m_name = name; }
393 
394 private:
395  int m_level;
396  bool m_enabled;
397  const DebugEnabler* m_chain;
398  const char* m_name;
399 };
400 
401 #if 0 /* for documentation generator */
402 
407 void DDebug(int level, const char* format, ...);
408 
414 void DDebug(const char* facility, int level, const char* format, ...);
415 
421 void DDebug(const DebugEnabler* local, int level, const char* format, ...);
422 
428 void XDebug(int level, const char* format, ...);
429 
435 void XDebug(const char* facility, int level, const char* format, ...);
436 
442 void XDebug(const DebugEnabler* local, int level, const char* format, ...);
443 
449 void NDebug(int level, const char* format, ...);
450 
456 void NDebug(const char* facility, int level, const char* format, ...);
457 
463 void NDebug(const DebugEnabler* local, int level, const char* format, ...);
464 #endif
465 
466 #if defined(_DEBUG) || defined(DEBUG) || defined(XDEBUG)
467 #undef DEBUG
468 #define DEBUG 1
469 #endif
470 
471 #ifdef DEBUG
472 #define DDebug Debug
473 #else
474 #ifdef _WINDOWS
475 #define DDebug do { break; } while
476 #else
477 #define DDebug(arg...)
478 #endif
479 #endif
480 
481 #ifdef XDEBUG
482 #define XDebug Debug
483 #else
484 #ifdef _WINDOWS
485 #define XDebug do { break; } while
486 #else
487 #define XDebug(arg...)
488 #endif
489 #endif
490 
491 #ifndef NDEBUG
492 #define NDebug Debug
493 #else
494 #ifdef _WINDOWS
495 #define NDebug do { break; } while
496 #else
497 #define NDebug(arg...)
498 #endif
499 #endif
500 
506 YATE_API void Debug(int level, const char* format, ...) FORMAT_CHECK(2);
507 
514 YATE_API void Debug(const char* facility, int level, const char* format, ...) FORMAT_CHECK(3);
515 
522 YATE_API void Debug(const DebugEnabler* local, int level, const char* format, ...) FORMAT_CHECK(3);
523 
530 YATE_API void Alarm(const char* component, int level, const char* format, ...) FORMAT_CHECK(3);
531 
538 YATE_API void Alarm(const DebugEnabler* component, int level, const char* format, ...) FORMAT_CHECK(3);
539 
547 YATE_API void Alarm(const char* component, const char* info, int level, const char* format, ...) FORMAT_CHECK(4);
548 
556 YATE_API void Alarm(const DebugEnabler* component, const char* info, int level, const char* format, ...) FORMAT_CHECK(4);
557 
562 YATE_API void Output(const char* format, ...) FORMAT_CHECK(1);
563 
570 class YATE_API Debugger
571 {
572 public:
576  enum Formatting {
577  None = 0,
578  Relative, // from program start
579  Absolute, // from EPOCH (1-1-1970)
580  Textual, // absolute GMT in YYYYMMDDhhmmss.uuuuuu format
581  TextLocal, // local time in YYYYMMDDhhmmss.uuuuuu format
582  TextSep, // absolute GMT in YYYY-MM-DD_hh:mm:ss.uuuuuu format
583  TextLSep, // local time in YYYY-MM-DD_hh:mm:ss.uuuuuu format
584  };
585 
591  explicit Debugger(const char* name, const char* format = 0, ...);
592 
599  Debugger(int level, const char* name, const char* format = 0, ...);
600 
604  ~Debugger();
605 
610  static void setOutput(void (*outFunc)(const char*,int) = 0);
611 
616  static void setIntOut(void (*outFunc)(const char*,int) = 0);
617 
622  static void setAlarmHook(void (*alarmFunc)(const char*,int,const char*,const char*) = 0);
623 
628  static void setRelayHook(void (*relayFunc)(int,const char*,const char*,const char*) = 0);
629 
635  static void enableOutput(bool enable = true, bool colorize = false);
636 
641  static uint32_t getStartTimeSec();
642 
647  static Formatting getFormatting();
648 
654  static void setFormatting(Formatting format, uint32_t startTimeSec = 0);
655 
662  static unsigned int formatTime(char* buf, Formatting format = getFormatting());
663 
672  static void relayOutput(int level, char* buffer, const char* component = 0, const char* info = 0);
673 
674 private:
675  const char* m_name;
676  int m_level;
677 };
678 
683 struct TokenDict {
687  const char* token;
688 
692  int value;
693 };
694 
695 class String;
696 class Mutex;
697 class ObjList;
698 class NamedCounter;
699 
700 #if 0 /* for documentation generator */
701 
705 void YIGNORE(primitive value);
706 
712 constant YSTRING(const char* string);
713 
719 constant YATOM(const char* string);
720 
726 void YCLASS(class type,class base);
727 
734 void YCLASS2(class type,class base1,class base2);
735 
743 void YCLASS3(class type,class base1,class base2,class base3);
744 
750 void YCLASSIMP(class type,class base);
751 
758 void YCLASSIMP2(class type,class base1,class base2);
759 
767 void YCLASSIMP3(class type,class base1,class base2,class base3);
768 
775 class* YOBJECT(class type,GenObject* pntr);
776 
781 void YNOCOPY(class type);
782 #endif
783 
784 #define YCLASS(type,base) \
785 public: virtual void* getObject(const String& name) const \
786 { return (name == YATOM(#type)) ? const_cast<type*>(this) : base::getObject(name); }
787 
788 #define YCLASS2(type,base1,base2) \
789 public: virtual void* getObject(const String& name) const \
790 { if (name == YATOM(#type)) return const_cast<type*>(this); \
791  void* tmp = base1::getObject(name); \
792  return tmp ? tmp : base2::getObject(name); }
793 
794 #define YCLASS3(type,base1,base2,base3) \
795 public: virtual void* getObject(const String& name) const \
796 { if (name == YATOM(#type)) return const_cast<type*>(this); \
797  void* tmp = base1::getObject(name); \
798  if (tmp) return tmp; \
799  tmp = base2::getObject(name); \
800  return tmp ? tmp : base3::getObject(name); }
801 
802 #define YCLASSIMP(type,base) \
803 void* type::getObject(const String& name) const \
804 { return (name == YATOM(#type)) ? const_cast<type*>(this) : base::getObject(name); }
805 
806 #define YCLASSIMP2(type,base1,base2) \
807 void* type::getObject(const String& name) const \
808 { if (name == YATOM(#type)) return const_cast<type*>(this); \
809  void* tmp = base1::getObject(name); \
810  return tmp ? tmp : base2::getObject(name); }
811 
812 #define YCLASSIMP3(type,base1,base2,base3) \
813 void* type::getObject(const String& name) const \
814 { if (name == YATOM(#type)) return const_cast<type*>(this); \
815  void* tmp = base1::getObject(name); \
816  if (tmp) return tmp; \
817  tmp = base2::getObject(name); \
818  return tmp ? tmp : base3::getObject(name); }
819 
820 #define YOBJECT(type,pntr) (static_cast<type*>(GenObject::getObject(YATOM(#type),pntr)))
821 
822 #define YNOCOPY(type) private: \
823 type(const type&); \
824 void operator=(const type&)
825 
826 
830 class YATE_API GenObject
831 {
832  YNOCOPY(GenObject); // no automatic copies please
833 public:
837  GenObject();
838 
842  virtual ~GenObject() { setObjCounter(0); }
843 
850  virtual bool alive() const;
851 
855  virtual void destruct();
856 
863  virtual const String& toString() const;
864 
870  virtual void* getObject(const String& name) const;
871 
878  static inline void* getObject(const String& name, const GenObject* obj)
879  { return obj ? obj->getObject(name) : 0; }
880 
885  static inline bool getObjCounting()
886  { return s_counting; }
887 
892  static inline void setObjCounting(bool enable)
893  { s_counting = enable; }
894 
899  inline NamedCounter* getObjCounter() const
900  { return m_counter; }
901 
907  NamedCounter* setObjCounter(NamedCounter* counter);
908 
915  static NamedCounter* getObjCounter(const String& name, bool create = true);
916 
921  static ObjList& getObjCounters();
922 
923 private:
924  NamedCounter* m_counter;
925  static bool s_counting;
926 };
927 
933 inline void destruct(GenObject* obj)
934  { if (obj) obj->destruct(); }
935 
942 template <class Obj> void destruct(Obj*& obj)
943  { if (obj) { obj->destruct(); obj = 0; } }
944 
949 class YATE_API RefObject : public GenObject
950 {
951  YNOCOPY(RefObject); // no automatic copies please
952 public:
957  RefObject();
958 
962  virtual ~RefObject();
963 
969  virtual void* getObject(const String& name) const;
970 
977  virtual bool alive() const;
978 
983  bool ref();
984 
993  bool deref();
994 
999  inline int refcount() const
1000  { return m_refcount; }
1001 
1006  virtual void destruct();
1007 
1013  inline static bool alive(const RefObject* obj)
1014  { return obj && (obj->refcount() > 0); }
1015 
1021  static bool efficientIncDec();
1022 
1023 protected:
1029  virtual void zeroRefs();
1030 
1036  bool resurrect();
1037 
1043  virtual void destroyed();
1044 
1045 private:
1046  int m_refcount;
1047  Mutex* m_mutex;
1048 };
1049 
1055 class YATE_API RefPointerBase
1056 {
1057 protected:
1062  : m_pointer(0) { }
1063 
1070  void assign(RefObject* oldptr, RefObject* newptr, void* pointer);
1071 
1075  void* m_pointer;
1076 };
1077 
1081 template <class Obj = RefObject> class RefPointer : public RefPointerBase
1082 {
1083 protected:
1088  inline Obj* pointer() const
1089  { return static_cast<Obj*>(m_pointer); }
1090 
1095  inline void assign(Obj* object = 0)
1096  { RefPointerBase::assign(pointer(),object,object); }
1097 
1098 public:
1102  inline RefPointer()
1103  { }
1104 
1109  inline RefPointer(const RefPointer<Obj>& value)
1110  : RefPointerBase()
1111  { assign(value); }
1112 
1117  inline RefPointer(Obj* object)
1118  { assign(object); }
1119 
1123  inline ~RefPointer()
1124  { assign(); }
1125 
1130  { assign(value.pointer()); return *this; }
1131 
1135  inline RefPointer<Obj>& operator=(Obj* object)
1136  { assign(object); return *this; }
1137 
1142  inline operator Obj*() const
1143  { return pointer(); }
1144 
1148  inline Obj* operator->() const
1149  { return pointer(); }
1150 
1154  inline Obj& operator*() const
1155  { return *pointer(); }
1156 };
1157 
1161 template <class Obj = GenObject> class GenPointer : public GenObject
1162 {
1163 private:
1167  Obj* m_pointer;
1168 
1169 public:
1173  inline GenPointer()
1174  : m_pointer(0)
1175  { }
1176 
1181  inline GenPointer(const GenPointer<Obj>& value)
1182  : m_pointer(value)
1183  { }
1184 
1189  inline GenPointer(Obj* object)
1190  : m_pointer(object)
1191  { }
1192 
1197  { m_pointer = value; return *this; }
1198 
1202  inline GenPointer<Obj>& operator=(Obj* object)
1203  { m_pointer = object; return *this; }
1204 
1209  inline operator Obj*() const
1210  { return m_pointer; }
1211 
1215  inline Obj* operator->() const
1216  { return m_pointer; }
1217 
1221  inline Obj& operator*() const
1222  { return *m_pointer; }
1223 };
1224 
1229 class YATE_API ObjList : public GenObject
1230 {
1231  YNOCOPY(ObjList); // no automatic copies please
1232 public:
1236  ObjList();
1237 
1241  virtual ~ObjList();
1242 
1248  virtual void* getObject(const String& name) const;
1249 
1254  unsigned int length() const;
1255 
1260  unsigned int count() const;
1261 
1266  inline GenObject* get() const
1267  { return m_obj; }
1268 
1275  GenObject* set(const GenObject* obj, bool delold = true);
1276 
1281  inline ObjList* next() const
1282  { return m_next; }
1283 
1288  ObjList* last() const;
1289 
1294  ObjList* skipNull() const;
1295 
1300  ObjList* skipNext() const;
1301 
1307  GenObject* at(int index) const;
1308 
1314  ObjList* operator+(int index) const;
1315 
1321  inline GenObject* operator[](signed int index) const
1322  { return at(index); }
1323 
1329  inline GenObject* operator[](unsigned int index) const
1330  { return at(index); }
1331 
1337  GenObject* operator[](const String& str) const;
1338 
1344  ObjList* find(const GenObject* obj) const;
1345 
1351  ObjList* find(const String& str) const;
1352 
1358  int index(const GenObject* obj) const;
1359 
1365  int index(const String& str) const;
1366 
1373  ObjList* insert(const GenObject* obj, bool compact = true);
1374 
1381  ObjList* append(const GenObject* obj, bool compact = true);
1382 
1389  ObjList* setUnique(const GenObject* obj, bool compact = true);
1390 
1396  GenObject* remove(bool delobj = true);
1397 
1404  GenObject* remove(GenObject* obj, bool delobj = true);
1405 
1412  GenObject* remove(const String& str, bool delobj = true);
1413 
1417  void clear();
1418 
1422  void compact();
1423 
1428  inline bool autoDelete()
1429  { return m_delete; }
1430 
1435  inline void setDelete(bool autodelete)
1436  { m_delete = autodelete; }
1437 
1442  static const ObjList& empty();
1443 
1456  void sort(int (*callbackCompare)(GenObject* obj1, GenObject* obj2, void* context), void* context = 0);
1457 private:
1458  ObjList* m_next;
1459  GenObject* m_obj;
1460  bool m_delete;
1461 };
1462 
1467 class YATE_API ObjVector : public GenObject
1468 {
1469  YNOCOPY(ObjVector); // no automatic copies please
1470 public:
1475  inline explicit ObjVector(bool autodelete = true)
1476  : m_length(0), m_objects(0), m_delete(autodelete)
1477  { }
1478 
1484  ObjVector(unsigned int maxLen, bool autodelete = true);
1485 
1493  ObjVector(ObjList& list, bool move = true, unsigned int maxLen = 0, bool autodelete = true);
1494 
1498  virtual ~ObjVector();
1499 
1505  virtual void* getObject(const String& name) const;
1506 
1511  inline unsigned int length() const
1512  { return m_length; }
1513 
1518  unsigned int count() const;
1519 
1524  bool null() const;
1525 
1531  inline GenObject* at(int index) const
1532  { return (index >= 0 && index < (int)m_length) ? m_objects[index] : 0; }
1533 
1539  inline GenObject* operator[](signed int index) const
1540  { return at(index); }
1541 
1547  inline GenObject* operator[](unsigned int index) const
1548  { return at(index); }
1549 
1557  unsigned int assign(ObjList& list, bool move = true, unsigned int maxLen = 0);
1558 
1564  GenObject* take(unsigned int index);
1565 
1572  bool set(GenObject* obj, unsigned int index);
1573 
1579  int index(const GenObject* obj) const;
1580 
1586  int index(const String& str) const;
1587 
1591  void clear();
1592 
1597  inline bool autoDelete()
1598  { return m_delete; }
1599 
1604  inline void setDelete(bool autodelete)
1605  { m_delete = autodelete; }
1606 
1607 private:
1608  unsigned int m_length;
1609  GenObject** m_objects;
1610  bool m_delete;
1611 };
1612 
1621 class YATE_API Array : public RefObject
1622 {
1623 public:
1629  explicit Array(int columns = 0, int rows = 0);
1630 
1634  virtual ~Array();
1635 
1641  virtual void* getObject(const String& name) const;
1642 
1649  bool addRow(ObjList* row = 0, int index = -1);
1650 
1657  bool addColumn(ObjList* column = 0, int index = -1);
1658 
1664  bool delRow(int index);
1665 
1671  bool delColumn(int index);
1672 
1679  GenObject* get(int column, int row) const;
1680 
1687  GenObject* take(int column, int row);
1688 
1696  bool set(GenObject* obj, int column, int row);
1697 
1702  inline int getRows() const
1703  { return m_rows; }
1704 
1709  inline int getColumns() const
1710  { return m_columns; }
1711 
1719  inline ObjList* getColumn(int column) const {
1720  if (column >= 0 || column < m_columns)
1721  return static_cast<ObjList*>(m_obj[column]);
1722  return 0;
1723  }
1724 
1725 private:
1726  int m_rows;
1727  int m_columns;
1728  ObjList m_obj;
1729 };
1730 
1731 class Regexp;
1732 class StringMatchPrivate;
1733 
1738 class YATE_API UChar
1739 {
1740 public:
1745  inline explicit UChar(uint32_t code = 0)
1746  : m_chr(code)
1747  { encode(); }
1748 
1753  inline explicit UChar(int32_t code)
1754  : m_chr((code < 0) ? 0 : code)
1755  { encode(); }
1756 
1761  inline explicit UChar(signed char code)
1762  : m_chr((unsigned char)code)
1763  { encode(); }
1764 
1769  inline explicit UChar(unsigned char code)
1770  : m_chr(code)
1771  { encode(); }
1772 
1778  inline UChar& operator=(uint32_t code)
1779  { m_chr = code; encode(); return *this; }
1780 
1786  inline UChar& operator=(char code)
1787  { m_chr = (unsigned char)code; encode(); return *this; }
1788 
1793  inline uint32_t code() const
1794  { return m_chr; }
1795 
1800  inline const char* c_str() const
1801  { return m_str; }
1802 
1807  inline operator const char*() const
1808  { return m_str; };
1809 
1817  bool decode(const char*& str, uint32_t maxChar = 0x10ffff, bool overlong = false);
1818 
1819 private:
1820  void encode();
1821  uint32_t m_chr;
1822  char m_str[8];
1823 };
1824 
1832 class YATE_API String : public GenObject
1833 {
1834 public:
1835  enum Align {
1836  Left = 0,
1837  Center,
1838  Right
1839  };
1840 
1844  String();
1845 
1851  String(const char* value, int len = -1);
1852 
1858  explicit String(char value, unsigned int repeat = 1);
1859 
1864  explicit String(int32_t value);
1865 
1870  explicit String(uint32_t value);
1871 
1876  explicit String(int64_t value);
1877 
1882  explicit String(uint64_t value);
1883 
1888  explicit String(bool value);
1889 
1894  explicit String(double value);
1895 
1900  String(const String& value);
1901 
1906  String(const String* value);
1907 
1911  virtual ~String();
1912 
1918  virtual void* getObject(const String& name) const;
1919 
1924  static const String& empty();
1925 
1931  inline static const char* boolText(bool value)
1932  { return value ? "true" : "false"; }
1933 
1938  inline const char* c_str() const
1939  { return m_string; }
1940 
1945  inline const char* safe() const
1946  { return m_string ? m_string : ""; }
1947 
1953  inline const char* safe(const char* defStr) const
1954  { return m_string ? m_string : (defStr ? defStr : ""); }
1955 
1960  inline unsigned int length() const
1961  { return m_length; }
1962 
1967  inline bool null() const
1968  { return !m_string; }
1969 
1977  static int lenUtf8(const char* value, uint32_t maxChar = 0x10ffff, bool overlong = false);
1978 
1985  inline int lenUtf8(uint32_t maxChar = 0x10ffff, bool overlong = false) const
1986  { return lenUtf8(m_string,maxChar,overlong); }
1987 
1988 
1996  int fixUtf8(const char* replace = 0, uint32_t maxChar = 0x10ffff, bool overlong = false);
1997 
2003  inline static bool checkBOM(const char* str)
2004  { return str && (str[0] == '\357') && (str[1] == '\273') && (str[2] == '\277'); }
2005 
2010  inline bool checkBOM() const
2011  { return checkBOM(c_str()); }
2012 
2018  inline static bool stripBOM(const char*& str)
2019  { return checkBOM(str) && (str += 3); }
2020 
2026  inline static bool stripBOM(char*& str)
2027  { return checkBOM(str) && (str += 3); }
2028 
2033  inline bool stripBOM()
2034  { return checkBOM(c_str()) && &(*this = c_str() + 3); }
2035 
2040  inline unsigned int hash() const
2041  {
2042  if (m_hash == YSTRING_INIT_HASH)
2043  m_hash = hash(m_string);
2044  return m_hash;
2045  }
2046 
2053  static unsigned int hash(const char* value, unsigned int h = 0);
2054 
2058  void clear();
2059 
2065  char at(int index) const;
2066 
2073  String substr(int offs, int len = -1) const;
2074 
2078  String& trimBlanks();
2079 
2084  String& trimSpaces();
2085 
2090  virtual const String& toString() const;
2091 
2102  int toInteger(int defvalue = 0, int base = 0, int minvalue = INT_MIN,
2103  int maxvalue = INT_MAX, bool clamp = true) const;
2104 
2112  int toInteger(const TokenDict* tokens, int defvalue = 0, int base = 0) const;
2113 
2124  long int toLong(long int defvalue = 0, int base = 0, long int minvalue = LONG_MIN,
2125  long int maxvalue = LONG_MAX, bool clamp = true) const;
2126 
2137  int64_t toInt64(int64_t defvalue = 0, int base = 0, int64_t minvalue = LLONG_MIN,
2138  int64_t maxvalue = LLONG_MAX, bool clamp = true) const;
2139 
2145  double toDouble(double defvalue = 0.0) const;
2146 
2152  bool toBoolean(bool defvalue = false) const;
2153 
2158  bool isBoolean() const;
2159 
2164  String& toUpper();
2165 
2170  String& toLower();
2171 
2177  inline char operator[](signed int index) const
2178  { return at(index); }
2179 
2185  inline char operator[](unsigned int index) const
2186  { return at(index); }
2187 
2192  inline operator const char*() const
2193  { return m_string; };
2194 
2201  String& assign(const char* value, int len = -1);
2202 
2209  String& assign(char value, unsigned int repeat = 1);
2210 
2219  String& hexify(void* data, unsigned int len, char sep = 0, bool upCase = false);
2220 
2225  inline String& operator=(const String& value)
2226  { return operator=(value.c_str()); }
2227 
2233  inline String& operator=(const String* value)
2234  { return operator=(value ? value->c_str() : ""); }
2235 
2241  String& operator=(const char* value);
2242 
2247  String& operator=(char value);
2248 
2253  String& operator=(int32_t value);
2254 
2259  String& operator=(uint32_t value);
2260 
2265  String& operator=(int64_t value);
2266 
2271  String& operator=(uint64_t value);
2272 
2277  inline String& operator=(bool value)
2278  { return operator=(boolText(value)); }
2279 
2284  String& operator=(double value);
2285 
2291  inline String& operator+=(const char* value)
2292  { return append(value,-1); }
2293 
2298  String& operator+=(char value);
2299 
2304  String& operator+=(int32_t value);
2305 
2310  String& operator+=(uint32_t value);
2311 
2316  String& operator+=(int64_t value);
2317 
2322  String& operator+=(uint64_t value);
2323 
2328  inline String& operator+=(bool value)
2329  { return operator+=(boolText(value)); }
2330 
2335  String& operator+=(double value);
2336 
2340  bool operator==(const char* value) const;
2341 
2345  bool operator!=(const char* value) const;
2346 
2350  inline bool operator==(const String& value) const
2351  { return (this == &value) || ((hash() == value.hash()) && operator==(value.c_str())); }
2352 
2356  inline bool operator!=(const String& value) const
2357  { return (this != &value) && ((hash() != value.hash()) || operator!=(value.c_str())); }
2358 
2362  bool operator&=(const char* value) const;
2363 
2367  bool operator|=(const char* value) const;
2368 
2372  inline String& operator<<(const char* value)
2373  { return operator+=(value); }
2374 
2378  inline String& operator<<(char value)
2379  { return operator+=(value); }
2380 
2384  inline String& operator<<(int32_t value)
2385  { return operator+=(value); }
2386 
2390  inline String& operator<<(uint32_t value)
2391  { return operator+=(value); }
2392 
2396  inline String& operator<<(int64_t value)
2397  { return operator+=(value); }
2398 
2402  inline String& operator<<(uint64_t value)
2403  { return operator+=(value); }
2404 
2408  inline String& operator<<(bool value)
2409  { return operator+=(value); }
2410 
2414  inline String& operator<<(double value)
2415  { return operator+=(value); }
2416 
2421  String& operator>>(const char* skip);
2422 
2426  String& operator>>(char& store);
2427 
2431  String& operator>>(UChar& store);
2432 
2436  String& operator>>(int& store);
2437 
2441  String& operator>>(unsigned int& store);
2442 
2446  String& operator>>(bool& store);
2447 
2454  String& append(const char* value, int len);
2455 
2462  String& append(const char* value, const char* separator = 0, bool force = false);
2463 
2470  String& append(const ObjList* list, const char* separator = 0, bool force = false);
2471 
2478  inline String& append(const ObjList& list, const char* separator = 0, bool force = false)
2479  { return append(&list,separator,force); }
2480 
2486  String& append(double value, unsigned int decimals = 3);
2487 
2493  String& printf(const char* format, ...) FORMAT_CHECK(2);
2494 
2500  String& printf(unsigned int length, const char* format, ...) FORMAT_CHECK(3);
2501 
2510  String& appendFixed(unsigned int fixedLength, const char* str, unsigned int len = -1, char fill = ' ', int align = Left);
2511 
2519  inline String& appendFixed(unsigned int fixedLength, const String& str, char fill = ' ', int align = Left)
2520  { return appendFixed(fixedLength,str.c_str(),str.length(),fill,align); }
2521 
2528  int find(char what, unsigned int offs = 0) const;
2529 
2536  int find(const char* what, unsigned int offs = 0) const;
2537 
2543  int rfind(char what) const;
2544 
2550  int rfind(const char* what) const;
2551 
2559  bool startsWith(const char* what, bool wordBreak = false, bool caseInsensitive = false) const;
2560 
2568  bool endsWith(const char* what, bool wordBreak = false, bool caseInsensitive = false) const;
2569 
2581  bool startSkip(const char* what, bool wordBreak = true, bool caseInsensitive = false);
2582 
2589  String& extractTo(const char* sep, String& store);
2590 
2597  String& extractTo(const char* sep, bool& store);
2598 
2606  String& extractTo(const char* sep, int& store, int base = 0);
2607 
2616  String& extractTo(const char* sep, int& store, const TokenDict* tokens, int base = 0);
2617 
2624  String& extractTo(const char* sep, double& store);
2625 
2631  virtual bool matches(const String& value) const
2632  { return operator==(value); }
2633 
2639  bool matches(const Regexp& rexp);
2640 
2646  int matchOffset(int index = 0) const;
2647 
2653  int matchLength(int index = 0) const;
2654 
2660  inline String matchString(int index = 0) const
2661  { return substr(matchOffset(index),matchLength(index)); }
2662 
2668  String replaceMatches(const String& templ) const;
2669 
2674  int matchCount() const;
2675 
2682  ObjList* split(char separator, bool emptyOK = true) const;
2683 
2690  static String msgEscape(const char* str, char extraEsc = 0);
2691 
2697  inline String msgEscape(char extraEsc = 0) const
2698  { return msgEscape(c_str(),extraEsc); }
2699 
2707  static String msgUnescape(const char* str, int* errptr = 0, char extraEsc = 0);
2708 
2715  inline String msgUnescape(int* errptr = 0, char extraEsc = 0) const
2716  { return msgUnescape(c_str(),errptr,extraEsc); }
2717 
2724  static String sqlEscape(const char* str, char extraEsc = 0);
2725 
2731  inline String sqlEscape(char extraEsc = 0) const
2732  { return sqlEscape(c_str(),extraEsc); }
2733 
2741  static String uriEscape(const char* str, char extraEsc = 0, const char* noEsc = 0);
2742 
2750  static String uriEscape(const char* str, const char* extraEsc, const char* noEsc = 0);
2751 
2758  inline String uriEscape(char extraEsc = 0, const char* noEsc = 0) const
2759  { return uriEscape(c_str(),extraEsc,noEsc); }
2760 
2767  static String uriUnescape(const char* str, int* errptr = 0);
2768 
2774  inline String uriUnescape(int* errptr = 0) const
2775  { return uriUnescape(c_str(),errptr); }
2776 
2783  static const String* atom(const String*& str, const char* val);
2784 
2785 protected:
2789  virtual void changed();
2790 
2791 private:
2792  void clearMatches();
2793  char* m_string;
2794  unsigned int m_length;
2795  // I hope every C++ compiler now knows about mutable...
2796  mutable unsigned int m_hash;
2797  StringMatchPrivate* m_matches;
2798 };
2799 
2805 inline const char* c_str(const String* str)
2806  { return str ? str->c_str() : (const char*)0; }
2807 
2813 inline const char* c_safe(const char* str)
2814  { return str ? str : ""; }
2815 
2821 inline const char* c_safe(const String* str)
2822  { return str ? str->safe() : ""; }
2823 
2829 inline bool null(const char* str)
2830  { return !(str && *str); }
2831 
2837 inline bool null(const String* str)
2838  { return !str || str->null(); }
2839 
2843 YATE_API String operator+(const String& s1, const String& s2);
2844 
2848 YATE_API String operator+(const String& s1, const char* s2);
2849 
2853 YATE_API String operator+(const char* s1, const String& s2);
2854 
2859 inline const char *strcpy(String& dest, const char* src)
2860  { dest = src; return dest.c_str(); }
2861 
2866 inline const char *strcat(String& dest, const char* src)
2867  { dest += src; return dest.c_str(); }
2868 
2877 YATE_API int lookup(const char* str, const TokenDict* tokens, int defvalue = 0, int base = 0);
2878 
2885 YATE_API const char* lookup(int value, const TokenDict* tokens, const char* defvalue = 0);
2886 
2887 class NamedList;
2888 
2896 YATE_API bool controlReturn(NamedList* params, bool ret, const char* retVal = 0);
2897 
2902 class YATE_API Regexp : public String
2903 {
2904  friend class String;
2905 public:
2909  Regexp();
2910 
2917  explicit Regexp(const char* value, bool extended = false, bool insensitive = false);
2918 
2923  Regexp(const Regexp& value);
2924 
2928  virtual ~Regexp();
2929 
2933  inline Regexp& operator=(const char* value)
2934  { String::operator=(value); return *this; }
2935 
2940  inline bool compile() const
2941  { return m_regexp || (m_compile && doCompile()); }
2942 
2948  bool matches(const char* value) const;
2949 
2955  virtual bool matches(const String& value) const
2956  { return Regexp::matches(value.safe()); }
2957 
2963  void setFlags(bool extended, bool insensitive);
2964 
2969  bool isExtended() const;
2970 
2975  bool isCaseInsensitive() const;
2976 
2977 protected:
2981  virtual void changed();
2982 
2987  bool doCompile() const;
2988 
2989 private:
2990  void cleanup();
2991  bool matches(const char* value, StringMatchPrivate* matchlist) const;
2992  mutable void* m_regexp;
2993  mutable bool m_compile;
2994  int m_flags;
2995 };
2996 
3001 class Atom
3002 {
3003 public:
3008  inline explicit Atom(const char* value)
3009  : m_atom(0)
3010  { String::atom(m_atom,value); }
3011 
3016  inline operator const String&() const
3017  { return *m_atom; }
3018 
3023  inline const String* operator->() const
3024  { return m_atom; }
3025 
3026 private:
3027  const String* m_atom;
3028 };
3029 
3034 class YATE_API CapturedEvent : public String
3035 {
3036  friend class Engine;
3038 public:
3044  inline CapturedEvent(int level, const char* text)
3045  : String(text), m_level(level)
3046  { }
3047 
3052  inline CapturedEvent(const CapturedEvent& original)
3053  : String(original), m_level(original.level())
3054  { }
3055 
3060  inline int level() const
3061  { return m_level; }
3062 
3063 
3068  inline static bool capturing()
3069  { return s_capturing; }
3070 
3075  inline static const ObjList& events()
3076  { return s_events; }
3077 
3083  inline static void append(int level, const char* text)
3084  { if (text && *text) s_events.append(new CapturedEvent(level,text)); }
3085 
3086 protected:
3091  inline static ObjList& eventsRw()
3092  { return s_events; }
3093 
3098  inline static void capturing(bool capture)
3099  { s_capturing = capture; }
3100 
3101 private:
3102  int m_level;
3103  static ObjList s_events;
3104  static bool s_capturing;
3105 };
3106 
3111 class YATE_API NamedString : public String
3112 {
3113  YNOCOPY(NamedString); // no automatic copies please
3114 public:
3120  explicit NamedString(const char* name, const char* value = 0);
3121 
3126  inline const String& name() const
3127  { return m_name; }
3128 
3133  virtual const String& toString() const;
3134 
3140  virtual void* getObject(const String& name) const;
3141 
3145  inline NamedString& operator=(const char* value)
3146  { String::operator=(value); return *this; }
3147 
3148 private:
3149  NamedString(); // no default constructor please
3150  String m_name;
3151 };
3152 
3159 class YATE_API NamedPointer : public NamedString
3160 {
3161 public:
3168  explicit NamedPointer(const char* name, GenObject* data = 0, const char* value = 0);
3169 
3173  virtual ~NamedPointer();
3174 
3179  inline GenObject* userData() const
3180  { return m_data; }
3181 
3187  GenObject* takeData();
3188 
3194  void userData(GenObject* data);
3195 
3201  inline void* userObject(const String& name) const
3202  { return m_data ? m_data->getObject(name) : 0; }
3203 
3207  inline NamedPointer& operator=(const char* value)
3208  { NamedString::operator=(value); return *this; }
3209 
3215  virtual void* getObject(const String& name) const;
3216 
3217 protected:
3221  virtual void changed();
3222 
3223 private:
3224  NamedPointer(); // no default constructor please
3225  GenObject* m_data;
3226 };
3227 
3232 class YATE_API NamedCounter : public String
3233 {
3234  YNOCOPY(NamedCounter); // no automatic copies please
3235 public:
3240  explicit NamedCounter(const String& name);
3241 
3246  inline bool enabled() const
3247  { return m_enabled; }
3248 
3253  inline void enable(bool val)
3254  { m_enabled = val; }
3255 
3260  int inc();
3261 
3266  int dec();
3267 
3272  inline int count() const
3273  { return m_count; }
3274 
3275 private:
3276  int m_count;
3277  bool m_enabled;
3278  Mutex* m_mutex;
3279 };
3280 
3288 class YATE_API HashList : public GenObject
3289 {
3290  YNOCOPY(HashList); // no automatic copies please
3291 public:
3296  explicit HashList(unsigned int size = 17);
3297 
3301  virtual ~HashList();
3302 
3308  virtual void* getObject(const String& name) const;
3309 
3314  inline unsigned int length() const
3315  { return m_size; }
3316 
3321  unsigned int count() const;
3322 
3329  inline ObjList* getList(unsigned int index) const
3330  { return (index < m_size) ? m_lists[index] : 0; }
3331 
3337  inline ObjList* getHashList(unsigned int hash) const
3338  { return getList(hash % m_size); }
3339 
3345  inline ObjList* getHashList(const String& str) const
3346  { return getHashList(str.hash()); }
3347 
3353  GenObject* operator[](const String& str) const;
3354 
3361  ObjList* find(const GenObject* obj) const;
3362 
3369  ObjList* find(const GenObject* obj, unsigned int hash) const;
3370 
3376  ObjList* find(const String& str) const;
3377 
3383  ObjList* append(const GenObject* obj);
3384 
3392  GenObject* remove(GenObject* obj, bool delobj = true, bool useHash = false);
3393 
3400  inline GenObject* remove(const String& str, bool delobj = true)
3401  {
3402  ObjList* n = find(str);
3403  return n ? n->remove(delobj) : 0;
3404  }
3405 
3409  void clear();
3410 
3417  bool resync(GenObject* obj);
3418 
3424  bool resync();
3425 
3426 private:
3427  unsigned int m_size;
3428  ObjList** m_lists;
3429 };
3430 
3437 class YATE_API ListIterator
3438 {
3439  YNOCOPY(ListIterator); // no automatic copies please
3440 public:
3447  ListIterator(ObjList& list, int offset = 0);
3448 
3455  ListIterator(HashList& list, int offset = 0);
3456 
3460  ~ListIterator();
3461 
3466  inline unsigned int length() const
3467  { return m_length; }
3468 
3472  void clear();
3473 
3479  void assign(ObjList& list, int offset = 0);
3480 
3486  void assign(HashList& list, int offset = 0);
3487 
3494  GenObject* get(unsigned int index) const;
3495 
3508  GenObject* get();
3509 
3514  inline bool eof() const
3515  { return m_current >= m_length; }
3516 
3520  inline void reset()
3521  { m_current = 0; }
3522 
3523 private:
3524  ObjList* m_objList;
3525  HashList* m_hashList;
3526  GenObject** m_objects;
3527  unsigned int* m_hashes;
3528  unsigned int m_length;
3529  unsigned int m_current;
3530 };
3531 
3536 class YATE_API Time
3537 {
3538 public:
3542  inline Time()
3543  : m_time(now())
3544  { }
3545 
3550  inline Time(u_int64_t usec)
3551  : m_time(usec)
3552  { }
3553 
3558  inline explicit Time(const struct timeval* tv)
3559  : m_time(fromTimeval(tv))
3560  { }
3561 
3566  inline explicit Time(const struct timeval& tv)
3567  : m_time(fromTimeval(tv))
3568  { }
3569 
3574  inline ~Time()
3575  { }
3576 
3581  inline u_int32_t sec() const
3582  { return (u_int32_t)((m_time+500000) / 1000000); }
3583 
3588  inline u_int64_t msec() const
3589  { return (m_time+500) / 1000; }
3590 
3595  inline u_int64_t usec() const
3596  { return m_time; }
3597 
3601  inline operator u_int64_t() const
3602  { return m_time; }
3603 
3607  inline Time& operator=(u_int64_t usec)
3608  { m_time = usec; return *this; }
3609 
3613  inline Time& operator+=(int64_t delta)
3614  { m_time += delta; return *this; }
3615 
3619  inline Time& operator-=(int64_t delta)
3620  { m_time -= delta; return *this; }
3621 
3626  inline void toTimeval(struct timeval* tv) const
3627  { toTimeval(tv, m_time); }
3628 
3634  static void toTimeval(struct timeval* tv, u_int64_t usec);
3635 
3641  static u_int64_t fromTimeval(const struct timeval* tv);
3642 
3648  inline static u_int64_t fromTimeval(const struct timeval& tv)
3649  { return fromTimeval(&tv); }
3650 
3655  static u_int64_t now();
3656 
3661  static u_int64_t msecNow();
3662 
3667  static u_int32_t secNow();
3668 
3682  static unsigned int toEpoch(int year, unsigned int month, unsigned int day,
3683  unsigned int hour, unsigned int minute, unsigned int sec, int offset = 0);
3684 
3697  static bool toDateTime(unsigned int epochTimeSec, int& year, unsigned int& month,
3698  unsigned int& day, unsigned int& hour, unsigned int& minute, unsigned int& sec,
3699  unsigned int* wDay = 0);
3700 
3706  static inline bool isLeap(unsigned int year)
3707  { return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)); }
3708 
3713  static int timeZone();
3714 
3715 private:
3716  u_int64_t m_time;
3717 };
3718 
3723 class YATE_API Random
3724 {
3725 public:
3730  inline Random(u_int32_t seed = Time::now() & 0xffffffff)
3731  : m_random(seed)
3732  { }
3733 
3738  inline u_int32_t get() const
3739  { return m_random; }
3740 
3745  inline void set(u_int32_t seed)
3746  { m_random = seed; }
3747 
3752  u_int32_t next();
3753 
3758  static long int random();
3759 
3764  static void srandom(unsigned int seed);
3765 
3766 private:
3767  u_int32_t m_random;
3768 };
3769 
3774 class YATE_API DataBlock : public GenObject
3775 {
3776 public:
3777 
3782  DataBlock(unsigned int overAlloc = 0);
3783 
3788  DataBlock(const DataBlock& value);
3789 
3795  DataBlock(const DataBlock& value, unsigned int overAlloc);
3796 
3804  DataBlock(void* value, unsigned int len, bool copyData = true, unsigned int overAlloc = 0);
3805 
3809  virtual ~DataBlock();
3810 
3816  virtual void* getObject(const String& name) const;
3817 
3821  static const DataBlock& empty();
3822 
3827  inline void* data() const
3828  { return m_data; }
3829 
3836  inline unsigned char* data(unsigned int offs, unsigned int len = 1) const
3837  { return (offs + len <= m_length) ? (static_cast<unsigned char*>(m_data) + offs) : 0; }
3838 
3845  inline int at(unsigned int offs, int defvalue = -1) const
3846  { return (offs < m_length) ? static_cast<unsigned char*>(m_data)[offs] : defvalue; }
3847 
3852  inline bool null() const
3853  { return !m_data; }
3854 
3859  inline unsigned int length() const
3860  { return m_length; }
3861 
3866  inline unsigned int overAlloc() const
3867  { return m_overAlloc; }
3868 
3873  inline void overAlloc(unsigned int bytes)
3874  { m_overAlloc = bytes; }
3875 
3880  void clear(bool deleteData = true);
3881 
3889  DataBlock& assign(void* value, unsigned int len, bool copyData = true, unsigned int allocated = 0);
3890 
3896  inline void append(void* value, unsigned int len) {
3897  DataBlock tmp(value,len,false);
3898  append(tmp);
3899  tmp.clear(false);
3900  }
3901 
3906  void append(const DataBlock& value);
3907 
3912  void append(const String& value);
3913 
3918  void insert(const DataBlock& value);
3919 
3924  inline void resize(unsigned int len) {
3925  if (len != length())
3926  assign(0,len);
3927  }
3928 
3933  void truncate(unsigned int len);
3934 
3939  void cut(int len);
3940 
3946  inline int operator[](signed int index) const
3947  { return at(index); }
3948 
3954  inline int operator[](unsigned int index) const
3955  { return at(index); }
3956 
3960  DataBlock& operator=(const DataBlock& value);
3961 
3965  inline DataBlock& operator+=(const DataBlock& value)
3966  { append(value); return *this; }
3967 
3971  inline DataBlock& operator+=(const String& value)
3972  { append(value); return *this; }
3973 
3982  bool convert(const DataBlock& src, const String& sFormat,
3983  const String& dFormat, unsigned maxlen = 0);
3984 
3995  bool unHexify(const char* data, unsigned int len, char sep);
3996 
4006  bool unHexify(const char* data, unsigned int len);
4007 
4014  inline bool unHexify(const String& data)
4015  { return unHexify(data.c_str(),data.length()); }
4016 
4022  String sqlEscape(char extraEsc) const;
4023 
4024 private:
4025  unsigned int allocLen(unsigned int len) const;
4026  void* m_data;
4027  unsigned int m_length;
4028  unsigned int m_allocated;
4029  unsigned int m_overAlloc;
4030 };
4031 
4036 class YATE_API Hasher
4037 {
4038 public:
4042  virtual ~Hasher();
4043 
4047  virtual void clear() = 0;
4048 
4053  virtual void finalize() = 0;
4054 
4060  virtual const unsigned char* rawDigest() = 0;
4061 
4067  inline const String& hexDigest()
4068  { finalize(); return m_hex; }
4069 
4076  inline bool update(const void* buf, unsigned int len)
4077  { return updateInternal(buf,len); }
4078 
4084  inline bool update(const DataBlock& data)
4085  { return updateInternal(data.data(), data.length()); }
4086 
4092  inline bool update(const String& str)
4093  { return updateInternal(str.c_str(), str.length()); }
4094 
4099  inline Hasher& operator<<(const String& value)
4100  { update(value); return *this; }
4101 
4106  inline Hasher& operator<<(const DataBlock& data)
4107  { update(data); return *this; }
4108 
4113  Hasher& operator<<(const char* value);
4114 
4122  bool hmacStart(DataBlock& opad, const void* key, unsigned int keyLen);
4123 
4130  inline bool hmacStart(DataBlock& opad, const DataBlock& key)
4131  { return hmacStart(opad,key.data(),key.length()); }
4132 
4139  inline bool hmacStart(DataBlock& opad, const String& key)
4140  { return hmacStart(opad,key.c_str(),key.length()); }
4141 
4147  bool hmacFinal(const DataBlock& opad);
4148 
4157  bool hmac(const void* key, unsigned int keyLen, const void* msg, unsigned int msgLen);
4158 
4165  inline bool hmac(const DataBlock& key, const DataBlock& msg)
4166  { return hmac(key.data(),key.length(),msg.data(),msg.length()); }
4167 
4174  inline bool hmac(const String& key, const String& msg)
4175  { return hmac(key.c_str(),key.length(),msg.c_str(),msg.length()); }
4176 
4181  virtual unsigned int hashLength() const = 0;
4182 
4187  virtual unsigned int hmacBlockSize() const;
4188 
4189 protected:
4193  inline Hasher()
4194  : m_private(0)
4195  { }
4196 
4203  virtual bool updateInternal(const void* buf, unsigned int len) = 0;
4204 
4205  void* m_private;
4206  String m_hex;
4207 };
4208 
4213 class YATE_API MD5 : public Hasher
4214 {
4215 public:
4219  MD5();
4220 
4225  MD5(const MD5& original);
4226 
4232  MD5(const void* buf, unsigned int len);
4233 
4238  MD5(const DataBlock& data);
4239 
4244  MD5(const String& str);
4245 
4249  MD5& operator=(const MD5& original);
4250 
4254  virtual ~MD5();
4255 
4259  virtual void clear();
4260 
4265  virtual void finalize();
4266 
4272  virtual const unsigned char* rawDigest();
4273 
4278  inline static unsigned int rawLength()
4279  { return 16; }
4280 
4285  virtual unsigned int hashLength() const
4286  { return 16; }
4287 
4288 protected:
4289  bool updateInternal(const void* buf, unsigned int len);
4290 
4291 private:
4292  void init();
4293  unsigned char m_bin[16];
4294 };
4295 
4300 class YATE_API SHA1 : public Hasher
4301 {
4302 public:
4306  SHA1();
4307 
4312  SHA1(const SHA1& original);
4313 
4319  SHA1(const void* buf, unsigned int len);
4320 
4325  SHA1(const DataBlock& data);
4326 
4331  SHA1(const String& str);
4332 
4336  SHA1& operator=(const SHA1& original);
4337 
4341  virtual ~SHA1();
4342 
4346  virtual void clear();
4347 
4352  virtual void finalize();
4353 
4359  virtual const unsigned char* rawDigest();
4360 
4365  inline static unsigned int rawLength()
4366  { return 20; }
4367 
4372  virtual unsigned int hashLength() const
4373  { return 20; }
4374 
4383  static bool fips186prf(DataBlock& out, const DataBlock& seed, unsigned int len);
4384 
4385 protected:
4386  bool updateInternal(const void* buf, unsigned int len);
4387 
4388 private:
4389  void init();
4390  unsigned char m_bin[20];
4391 };
4392 
4397 class YATE_API SHA256 : public Hasher
4398 {
4399 public:
4403  SHA256();
4404 
4409  SHA256(const SHA256& original);
4410 
4416  SHA256(const void* buf, unsigned int len);
4417 
4422  SHA256(const DataBlock& data);
4423 
4428  SHA256(const String& str);
4429 
4433  SHA256& operator=(const SHA256& original);
4434 
4438  virtual ~SHA256();
4439 
4443  virtual void clear();
4444 
4449  virtual void finalize();
4450 
4456  virtual const unsigned char* rawDigest();
4457 
4462  inline static unsigned int rawLength()
4463  { return 32; }
4464 
4469  virtual unsigned int hashLength() const
4470  { return 32; }
4471 
4472 protected:
4473  bool updateInternal(const void* buf, unsigned int len);
4474 
4475 private:
4476  void init();
4477  unsigned char m_bin[32];
4478 };
4479 
4484 class YATE_API Base64 : public DataBlock
4485 {
4486  YNOCOPY(Base64); // no automatic copies please
4487 public:
4491  inline Base64()
4492  { }
4493 
4500  inline Base64(void* src, unsigned int len, bool copyData = true)
4501  : DataBlock(src,len,copyData)
4502  { }
4503 
4513  void encode(String& dest, unsigned int lineLen = 0, bool lineAtEnd = false);
4514 
4526  bool decode(DataBlock& dest, bool liberal = true);
4527 
4531  inline Base64& operator<<(const String& value)
4532  { append(value); return *this; }
4533 
4537  inline Base64& operator<<(const DataBlock& data)
4538  { append(data); return *this; }
4539 
4543  inline Base64& operator<<(const char* value)
4544  { return operator<<(String(value)); }
4545 };
4546 
4547 class NamedIterator;
4548 
4553 class YATE_API NamedList : public String
4554 {
4555  friend class NamedIterator;
4556 public:
4561  explicit NamedList(const char* name);
4562 
4567  NamedList(const NamedList& original);
4568 
4575  NamedList(const char* name, const NamedList& original, const String& prefix);
4576 
4582  NamedList& operator=(const NamedList& value);
4583 
4589  virtual void* getObject(const String& name) const;
4590 
4595  inline unsigned int length() const
4596  { return m_params.length(); }
4597 
4602  inline unsigned int count() const
4603  { return m_params.count(); }
4604 
4608  inline void clearParams()
4609  { m_params.clear(); }
4610 
4616  NamedList& addParam(NamedString* param);
4617 
4625  NamedList& addParam(const char* name, const char* value, bool emptyOK = true);
4626 
4633  {
4634  if (param)
4635  m_params.setUnique(param);
4636  return *this;
4637  }
4638 
4645  NamedList& setParam(const String& name, const char* value);
4646 
4653  NamedList& clearParam(const String& name, char childSep = 0);
4654 
4661  NamedList& clearParam(NamedString* param, bool delParam = true);
4662 
4670  NamedList& copyParam(const NamedList& original, const String& name, char childSep = 0);
4671 
4677  NamedList& copyParams(const NamedList& original);
4678 
4686  NamedList& copyParams(const NamedList& original, ObjList* list, char childSep = 0);
4687 
4695  NamedList& copyParams(const NamedList& original, const String& list, char childSep = 0);
4696 
4705  NamedList& copySubParams(const NamedList& original, const String& prefix,
4706  bool skipPrefix = true, bool replace = false);
4707 
4713  bool hasSubParams(const char* prefix) const;
4714 
4720  int getIndex(const NamedString* param) const;
4721 
4727  int getIndex(const String& name) const;
4728 
4734  NamedString* getParam(const String& name) const;
4735 
4741  NamedString* getParam(unsigned int index) const;
4742 
4748  const String& operator[](const String& name) const;
4749 
4756  const char* getValue(const String& name, const char* defvalue = 0) const;
4757 
4768  int getIntValue(const String& name, int defvalue = 0, int minvalue = INT_MIN,
4769  int maxvalue = INT_MAX, bool clamp = true) const;
4770 
4778  int getIntValue(const String& name, const TokenDict* tokens, int defvalue = 0) const;
4779 
4790  int64_t getInt64Value(const String& name, int64_t defvalue = 0, int64_t minvalue = LLONG_MIN,
4791  int64_t maxvalue = LLONG_MAX, bool clamp = true) const;
4792 
4799  double getDoubleValue(const String& name, double defvalue = 0.0) const;
4800 
4807  bool getBoolValue(const String& name, bool defvalue = false) const;
4808 
4816  int replaceParams(String& str, bool sqlEsc = false, char extraEsc = 0) const;
4817 
4826  void dump(String& str, const char* separator, char quote = 0, bool force = false) const;
4827 
4832  static const NamedList& empty();
4833 
4838  inline ObjList* paramList()
4839  { return &m_params; }
4840 
4845  inline const ObjList* paramList() const
4846  { return &m_params; }
4847 
4848 private:
4849  NamedList(); // no default constructor please
4850  ObjList m_params;
4851 };
4852 
4858 class YATE_API NamedIterator
4859 {
4860 public:
4865  inline NamedIterator(const NamedList& list)
4866  : m_list(&list), m_item(list.m_params.skipNull())
4867  { }
4868 
4873  inline NamedIterator(const NamedIterator& original)
4874  : m_list(original.m_list), m_item(original.m_item)
4875  { }
4876 
4881  inline NamedIterator& operator=(const NamedList& list)
4882  { m_list = &list; m_item = list.m_params.skipNull(); return *this; }
4883 
4888  inline NamedIterator& operator=(const NamedIterator& original)
4889  { m_list = original.m_list; m_item = original.m_item; return *this; }
4890 
4895  const NamedString* get();
4896 
4900  inline bool eof() const
4901  { return !m_item; }
4902 
4906  inline void reset()
4907  { m_item = m_list->m_params.skipNull(); }
4908 
4909 private:
4910  NamedIterator(); // no default constructor please
4911  const NamedList* m_list;
4912  const ObjList* m_item;
4913 };
4914 
4920 class YATE_API URI : public String
4921 {
4922 public:
4926  URI();
4927 
4932  URI(const URI& uri);
4933 
4938  explicit URI(const String& uri);
4939 
4944  explicit URI(const char* uri);
4945 
4954  URI(const char* proto, const char* user, const char* host, int port = 0, const char* desc = 0);
4955 
4959  void parse() const;
4960 
4965  inline URI& operator=(const URI& value)
4966  { String::operator=(value); return *this; }
4967 
4972  inline URI& operator=(const String& value)
4973  { String::operator=(value); return *this; }
4974 
4979  inline URI& operator=(const char* value)
4980  { String::operator=(value); return *this; }
4981 
4986  inline const String& getDescription() const
4987  { parse(); return m_desc; }
4988 
4993  inline const String& getProtocol() const
4994  { parse(); return m_proto; }
4995 
5000  inline const String& getUser() const
5001  { parse(); return m_user; }
5002 
5007  inline const String& getHost() const
5008  { parse(); return m_host; }
5009 
5014  inline int getPort() const
5015  { parse(); return m_port; }
5016 
5021  inline const String& getExtra() const
5022  { parse(); return m_extra; }
5023 
5024 protected:
5030  virtual void changed();
5031  mutable bool m_parsed;
5032  mutable String m_desc;
5033  mutable String m_proto;
5034  mutable String m_user;
5035  mutable String m_host;
5036  mutable String m_extra;
5037  mutable int m_port;
5038 };
5039 
5040 class MutexPrivate;
5041 class SemaphorePrivate;
5042 class ThreadPrivate;
5043 
5048 class YATE_API Lockable
5049 {
5050 public:
5054  virtual ~Lockable();
5055 
5061  virtual bool lock(long maxwait = -1) = 0;
5062 
5067  virtual bool unlock() = 0;
5068 
5074  virtual bool locked() const = 0;
5075 
5081  virtual bool check(long maxwait = -1);
5082 
5089  virtual bool unlockAll();
5090 
5096  static void wait(unsigned long maxwait);
5097 
5102  static unsigned long wait();
5103 
5110  static void startUsingNow();
5111 
5118  static void enableSafety(bool safe = true);
5119 
5124  static bool safety();
5125 };
5126 
5131 class YATE_API Mutex : public Lockable
5132 {
5133  friend class MutexPrivate;
5134 public:
5141  explicit Mutex(bool recursive = false, const char* name = 0);
5142 
5147  Mutex(const Mutex& original);
5148 
5152  ~Mutex();
5153 
5158  Mutex& operator=(const Mutex& original);
5159 
5165  virtual bool lock(long maxwait = -1);
5166 
5171  virtual bool unlock();
5172 
5178  virtual bool locked() const;
5179 
5184  const char* owner() const;
5185 
5190  bool recursive() const;
5191 
5196  static int count();
5197 
5202  static int locks();
5203 
5208  static bool efficientTimedLock();
5209 
5210 private:
5211  MutexPrivate* privDataCopy() const;
5212  MutexPrivate* m_private;
5213 };
5214 
5221 class YATE_API MutexPool
5222 {
5223 public:
5234  MutexPool(unsigned int len = 13, bool recursive = false, const char* name = 0);
5235 
5239  ~MutexPool();
5240 
5248  inline unsigned int index(void* ptr) const
5249  { return ((unsigned int)(unsigned long)ptr) % m_length; }
5250 
5258  inline Mutex* mutex(void* ptr) const
5259  { return m_data[index(ptr)]; }
5260 
5266  inline Mutex* mutex(unsigned int idx) const
5267  { return m_data[idx % m_length]; }
5268 
5269 private:
5270  String* m_name; // Mutex names
5271  Mutex** m_data; // The array
5272  unsigned int m_length; // Array length
5273 };
5274 
5279 class YATE_API Semaphore : public Lockable
5280 {
5281  friend class SemaphorePrivate;
5282 public:
5289  explicit Semaphore(unsigned int maxcount = 1, const char* name = 0,
5290  unsigned int initialCount = 1);
5291 
5296  Semaphore(const Semaphore& original);
5297 
5301  ~Semaphore();
5302 
5307  Semaphore& operator=(const Semaphore& original);
5308 
5314  virtual bool lock(long maxwait = -1);
5315 
5320  virtual bool unlock();
5321 
5327  virtual bool locked() const;
5328 
5333  static int count();
5334 
5339  static int locks();
5340 
5345  static bool efficientTimedLock();
5346 
5347 private:
5348  SemaphorePrivate* privDataCopy() const;
5349  SemaphorePrivate* m_private;
5350 };
5351 
5357 class YATE_API Lock
5358 {
5359  YNOCOPY(Lock); // no automatic copies please
5360 public:
5366  inline Lock(Lockable& lck, long maxwait = -1)
5367  { m_lock = lck.lock(maxwait) ? &lck : 0; }
5368 
5374  inline Lock(Lockable* lck, long maxwait = -1)
5375  { m_lock = (lck && lck->lock(maxwait)) ? lck : 0; }
5376 
5380  inline ~Lock()
5381  { if (m_lock) m_lock->unlock(); }
5382 
5387  inline Lockable* locked() const
5388  { return m_lock; }
5389 
5393  inline void drop()
5394  { if (m_lock) m_lock->unlock(); m_lock = 0; }
5395 
5402  inline bool acquire(Lockable* lck, long maxwait = -1)
5403  { return (lck && (lck == m_lock)) ||
5404  (drop(),(lck && (m_lock = lck->lock(maxwait) ? lck : 0))); }
5405 
5412  inline bool acquire(Lockable& lck, long maxwait = -1)
5413  { return acquire(&lck,maxwait); }
5414 
5415 private:
5416  Lockable* m_lock;
5417 
5419  inline void* operator new(size_t);
5420 
5422  inline void* operator new[](size_t);
5423 };
5424 
5431 class YATE_API Lock2
5432 {
5433  YNOCOPY(Lock2); // no automatic copies please
5434 public:
5441  inline Lock2(Mutex* mx1, Mutex* mx2, long maxwait = -1)
5442  : m_mx1(0), m_mx2(0)
5443  { lock(mx1,mx2,maxwait); }
5444 
5451  inline Lock2(Mutex& mx1, Mutex& mx2, long maxwait = -1)
5452  : m_mx1(0), m_mx2(0)
5453  { lock(&mx1,&mx2,maxwait); }
5454 
5458  inline ~Lock2()
5459  { drop(); }
5460 
5465  inline bool locked() const
5466  { return m_mx1 != 0; }
5467 
5475  bool lock(Mutex* mx1, Mutex* mx2, long maxwait = -1);
5476 
5484  inline bool lock(Mutex& mx1, Mutex& mx2, long maxwait = -1)
5485  { return lock(&mx1,&mx2,maxwait); }
5486 
5490  void drop();
5491 
5492 private:
5493  Mutex* m_mx1;
5494  Mutex* m_mx2;
5495 
5497  inline void* operator new(size_t);
5498 
5500  inline void* operator new[](size_t);
5501 };
5502 
5508 class YATE_API Runnable
5509 {
5510 public:
5515  virtual void run() = 0;
5516 
5520  virtual ~Runnable();
5521 };
5522 
5529 class YATE_API Thread : public Runnable
5530 {
5531  friend class ThreadPrivate;
5532  friend class MutexPrivate;
5533  friend class SemaphorePrivate;
5534  YNOCOPY(Thread); // no automatic copies please
5535 public:
5539  enum Priority {
5540  Lowest,
5541  Low,
5542  Normal,
5543  High,
5544  Highest
5545  };
5546 
5550  virtual void cleanup();
5551 
5556  bool startup();
5557 
5562  bool error() const;
5563 
5568  bool running() const;
5569 
5574  inline int locks() const
5575  { return m_locks; }
5576 
5581  inline bool locked() const
5582  { return m_locking || m_locks; }
5583 
5588  const char* name() const;
5589 
5594  static const char* currentName();
5595 
5601  static void yield(bool exitCheck = false);
5602 
5608  static void idle(bool exitCheck = false);
5609 
5615  static void sleep(unsigned int sec, bool exitCheck = false);
5616 
5622  static void msleep(unsigned long msec, bool exitCheck = false);
5623 
5630  static void usleep(unsigned long usec, bool exitCheck = false);
5631 
5636  static unsigned long idleUsec();
5637 
5642  static unsigned long idleMsec();
5643 
5648  static void idleMsec(unsigned long msec);
5649 
5655  static Thread* current();
5656 
5661  static int count();
5662 
5668  static bool check(bool exitNow = true);
5669 
5673  static void exit();
5674 
5679  void cancel(bool hard = false);
5680 
5685  inline bool isCurrent() const
5686  { return current() == this; }
5687 
5692  NamedCounter* getObjCounter() const;
5693 
5699  NamedCounter* setObjCounter(NamedCounter* counter);
5700 
5706  static NamedCounter* getCurrentObjCounter(bool always = false);
5707 
5713  static NamedCounter* setCurrentObjCounter(NamedCounter* counter);
5714 
5721  static Priority priority(const char* name, Priority defvalue = Normal);
5722 
5728  static const char* priority(Priority prio);
5729 
5734  static void killall();
5735 
5740  static void preExec();
5741 
5747  static int lastError();
5748 
5755  static inline bool errorString(String& buffer)
5756  { return errorString(buffer,lastError()); }
5757 
5768  static bool errorString(String& buffer, int code);
5769 
5770 protected:
5776  Thread(const char *name = 0, Priority prio = Normal);
5777 
5783  Thread(const char *name, const char* prio);
5784 
5788  virtual ~Thread();
5789 
5790 private:
5791  ThreadPrivate* m_private;
5792  int m_locks;
5793  bool m_locking;
5794 };
5795 
5800 class YATE_API TempObjectCounter
5801 {
5802  YNOCOPY(TempObjectCounter); // no automatic copies please
5803 public:
5810  : m_saved(0), m_enabled(enable)
5811  { if (m_enabled) m_saved = Thread::setCurrentObjCounter(counter); }
5812 
5818  inline TempObjectCounter(const GenObject* obj, bool enable = GenObject::getObjCounting())
5819  : m_saved(0), m_enabled(enable && obj)
5820  { if (m_enabled) m_saved = Thread::setCurrentObjCounter(obj->getObjCounter()); }
5821 
5827  inline TempObjectCounter(const GenObject& obj, bool enable = GenObject::getObjCounting())
5828  : m_saved(0), m_enabled(enable)
5829  { if (m_enabled) m_saved = Thread::setCurrentObjCounter(obj.getObjCounter()); }
5830 
5835  { if (m_enabled) Thread::setCurrentObjCounter(m_saved); }
5836 
5837 private:
5838  NamedCounter* m_saved;
5839  bool m_enabled;
5840 };
5841 
5842 class Socket;
5843 
5848 class YATE_API SocketAddr : public GenObject
5849 {
5851 public:
5855  enum Family {
5856  Unknown = AF_UNSPEC,
5857  IPv4 = AF_INET,
5858  AfMax = AF_MAX,
5859  AfUnsupported = AfMax,
5860 #ifdef AF_INET6
5861  IPv6 = AF_INET6,
5862 #else
5863  IPv6 = AfUnsupported + 1,
5864 #endif
5865 #ifdef HAS_AF_UNIX
5866  Unix = AF_UNIX,
5867 #else
5868  Unix = AfUnsupported + 2,
5869 #endif
5870  };
5871 
5875  inline SocketAddr()
5876  : m_address(0), m_length(0)
5877  { }
5878 
5883  inline SocketAddr(const SocketAddr& value)
5884  : GenObject(),
5885  m_address(0), m_length(0)
5886  { assign(value.address(),value.length()); }
5887 
5893  explicit SocketAddr(int family, const void* raw = 0);
5894 
5900  SocketAddr(const struct sockaddr* addr, socklen_t len = 0);
5901 
5905  virtual ~SocketAddr();
5906 
5911  inline SocketAddr& operator=(const SocketAddr& value)
5912  { assign(value.address(),value.length()); return *this; }
5913 
5919  bool operator==(const SocketAddr& other) const;
5920 
5926  inline bool operator!=(const SocketAddr& other) const
5927  { return !operator==(other); }
5928 
5932  void clear();
5933 
5939  bool assign(int family);
5940 
5946  void assign(const struct sockaddr* addr, socklen_t len = 0);
5947 
5953  bool assign(const DataBlock& addr);
5954 
5960  bool local(const SocketAddr& remote);
5961 
5966  inline bool valid() const
5967  { return m_length && m_address; }
5968 
5973  inline bool null() const
5974  { return !(m_length && m_address); }
5975 
5980  inline int family() const
5981  { return m_address ? m_address->sa_family : 0; }
5982 
5987  inline const char* familyName()
5988  { return lookupFamily(family()); }
5989 
5994  inline unsigned int scopeId() const
5995  { return scopeId(address()); }
5996 
6002  inline bool scopeId(unsigned int val)
6003  { return scopeId(address(),val); }
6004 
6009  inline const String& host() const
6010  { return m_host; }
6011 
6016  inline const String& addr() const {
6017  if (!m_addr)
6018  updateAddr();
6019  return m_addr;
6020  }
6021 
6028  virtual bool host(const String& name);
6029 
6034  int port() const;
6035 
6041  bool port(int newport);
6042 
6047  inline struct sockaddr* address() const
6048  { return m_address; }
6049 
6054  inline socklen_t length() const
6055  { return m_length; }
6056 
6061  inline bool isNullAddr() const
6062  { return isNullAddr(m_host,family()); }
6063 
6069  int copyAddr(DataBlock& addr) const;
6070 
6076  static bool supports(int family);
6077 
6083  static int family(const String& addr);
6084 
6091  static bool stringify(String& buf, struct sockaddr* addr);
6092 
6101  static inline int unStringify(uint8_t* buf, const String& host,
6102  int family = Unknown) {
6103  SocketAddr sa(family);
6104  return sa.host(host) ? copyAddr(buf,sa.address()) : Unknown;
6105  }
6106 
6114  static int copyAddr(uint8_t* buf, struct sockaddr* addr);
6115 
6121  static inline unsigned int scopeId(struct sockaddr* addr) {
6122 #ifdef AF_INET6
6123  if (addr && addr->sa_family == AF_INET6)
6124  return ((struct sockaddr_in6*)addr)->sin6_scope_id;
6125 #endif
6126  return 0;
6127  }
6128 
6135  static inline bool scopeId(struct sockaddr* addr, unsigned int val) {
6136 #ifdef AF_INET6
6137  if (addr && addr->sa_family == AF_INET6) {
6138  ((struct sockaddr_in6*)addr)->sin6_scope_id = val;
6139  return true;
6140  }
6141 #endif
6142  return false;
6143  }
6144 
6152  static String& appendAddr(String& buf, const String& addr, int family = Unknown);
6153 
6162  static inline String& appendTo(String& buf, const String& addr, int port,
6163  int family = Unknown) {
6164  appendAddr(buf,addr,family) << ":" << port;
6165  return buf;
6166  }
6167 
6175  static inline String appendTo(const String& addr, int port, int family = Unknown) {
6176  String buf;
6177  appendTo(buf,addr,port,family);
6178  return buf;
6179  }
6180 
6187  static bool isNullAddr(const String& addr, int family = Unknown);
6188 
6197  static void splitIface(const String& buf, String& addr, String* iface = 0);
6198 
6210  static void split(const String& buf, String& addr, int& port, bool portPresent = false);
6211 
6217  static inline const char* lookupFamily(int family)
6218  { return lookup(family,s_familyName); }
6219 
6224  static const String& ipv4NullAddr();
6225 
6230  static const String& ipv6NullAddr();
6231 
6236  static const TokenDict* dictFamilyName();
6237 
6238 protected:
6242  virtual void stringify();
6243 
6247  virtual void updateAddr() const;
6248 
6249  struct sockaddr* m_address;
6250  socklen_t m_length;
6251  String m_host;
6252  mutable String m_addr;
6253 
6254 private:
6255  static const TokenDict s_familyName[];
6256 };
6257 
6262 class YATE_API SocketFilter : public GenObject
6263 {
6264  friend class Socket;
6265  YNOCOPY(SocketFilter); // no automatic copies please
6266 public:
6270  SocketFilter();
6271 
6275  virtual ~SocketFilter();
6276 
6282  virtual void* getObject(const String& name) const;
6283 
6288  virtual void timerTick(const Time& when);
6289 
6299  virtual bool received(void* buffer, int length, int flags, const struct sockaddr* addr, socklen_t adrlen) = 0;
6300 
6305  inline Socket* socket() const
6306  { return m_socket; }
6307 
6312  bool valid() const;
6313 
6314 private:
6315  Socket* m_socket;
6316 };
6317 
6322 class YATE_API Stream
6323 {
6324 public:
6328  enum SeekPos {
6329  SeekBegin, // Seek from start of stream
6330  SeekEnd, // Seek from stream end
6331  SeekCurrent // Seek from current position
6332  };
6333 
6337  virtual ~Stream();
6338 
6343  inline int error() const
6344  { return m_error; }
6345 
6350  virtual bool terminate() = 0;
6351 
6356  virtual bool canRetry() const;
6357 
6362  virtual bool inProgress() const;
6363 
6368  virtual bool valid() const = 0;
6369 
6375  virtual bool setBlocking(bool block = true);
6376 
6383  virtual int writeData(const void* buffer, int length) = 0;
6384 
6390  int writeData(const char* str);
6391 
6397  inline int writeData(const String& str)
6398  { return writeData(str.c_str(), str.length()); }
6399 
6405  inline int writeData(const DataBlock& buf)
6406  { return writeData(buf.data(), buf.length()); }
6407 
6414  virtual int readData(void* buffer, int length) = 0;
6415 
6420  virtual int64_t length();
6421 
6428  virtual int64_t seek(SeekPos pos, int64_t offset = 0);
6429 
6435  inline int64_t seek(int64_t offset)
6436  { return seek(SeekBegin,offset); }
6437 
6444  static bool allocPipe(Stream*& reader, Stream*& writer);
6445 
6452  static bool allocPair(Stream*& str1, Stream*& str2);
6453 
6458  static bool supportsPipes();
6459 
6464  static bool supportsPairs();
6465 
6466 protected:
6470  inline Stream()
6471  : m_error(0)
6472  { }
6473 
6477  inline void clearError()
6478  { m_error = 0; }
6479 
6480  int m_error;
6481 };
6482 
6487 class YATE_API MemoryStream : public Stream
6488 {
6489  YNOCOPY(MemoryStream); // no automatic copies please
6490 public:
6494  inline MemoryStream()
6495  : m_offset(0)
6496  { }
6497 
6502  inline MemoryStream(const DataBlock& data)
6503  : m_data(data), m_offset(0)
6504  { }
6505 
6510  inline const DataBlock& data() const
6511  { return m_data; }
6512 
6517  virtual bool terminate()
6518  { return true; }
6523  virtual bool valid() const
6524  { return true; }
6525 
6532  virtual int writeData(const void* buffer, int len);
6533 
6540  virtual int readData(void* buffer, int len);
6541 
6546  virtual int64_t length()
6547  { return m_data.length(); }
6548 
6555  virtual int64_t seek(SeekPos pos, int64_t offset = 0);
6556 
6557 protected:
6562 
6566  int64_t m_offset;
6567 };
6568 
6573 class YATE_API File : public Stream
6574 {
6575  YNOCOPY(File); // no automatic copies please
6576 public:
6580  File();
6581 
6586  explicit File(HANDLE handle);
6587 
6591  virtual ~File();
6592 
6605  virtual bool openPath(const char* name, bool canWrite = false, bool canRead = true,
6606  bool create = false, bool append = false, bool binary = false,
6607  bool pubReadable = false, bool pubWritable = false);
6608 
6613  virtual bool terminate();
6614 
6619  void attach(HANDLE handle);
6620 
6625  HANDLE detach();
6626 
6631  inline HANDLE handle() const
6632  { return m_handle; }
6633 
6638  virtual bool canRetry() const;
6639 
6644  virtual bool valid() const;
6645 
6650  static HANDLE invalidHandle();
6651 
6657  virtual bool setBlocking(bool block = true);
6658 
6663  virtual int64_t length();
6664 
6671  virtual int64_t seek(SeekPos pos, int64_t offset = 0);
6672 
6679  virtual int writeData(const void* buffer, int length);
6680 
6687  virtual int readData(void* buffer, int length);
6688 
6694  bool getFileTime(unsigned int& secEpoch);
6695 
6702  virtual bool md5(String& buffer);
6703 
6711  static bool setFileTime(const char* name, unsigned int secEpoch, int* error = 0);
6712 
6720  static bool getFileTime(const char* name, unsigned int& secEpoch, int* error = 0);
6721 
6728  static bool exists(const char* name, int* error = 0);
6729 
6737  static bool rename(const char* oldFile, const char* newFile, int* error = 0);
6738 
6745  static bool remove(const char* name, int* error = 0);
6746 
6754  static bool md5(const char* name, String& buffer, int* error = 0);
6755 
6763  static bool mkDir(const char* path, int* error = 0, int mode = -1);
6764 
6771  static bool rmDir(const char* path, int* error = 0);
6772 
6784  static bool listDirectory(const char* path, ObjList* dirs, ObjList* files,
6785  int* error = 0);
6786 
6793  static bool createPipe(File& reader, File& writer);
6794 
6795 protected:
6796 
6800  void copyError();
6801 
6802  HANDLE m_handle;
6803 };
6804 
6809 class YATE_API Socket : public Stream
6810 {
6811  YNOCOPY(Socket); // no automatic copies please
6812 public:
6816  enum TOS {
6817  Normal = 0,
6818  LowDelay = IPTOS_LOWDELAY,
6819  MaxThroughput = IPTOS_THROUGHPUT,
6820  MaxReliability = IPTOS_RELIABILITY,
6821  MinCost = IPTOS_MINCOST,
6822  };
6823 
6827  enum DSCP {
6828  DefaultPHB = 0x00,
6829  // Class selectors
6830  CS0 = 0x00,
6831  CS1 = 0x20,
6832  CS2 = 0x40,
6833  CS3 = 0x60,
6834  CS4 = 0x80,
6835  CS5 = 0xa0,
6836  CS6 = 0xc0,
6837  CS7 = 0xe0,
6838  // Assured forwarding
6839  AF11 = 0x28,
6840  AF12 = 0x30,
6841  AF13 = 0x38,
6842  AF21 = 0x48,
6843  AF22 = 0x50,
6844  AF23 = 0x58,
6845  AF31 = 0x68,
6846  AF32 = 0x70,
6847  AF33 = 0x78,
6848  AF41 = 0x88,
6849  AF42 = 0x90,
6850  AF43 = 0x98,
6851  // Expedited forwarding
6852  ExpeditedFwd = 0xb8,
6853  VoiceAdmit = 0xb0,
6854  };
6855 
6859  Socket();
6860 
6865  explicit Socket(SOCKET handle);
6866 
6873  Socket(int domain, int type, int protocol = 0);
6874 
6878  virtual ~Socket();
6879 
6887  virtual bool create(int domain, int type, int protocol = 0);
6888 
6893  virtual bool terminate();
6894 
6899  void attach(SOCKET handle);
6900 
6905  SOCKET detach();
6906 
6911  inline SOCKET handle() const
6912  { return m_handle; }
6913 
6918  virtual bool canRetry() const;
6919 
6924  virtual bool inProgress() const;
6925 
6930  virtual bool valid() const;
6931 
6936  static SOCKET invalidHandle();
6937 
6942  static int socketError();
6943 
6948  static const TokenDict* tosValues();
6949 
6958  virtual bool setOption(int level, int name, const void* value = 0, socklen_t length = 0);
6959 
6968  inline bool setIpv6OnlyOption(bool on) {
6969 #if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
6970  int value = on ? 1 : 0;
6971  return setOption(IPPROTO_IPV6,IPV6_V6ONLY,&value,sizeof(value));
6972 #else
6973  return false;
6974 #endif
6975  }
6976 
6985  virtual bool getOption(int level, int name, void* buffer, socklen_t* length);
6986 
6991  virtual bool setParams(const NamedList& params)
6992  { return false; }
6993 
7000  virtual bool getParams(const String& params, NamedList& result)
7001  { return false; }
7002 
7008  virtual bool setTOS(int tos);
7009 
7016  inline bool setTOS(const char* tos, int defTos = Normal)
7017  { return setTOS(lookup(tos,tosValues(),defTos)); }
7018 
7023  virtual int getTOS();
7024 
7030  virtual bool setBlocking(bool block = true);
7031 
7039  virtual bool setReuse(bool reuse = true, bool exclusive = false);
7040 
7047  virtual bool setLinger(int seconds = -1);
7048 
7055  virtual bool bind(struct sockaddr* addr, socklen_t addrlen);
7056 
7062  inline bool bind(const SocketAddr& addr)
7063  { return bind(addr.address(), addr.length()); }
7064 
7070  virtual bool listen(unsigned int backlog = 0);
7071 
7078  virtual Socket* accept(struct sockaddr* addr = 0, socklen_t* addrlen = 0);
7079 
7085  Socket* accept(SocketAddr& addr);
7086 
7093  SOCKET acceptHandle(struct sockaddr* addr = 0, socklen_t* addrlen = 0);
7094 
7102  bool updateError();
7103 
7108  static bool efficientSelect();
7109 
7115  static bool canSelect(SOCKET handle);
7116 
7121  virtual bool canSelect() const;
7122 
7129  virtual bool connect(struct sockaddr* addr, socklen_t addrlen);
7130 
7136  inline bool connect(const SocketAddr& addr)
7137  { return connect(addr.address(), addr.length()); }
7138 
7148  virtual bool connectAsync(struct sockaddr* addr, socklen_t addrlen, unsigned int toutUs,
7149  bool* timeout = 0);
7150 
7159  inline bool connectAsync(const SocketAddr& addr, unsigned int toutUs,
7160  bool* timeout = 0)
7161  { return connectAsync(addr.address(),addr.length(),toutUs,timeout); }
7162 
7169  virtual bool shutdown(bool stopReads, bool stopWrites);
7170 
7177  virtual bool getSockName(struct sockaddr* addr, socklen_t* addrlen);
7178 
7184  bool getSockName(SocketAddr& addr);
7185 
7192  virtual bool getPeerName(struct sockaddr* addr, socklen_t* addrlen);
7193 
7199  bool getPeerName(SocketAddr& addr);
7200 
7210  virtual int sendTo(const void* buffer, int length, const struct sockaddr* addr, socklen_t adrlen, int flags = 0);
7211 
7220  inline int sendTo(const void* buffer, int length, const SocketAddr& addr, int flags = 0)
7221  { return sendTo(buffer, length, addr.address(), addr.length(), flags); }
7222 
7230  virtual int send(const void* buffer, int length, int flags = 0);
7231 
7238  virtual int writeData(const void* buffer, int length);
7239 
7249  virtual int recvFrom(void* buffer, int length, struct sockaddr* addr = 0, socklen_t* adrlen = 0, int flags = 0);
7250 
7259  int recvFrom(void* buffer, int length, SocketAddr& addr, int flags = 0);
7260 
7268  virtual int recv(void* buffer, int length, int flags = 0);
7269 
7276  virtual int readData(void* buffer, int length);
7277 
7286  virtual bool select(bool* readok, bool* writeok, bool* except, struct timeval* timeout = 0);
7287 
7296  bool select(bool* readok, bool* writeok, bool* except, int64_t timeout);
7297 
7303  bool installFilter(SocketFilter* filter);
7304 
7310  void removeFilter(SocketFilter* filter, bool delobj = false);
7311 
7315  void clearFilters();
7316 
7323  virtual void timerTick(const Time& when);
7324 
7332  static bool createPair(Socket& sock1, Socket& sock2, int domain = AF_UNIX);
7333 
7334 protected:
7335 
7339  void copyError();
7340 
7347  bool checkError(int retcode, bool strict = false);
7348 
7358  bool applyFilters(void* buffer, int length, int flags, const struct sockaddr* addr = 0, socklen_t adrlen = 0);
7359 
7360  SOCKET m_handle;
7361  ObjList m_filters;
7362 };
7363 
7368 class YATE_API SctpSocket : public Socket
7369 {
7370  YNOCOPY(SctpSocket); // no automatic copies please
7371 public:
7375  inline SctpSocket()
7376  { }
7377 
7382  inline explicit SctpSocket(SOCKET fd)
7383  : Socket(fd)
7384  { }
7385 
7389  virtual ~SctpSocket();
7390 
7396  virtual bool bindx(ObjList& addresses) = 0;
7397 
7403  virtual bool connectx(ObjList& addresses) = 0;
7404 
7414  virtual int sendTo(void* buffer, int length, int stream, SocketAddr& addr, int flags) = 0;
7415 
7421  virtual Socket* accept(SocketAddr& addr)
7422  { return 0; }
7423 
7432  virtual int sendMsg(const void* buf, int length, int stream, int& flags) = 0;
7433 
7443  virtual int recvMsg(void* buf, int length, SocketAddr& addr, int& stream, int& flags) = 0;
7444 
7451  virtual bool setStreams(int inbound, int outbound) = 0;
7452 
7458  virtual bool subscribeEvents() = 0;
7459 
7466  virtual bool getStreams(int& inbound, int& outbound) = 0;
7467 
7473  virtual bool setPayload(u_int32_t payload) = 0;
7474 };
7475 
7480 class YATE_API DnsRecord : public GenObject
7481 {
7483  YNOCOPY(DnsRecord);
7484 public:
7491  inline DnsRecord(int ttl, int order, int pref)
7492  : m_ttl(ttl), m_order(order), m_pref(pref)
7493  {}
7494 
7498  inline DnsRecord()
7499  : m_order(0), m_pref(0)
7500  {}
7501 
7506  inline int ttl() const
7507  { return m_ttl; }
7508 
7513  inline int order() const
7514  { return m_order; }
7515 
7520  inline int pref() const
7521  { return m_pref; }
7522 
7528  virtual void dump(String& buf, const char* sep = " ");
7529 
7537  static bool insert(ObjList& list, DnsRecord* rec, bool ascPref);
7538 
7539 protected:
7540  int m_ttl;
7541  int m_order;
7542  int m_pref;
7543 };
7544 
7549 class YATE_API TxtRecord : public DnsRecord
7550 {
7552  YNOCOPY(TxtRecord);
7553 public:
7559  inline TxtRecord(int ttl, const char* text)
7560  : DnsRecord(ttl,-1,-1), m_text(text)
7561  {}
7562 
7567  inline const String& text() const
7568  { return m_text; }
7569 
7575  virtual void dump(String& buf, const char* sep = " ");
7576 
7582  static void copy(ObjList& dest, const ObjList& src);
7583 
7584 protected:
7585  String m_text;
7586 
7587 private:
7588  TxtRecord() {} // No default contructor
7589 };
7590 
7595 class YATE_API SrvRecord : public DnsRecord
7596 {
7598  YNOCOPY(SrvRecord);
7599 public:
7608  inline SrvRecord(int ttl, int prio, int weight, const char* addr, int port)
7609  : DnsRecord(ttl,prio,weight), m_address(addr), m_port(port)
7610  {}
7611 
7616  inline const String& address() const
7617  { return m_address; }
7618 
7623  inline int port() const
7624  { return m_port; }
7625 
7631  virtual void dump(String& buf, const char* sep = " ");
7632 
7638  static void copy(ObjList& dest, const ObjList& src);
7639 
7640 protected:
7641  String m_address;
7642  int m_port;
7643 
7644 private:
7645  SrvRecord() {} // No default contructor
7646 };
7647 
7652 class YATE_API NaptrRecord : public DnsRecord
7653 {
7656 public:
7667  NaptrRecord(int ttl, int ord, int pref, const char* flags, const char* serv,
7668  const char* regexp, const char* next);
7669 
7676  bool replace(String& str) const;
7677 
7683  virtual void dump(String& buf, const char* sep = " ");
7684 
7689  inline const String& flags() const
7690  { return m_flags; }
7691 
7696  inline const String& serv() const
7697  { return m_service; }
7698 
7703  inline const Regexp& regexp() const
7704  { return m_regmatch; }
7705 
7710  inline const String& repTemplate() const
7711  { return m_template; }
7712 
7717  inline const String& nextName() const
7718  { return m_next; }
7719 
7720 protected:
7721  String m_flags;
7722  String m_service;
7723  Regexp m_regmatch;
7724  String m_template;
7725  String m_next;
7726 
7727 private:
7728  NaptrRecord() {} // No default contructor
7729 };
7730 
7735 class YATE_API Resolver
7736 {
7737 public:
7741  enum Type {
7742  Unknown,
7743  Srv, // SRV (Service Location)
7744  Naptr, // NAPTR (Naming Authority Pointer)
7745  A4, // A (Address)
7746  A6, // AAAA (IPv6 Address)
7747  Txt, // TXT (Text)
7748  };
7749 
7756  static bool available(Type type = Unknown);
7757 
7764  static bool init(int timeout = -1, int retries = -1);
7765 
7774  static int query(Type type, const char* dname, ObjList& result, String* error = 0);
7775 
7783  static int srvQuery(const char* dname, ObjList& result, String* error = 0);
7784 
7792  static int naptrQuery(const char* dname, ObjList& result, String* error = 0);
7793 
7801  static int a4Query(const char* dname, ObjList& result, String* error = 0);
7802 
7810  static int a6Query(const char* dname, ObjList& result, String* error = 0);
7811 
7819  static int txtQuery(const char* dname, ObjList& result, String* error = 0);
7820 
7824  static const TokenDict s_types[];
7825 };
7826 
7831 class YATE_API Cipher : public GenObject
7832 {
7833 public:
7837  enum Direction {
7838  Bidir,
7839  Encrypt,
7840  Decrypt,
7841  };
7842 
7847  inline static const TokenDict* directions()
7848  { return s_directions; }
7849 
7856  inline static Direction direction(const char* name, Direction defdir = Bidir)
7857  { return (Direction)TelEngine::lookup(name,s_directions,defdir); }
7858 
7862  virtual ~Cipher();
7863 
7869  virtual void* getObject(const String& name) const;
7870 
7876  virtual bool valid(Direction dir = Bidir) const;
7877 
7882  virtual unsigned int blockSize() const = 0;
7883 
7888  virtual unsigned int initVectorSize() const;
7889 
7895  unsigned int bufferSize(unsigned int len) const;
7896 
7902  bool bufferFull(unsigned int len) const;
7903 
7911  virtual bool setKey(const void* key, unsigned int len, Direction dir = Bidir) = 0;
7912 
7919  inline bool setKey(const DataBlock& key, Direction dir = Bidir)
7920  { return setKey(key.data(),key.length(),dir); }
7921 
7929  virtual bool initVector(const void* vect, unsigned int len, Direction dir = Bidir);
7930 
7937  inline bool initVector(const DataBlock& vect, Direction dir = Bidir)
7938  { return initVector(vect.data(),vect.length(),dir); }
7939 
7947  virtual bool encrypt(void* outData, unsigned int len, const void* inpData = 0) = 0;
7948 
7954  inline bool encrypt(DataBlock& data)
7955  { return encrypt(data.data(),data.length()); }
7956 
7964  virtual bool decrypt(void* outData, unsigned int len, const void* inpData = 0) = 0;
7965 
7971  inline bool decrypt(DataBlock& data)
7972  { return decrypt(data.data(),data.length()); }
7973 
7974 private:
7975  static const TokenDict s_directions[];
7976 };
7977 
7983 class YATE_API Compressor : public String
7984 {
7986  YNOCOPY(Compressor); // no automatic copies please
7987 public:
7993  inline Compressor(const char* format, const char* name = 0)
7994  : String(name), m_format(format)
7995  {}
7996 
8000  virtual ~Compressor()
8001  {}
8002 
8007  inline const String& format() const
8008  { return m_format; }
8009 
8017  virtual bool init(bool comp = true, bool decomp = true,
8018  const NamedList& params = NamedList::empty())
8019  { return true; }
8020 
8025  virtual void finalize(bool comp)
8026  {}
8027 
8036  virtual int compress(const void* buf, unsigned int len, DataBlock& dest);
8037 
8046  virtual int decompress(const void* buf, unsigned int len, DataBlock& dest);
8047 
8058  virtual int writeComp(const void* buf, unsigned int len, bool flush) = 0;
8059 
8068  inline int writeComp(const DataBlock& data, bool flush)
8069  { return writeComp(data.data(),data.length(),flush); }
8070 
8079  inline int writeComp(const String& data, bool flush)
8080  { return writeComp(data.c_str(),data.length(),flush); }
8081 
8088  virtual int readComp(DataBlock& buf, bool flush) = 0;
8089 
8098  virtual int writeDecomp(const void* buf, unsigned int len, bool flush) = 0;
8099 
8107  inline int writeDecomp(const DataBlock& data, bool flush)
8108  { return writeDecomp(data.data(),data.length(),flush); }
8109 
8117  inline int writeDecomp(const String& data, bool flush)
8118  { return writeDecomp(data.c_str(),data.length(),flush); }
8119 
8126  virtual int readDecomp(DataBlock& buf, bool flush) = 0;
8127 
8128 protected:
8129  String m_format;
8130 };
8131 
8137 class YATE_API SysUsage
8138 {
8139 public:
8143  enum Type {
8144  WallTime,
8145  UserTime,
8146  KernelTime
8147  };
8148 
8152  static void init();
8153 
8158  static u_int64_t startTime();
8159 
8165  static u_int64_t usecRunTime(Type type = WallTime);
8166 
8172  static u_int64_t msecRunTime(Type type = WallTime);
8173 
8179  static u_int32_t secRunTime(Type type = WallTime);
8180 
8186  static double runTime(Type type = WallTime);
8187 
8188 };
8189 
8190 }; // namespace TelEngine
8191 
8192 #endif /* __YATECLASS_H */
8193 
8194 /* vi: set ts=8 sw=4 sts=4 noet: */
A Mutex pool.
Definition: yateclass.h:5221
int sendTo(const void *buffer, int length, const SocketAddr &addr, int flags=0)
Definition: yateclass.h:7220
Time & operator=(u_int64_t usec)
Definition: yateclass.h:3607
String & operator+=(bool value)
Definition: yateclass.h:2328
A DNS record.
Definition: yateclass.h:7480
Internal helper class.
Definition: yateclass.h:1055
const char * c_safe(const char *str)
Definition: yateclass.h:2813
int count() const
Definition: yateclass.h:3272
bool null() const
Definition: yateclass.h:1967
Abstract interface for lockable objects.
Definition: yateclass.h:5048
int writeData(const DataBlock &buf)
Definition: yateclass.h:6405
RefPointer(const RefPointer< Obj > &value)
Definition: yateclass.h:1109
const char * debugColor(int level)
Compressor(const char *format, const char *name=0)
Definition: yateclass.h:7993
int debugLevel()
GenPointer()
Definition: yateclass.h:1173
DataBlock & operator+=(const DataBlock &value)
Definition: yateclass.h:3965
int locks() const
Definition: yateclass.h:5574
GenObject * operator[](unsigned int index) const
Definition: yateclass.h:1547
static bool alive(const RefObject *obj)
Definition: yateclass.h:1013
UChar & operator=(char code)
Definition: yateclass.h:1786
unsigned int index(void *ptr) const
Definition: yateclass.h:5248
void setDelete(bool autodelete)
Definition: yateclass.h:1604
bool hmacStart(DataBlock &opad, const DataBlock &key)
Definition: yateclass.h:4130
const char * c_str() const
Definition: yateclass.h:1938
GenObject * operator[](signed int index) const
Definition: yateclass.h:1539
A class that holds just a block of raw data.
Definition: yateclass.h:3774
ObjList * getList(unsigned int index) const
Definition: yateclass.h:3329
String sqlEscape(char extraEsc=0) const
Definition: yateclass.h:2731
int debugLevel() const
Definition: yateclass.h:328
ObjList * next() const
Definition: yateclass.h:1281
const String & getUser() const
Definition: yateclass.h:5000
u_int32_t sec() const
Definition: yateclass.h:3581
bool isNullAddr() const
Definition: yateclass.h:6061
UChar(uint32_t code=0)
Definition: yateclass.h:1745
Definition: yateclass.h:949
int value
Definition: yateclass.h:692
A regexp matching class.
Definition: yateclass.h:2902
NamedIterator(const NamedList &list)
Definition: yateclass.h:4865
static void setObjCounting(bool enable)
Definition: yateclass.h:892
void Debug(int level, const char *format,...)
static const char * lookupFamily(int family)
Definition: yateclass.h:6217
SOCKET handle() const
Definition: yateclass.h:6911
static unsigned int scopeId(struct sockaddr *addr)
Definition: yateclass.h:6121
A captured event string with a debug level.
Definition: yateclass.h:3034
const char * safe(const char *defStr) const
Definition: yateclass.h:1953
Regexp & operator=(const char *value)
Definition: yateclass.h:2933
String matchString(int index=0) const
Definition: yateclass.h:2660
Mutex * mutex(void *ptr) const
Definition: yateclass.h:5258
GenPointer< Obj > & operator=(Obj *object)
Definition: yateclass.h:1202
RefPointer()
Definition: yateclass.h:1102
String & operator<<(int64_t value)
Definition: yateclass.h:2396
SocketAddr & operator=(const SocketAddr &value)
Definition: yateclass.h:5911
~Lock2()
Definition: yateclass.h:5458
GenObject * operator[](unsigned int index) const
Definition: yateclass.h:1329
GenPointer< Obj > & operator=(const GenPointer< Obj > &value)
Definition: yateclass.h:1196
ObjList * skipNull() const
A NAPTR record.
Definition: yateclass.h:7652
void toTimeval(struct timeval *tv) const
Definition: yateclass.h:3626
bool eof() const
Definition: yateclass.h:3514
static bool capturing()
Definition: yateclass.h:3068
MemoryStream()
Definition: yateclass.h:6494
bool decrypt(DataBlock &data)
Definition: yateclass.h:7971
uint32_t code() const
Definition: yateclass.h:1793
virtual bool init(bool comp=true, bool decomp=true, const NamedList &params=NamedList::empty())
Definition: yateclass.h:8017
bool connectAsync(const SocketAddr &addr, unsigned int toutUs, bool *timeout=0)
Definition: yateclass.h:7159
A filter for received socket data.
Definition: yateclass.h:6262
const String & hexDigest()
Definition: yateclass.h:4067
const char * strcat(String &dest, const char *src)
Definition: yateclass.h:2866
const String & format() const
Definition: yateclass.h:8007
NamedIterator & operator=(const NamedList &list)
Definition: yateclass.h:4881
const String & address() const
Definition: yateclass.h:7616
bool autoDelete()
Definition: yateclass.h:1428
UChar(int32_t code)
Definition: yateclass.h:1753
Formatting
Definition: yateclass.h:576
virtual ~GenObject()
Definition: yateclass.h:842
static void append(int level, const char *text)
Definition: yateclass.h:3083
Thread support class.
Definition: yateclass.h:5529
bool update(const String &str)
Definition: yateclass.h:4092
bool locked() const
Definition: yateclass.h:5581
const String & getExtra() const
Definition: yateclass.h:5021
~Lock()
Definition: yateclass.h:5380
int writeDecomp(const String &data, bool flush)
Definition: yateclass.h:8117
SeekPos
Definition: yateclass.h:6328
constant YSTRING(const char *string)
A stream file class.
Definition: yateclass.h:6573
bool hmac(const String &key, const String &msg)
Definition: yateclass.h:4174
static int unStringify(uint8_t *buf, const String &host, int family=Unknown)
Definition: yateclass.h:6101
const Regexp & regexp() const
Definition: yateclass.h:7703
RefPointer< Obj > & operator=(const RefPointer< Obj > &value)
Definition: yateclass.h:1129
static const char * boolText(bool value)
Definition: yateclass.h:1931
bool lock(Mutex &mx1, Mutex &mx2, long maxwait=-1)
Definition: yateclass.h:5484
Stream()
Definition: yateclass.h:6470
unsigned int length() const
Definition: yateclass.h:4595
static bool getObjCounting()
Definition: yateclass.h:885
bool null() const
Definition: yateclass.h:5973
void enable(bool val)
Definition: yateclass.h:3253
String uriEscape(char extraEsc=0, const char *noEsc=0) const
Definition: yateclass.h:2758
bool compile() const
Definition: yateclass.h:2940
bool checkBOM() const
Definition: yateclass.h:2010
bool hmac(const DataBlock &key, const DataBlock &msg)
Definition: yateclass.h:4165
const String & flags() const
Definition: yateclass.h:7689
Socket * socket() const
Definition: yateclass.h:6305
virtual unsigned int hashLength() const
Definition: yateclass.h:4469
Lock(Lockable &lck, long maxwait=-1)
Definition: yateclass.h:5366
An abstract cipher.
Definition: yateclass.h:7831
virtual unsigned int hashLength() const
Definition: yateclass.h:4372
~RefPointer()
Definition: yateclass.h:1123
unsigned int length() const
Definition: yateclass.h:3314
u_int64_t msec() const
Definition: yateclass.h:3588
ObjList * getColumn(int column) const
Definition: yateclass.h:1719
Time()
Definition: yateclass.h:3542
unsigned char * data(unsigned int offs, unsigned int len=1) const
Definition: yateclass.h:3836
void XDebug(int level, const char *format,...)
static unsigned int rawLength()
Definition: yateclass.h:4365
Base64(void *src, unsigned int len, bool copyData=true)
Definition: yateclass.h:4500
String & operator<<(const char *value)
Definition: yateclass.h:2372
bool connect(const SocketAddr &addr)
Definition: yateclass.h:7136
int port() const
Definition: yateclass.h:7623
Obj * pointer() const
Definition: yateclass.h:1088
String uriUnescape(int *errptr=0) const
Definition: yateclass.h:2774
~Time()
Definition: yateclass.h:3574
A socket address holder.
Definition: yateclass.h:5848
ObjVector(bool autodelete=true)
Definition: yateclass.h:1475
static u_int64_t fromTimeval(const struct timeval &tv)
Definition: yateclass.h:3648
bool debugChained() const
Definition: yateclass.h:370
void resize(unsigned int len)
Definition: yateclass.h:3924
int order() const
Definition: yateclass.h:7513
URI & operator=(const char *value)
Definition: yateclass.h:4979
const String & name() const
Definition: yateclass.h:3126
static const String * atom(const String *&str, const char *val)
String & operator<<(uint64_t value)
Definition: yateclass.h:2402
const char * debugName() const
Definition: yateclass.h:356
virtual int64_t length()
Definition: yateclass.h:6546
virtual ~Compressor()
Definition: yateclass.h:8000
String & operator<<(double value)
Definition: yateclass.h:2414
A list based Array.
Definition: yateclass.h:1621
MemoryStream(const DataBlock &data)
Definition: yateclass.h:6502
bool bind(const SocketAddr &addr)
Definition: yateclass.h:7062
unsigned int length() const
Definition: yateclass.h:3466
SrvRecord(int ttl, int prio, int weight, const char *addr, int port)
Definition: yateclass.h:7608
NamedIterator & operator=(const NamedIterator &original)
Definition: yateclass.h:4888
void set(u_int32_t seed)
Definition: yateclass.h:3745
GenObject * remove(bool delobj=true)
void * userObject(const String &name) const
Definition: yateclass.h:3201
const char * familyName()
Definition: yateclass.h:5987
const String & nextName() const
Definition: yateclass.h:7717
void debugName(const char *name)
Definition: yateclass.h:391
Hasher()
Definition: yateclass.h:4193
RefPointer< Obj > & operator=(Obj *object)
Definition: yateclass.h:1135
GenObject * at(int index) const
Definition: yateclass.h:1531
NamedList & setParam(NamedString *param)
Definition: yateclass.h:4632
Ephemeral object counter changer.
Definition: yateclass.h:5800
static bool stripBOM(const char *&str)
Definition: yateclass.h:2018
bool acquire(Lockable &lck, long maxwait=-1)
Definition: yateclass.h:5412
virtual bool getParams(const String &params, NamedList &result)
Definition: yateclass.h:7000
static ObjList & eventsRw()
Definition: yateclass.h:3091
Type
Definition: yateclass.h:7741
Encapsulates a runnable task.
Definition: yateclass.h:5508
virtual bool valid() const
Definition: yateclass.h:6523
CapturedEvent(int level, const char *text)
Definition: yateclass.h:3044
int writeComp(const String &data, bool flush)
Definition: yateclass.h:8079
Base64 & operator<<(const DataBlock &data)
Definition: yateclass.h:4537
Abstract SCTP Socket.
Definition: yateclass.h:7368
struct sockaddr * address() const
Definition: yateclass.h:6047
A standard SHA1 digest calculator.
Definition: yateclass.h:4300
virtual void destruct()
GenPointer(Obj *object)
Definition: yateclass.h:1189
Time(const struct timeval *tv)
Definition: yateclass.h:3558
Encapsulation for an URI.
Definition: yateclass.h:4920
int family() const
Definition: yateclass.h:5980
unsigned int count() const
Definition: yateclass.h:4602
void overAlloc(unsigned int bytes)
Definition: yateclass.h:3873
Time & operator-=(int64_t delta)
Definition: yateclass.h:3619
Hasher & operator<<(const String &value)
Definition: yateclass.h:4099
String & operator=(const String &value)
Definition: yateclass.h:2225
String & operator=(bool value)
Definition: yateclass.h:2277
static bool checkBOM(const char *str)
Definition: yateclass.h:2003
URI & operator=(const URI &value)
Definition: yateclass.h:4965
int operator[](signed int index) const
Definition: yateclass.h:3946
A class exposing system resources usage.
Definition: yateclass.h:8137
static void capturing(bool capture)
Definition: yateclass.h:3098
const char * token
Definition: yateclass.h:687
int lookup(const char *str, const TokenDict *tokens, int defvalue=0, int base=0)
int operator[](unsigned int index) const
Definition: yateclass.h:3954
CapturedEvent(const CapturedEvent &original)
Definition: yateclass.h:3052
bool eof() const
Definition: yateclass.h:4900
GenObject * operator[](signed int index) const
Definition: yateclass.h:1321
Base64 & operator<<(const String &value)
Definition: yateclass.h:4531
void destruct(GenObject *obj)
Definition: yateclass.h:933
bool initVector(const DataBlock &vect, Direction dir=Bidir)
Definition: yateclass.h:7937
static unsigned int rawLength()
Definition: yateclass.h:4278
const String & host() const
Definition: yateclass.h:6009
bool scopeId(unsigned int val)
Definition: yateclass.h:6002
URI & operator=(const String &value)
Definition: yateclass.h:4972
char operator[](signed int index) const
Definition: yateclass.h:2177
void assign(RefObject *oldptr, RefObject *newptr, void *pointer)
int64_t seek(int64_t offset)
Definition: yateclass.h:6435
ObjList * paramList()
Definition: yateclass.h:4838
UChar(unsigned char code)
Definition: yateclass.h:1769
UChar & operator=(uint32_t code)
Definition: yateclass.h:1778
static String & appendTo(String &buf, const String &addr, int port, int family=Unknown)
Definition: yateclass.h:6162
Obj & operator*() const
Definition: yateclass.h:1154
TxtRecord(int ttl, const char *text)
Definition: yateclass.h:7559
RefPointer(Obj *object)
Definition: yateclass.h:1117
DSCP
Definition: yateclass.h:6827
GenObject * userData() const
Definition: yateclass.h:3179
A single Unicode character.
Definition: yateclass.h:1738
void append(void *value, unsigned int len)
Definition: yateclass.h:3896
bool unHexify(const String &data)
Definition: yateclass.h:4014
static String appendTo(const String &addr, int port, int family=Unknown)
Definition: yateclass.h:6175
A time holding class.
Definition: yateclass.h:3536
Time & operator+=(int64_t delta)
Definition: yateclass.h:3613
static bool isLeap(unsigned int year)
Definition: yateclass.h:3706
SocketAddr(const SocketAddr &value)
Definition: yateclass.h:5883
const String & text() const
Definition: yateclass.h:7567
const String * operator->() const
Definition: yateclass.h:3023
virtual bool lock(long maxwait=-1)=0
Obj & operator*() const
Definition: yateclass.h:1221
Direction
Definition: yateclass.h:7837
A holder for a debug level.
Definition: yateclass.h:309
Lock2(Mutex *mx1, Mutex *mx2, long maxwait=-1)
Definition: yateclass.h:5441
A generic socket class.
Definition: yateclass.h:6809
DataBlock m_data
Definition: yateclass.h:6561
virtual unsigned int hashLength() const
Definition: yateclass.h:4285
int error() const
Definition: yateclass.h:6343
void * data() const
Definition: yateclass.h:3827
bool acquire(Lockable *lck, long maxwait=-1)
Definition: yateclass.h:5402
An abstract hashing class.
Definition: yateclass.h:4036
DebugLevel
Definition: yateclass.h:254
TempObjectCounter(NamedCounter *counter, bool enable=GenObject::getObjCounting())
Definition: yateclass.h:5809
static const NamedList & empty()
void reset()
Definition: yateclass.h:3520
String msgUnescape(int *errptr=0, char extraEsc=0) const
Definition: yateclass.h:2715
int lenUtf8(uint32_t maxChar=0x10ffff, bool overlong=false) const
Definition: yateclass.h:1985
String & operator<<(char value)
Definition: yateclass.h:2378
An object that logs messages on creation and destruction.
Definition: yateclass.h:570
int getPort() const
Definition: yateclass.h:5014
void reset()
Definition: yateclass.h:4906
Atom string holder.
Definition: yateclass.h:3001
String & operator<<(int32_t value)
Definition: yateclass.h:2384
void debugChain(const DebugEnabler *chain=0)
Definition: yateclass.h:377
A named pointer class.
Definition: yateclass.h:3159
bool enabled() const
Definition: yateclass.h:3246
class * YOBJECT(class type, GenObject *pntr)
socklen_t length() const
Definition: yateclass.h:6054
constant YATOM(const char *string)
String & operator<<(bool value)
Definition: yateclass.h:2408
bool setKey(const DataBlock &key, Direction dir=Bidir)
Definition: yateclass.h:7919
void DDebug(int level, const char *format,...)
const String & getDescription() const
Definition: yateclass.h:4986
Obj * operator->() const
Definition: yateclass.h:1215
int64_t m_offset
Definition: yateclass.h:6566
A named string class.
Definition: yateclass.h:3111
virtual void finalize(bool comp)
Definition: yateclass.h:8025
A standard SHA256 digest calculator.
Definition: yateclass.h:4397
bool setTOS(const char *tos, int defTos=Normal)
Definition: yateclass.h:7016
String msgEscape(char extraEsc=0) const
Definition: yateclass.h:2697
bool operator!=(const String &value) const
Definition: yateclass.h:2356
static unsigned int rawLength()
Definition: yateclass.h:4462
void drop()
Definition: yateclass.h:5393
bool operator==(const String &value) const
Definition: yateclass.h:2350
DNS services.
Definition: yateclass.h:7735
int getColumns() const
Definition: yateclass.h:1709
const char * c_str(const String *str)
Definition: yateclass.h:2805
DebugEnabler(int level=TelEngine::debugLevel(), bool enabled=true)
Definition: yateclass.h:317
bool null(const char *str)
Definition: yateclass.h:2829
void NDebug(int level, const char *format,...)
int pref() const
Definition: yateclass.h:7520
static void * getObject(const String &name, const GenObject *obj)
Definition: yateclass.h:878
const String & getHost() const
Definition: yateclass.h:5007
NamedCounter * getObjCounter() const
Definition: yateclass.h:899
Base64 encoder/decoder class.
Definition: yateclass.h:4484
void YCLASSIMP3(class type, class base1, class base2, class base3)
A hashed object list class.
Definition: yateclass.h:3288
SctpSocket()
Definition: yateclass.h:7375
void clear(bool deleteData=true)
bool stripBOM()
Definition: yateclass.h:2033
const String & addr() const
Definition: yateclass.h:6016
int refcount() const
Definition: yateclass.h:999
void YCLASSIMP(class type, class base)
Base64 & operator<<(const char *value)
Definition: yateclass.h:4543
A named string container class.
Definition: yateclass.h:4553
String operator+(const String &s1, const String &s2)
void * m_pointer
Definition: yateclass.h:1075
DataBlock & operator+=(const String &value)
Definition: yateclass.h:3971
const String & getProtocol() const
Definition: yateclass.h:4993
char operator[](unsigned int index) const
Definition: yateclass.h:2185
virtual bool matches(const String &value) const
Definition: yateclass.h:2955
Templated smart pointer class.
Definition: yateclass.h:1081
Ephemeral mutex or semaphore locking object.
Definition: yateclass.h:5357
Lock2(Mutex &mx1, Mutex &mx2, long maxwait=-1)
Definition: yateclass.h:5451
virtual Socket * accept(SocketAddr &addr)
Definition: yateclass.h:7421
bool hmacStart(DataBlock &opad, const String &key)
Definition: yateclass.h:4139
void YCLASS3(class type, class base1, class base2, class base3)
Pseudo random number generator.
Definition: yateclass.h:3723
String & operator<<(String &str, const Complex &c)
Definition: yatemath.h:1685
GenPointer(const GenPointer< Obj > &value)
Definition: yateclass.h:1181
bool update(const void *buf, unsigned int len)
Definition: yateclass.h:4076
Hasher & operator<<(const DataBlock &data)
Definition: yateclass.h:4106
Semaphore implementation.
Definition: yateclass.h:5279
An abstract stream class capable of reading and writing.
Definition: yateclass.h:6322
void YCLASSIMP2(class type, class base1, class base2)
void clearError()
Definition: yateclass.h:6477
Base64()
Definition: yateclass.h:4491
String & append(const ObjList &list, const char *separator=0, bool force=false)
Definition: yateclass.h:2478
TempObjectCounter(const GenObject *obj, bool enable=GenObject::getObjCounting())
Definition: yateclass.h:5818
A Stream that operates on DataBlocks in memory.
Definition: yateclass.h:6487
Templated pointer that can be inserted in a list.
Definition: yateclass.h:1161
bool encrypt(DataBlock &data)
Definition: yateclass.h:7954
virtual bool matches(const String &value) const
Definition: yateclass.h:2631
static bool errorString(String &buffer)
Definition: yateclass.h:5755
virtual void * getObject(const String &name) const
Time(const struct timeval &tv)
Definition: yateclass.h:3566
Ephemeral double mutex locking object.
Definition: yateclass.h:5431
bool valid() const
Definition: yateclass.h:5966
static u_int64_t now()
unsigned int length() const
Definition: yateclass.h:1511
int writeDecomp(const DataBlock &data, bool flush)
Definition: yateclass.h:8107
int level() const
Definition: yateclass.h:3060
SctpSocket(SOCKET fd)
Definition: yateclass.h:7382
ObjList * getHashList(const String &str) const
Definition: yateclass.h:3345
bool isCurrent() const
Definition: yateclass.h:5685
static NamedCounter * setCurrentObjCounter(NamedCounter *counter)
HANDLE handle() const
Definition: yateclass.h:6631
static const ObjList & events()
Definition: yateclass.h:3075
A text based DNS record.
Definition: yateclass.h:7549
Definition: yateclass.h:217
int writeData(const String &str)
Definition: yateclass.h:6397
int ttl() const
Definition: yateclass.h:7506
const DataBlock & data() const
Definition: yateclass.h:6510
TOS
Definition: yateclass.h:6816
NamedPointer & operator=(const char *value)
Definition: yateclass.h:3207
NamedString & operator=(const char *value)
Definition: yateclass.h:3145
const ObjList * paramList() const
Definition: yateclass.h:4845
bool operator!=(const SocketAddr &other) const
Definition: yateclass.h:5926
A C-style string handling class.
Definition: yateclass.h:1832
Atom(const char *value)
Definition: yateclass.h:3008
void assign(Obj *object=0)
Definition: yateclass.h:1095
bool locked() const
Definition: yateclass.h:5465
const char * strcpy(String &dest, const char *src)
Definition: yateclass.h:2859
Class used to iterate the items of a list.
Definition: yateclass.h:3437
Definition: yateclass.h:683
static const TokenDict * directions()
Definition: yateclass.h:7847
Priority
Definition: yateclass.h:5539
const char * c_str() const
Definition: yateclass.h:1800
bool setIpv6OnlyOption(bool on)
Definition: yateclass.h:6968
Time(u_int64_t usec)
Definition: yateclass.h:3550
bool autoDelete()
Definition: yateclass.h:1597
TempObjectCounter(const GenObject &obj, bool enable=GenObject::getObjCounting())
Definition: yateclass.h:5827
const char * debugLevelName(int level)
DnsRecord(int ttl, int order, int pref)
Definition: yateclass.h:7491
virtual bool setParams(const NamedList &params)
Definition: yateclass.h:6991
u_int64_t usec() const
Definition: yateclass.h:3595
const char * safe() const
Definition: yateclass.h:1945
int writeComp(const DataBlock &data, bool flush)
Definition: yateclass.h:8068
static bool scopeId(struct sockaddr *addr, unsigned int val)
Definition: yateclass.h:6135
void Output(const char *format,...)
const String & serv() const
Definition: yateclass.h:7696
An object list class.
Definition: yateclass.h:1229
unsigned int length() const
Definition: yateclass.h:3859
unsigned int length() const
Definition: yateclass.h:1960
void Alarm(const char *component, int level, const char *format,...)
Lock(Lockable *lck, long maxwait=-1)
Definition: yateclass.h:5374
bool debugAt(int level)
bool null() const
Definition: yateclass.h:3852
void YNOCOPY(class type)
void clearParams()
Definition: yateclass.h:4608
const String & repTemplate() const
Definition: yateclass.h:7710
void YCLASS(class type, class base)
NamedIterator(const NamedIterator &original)
Definition: yateclass.h:4873
unsigned int scopeId() const
Definition: yateclass.h:5994
void setDelete(bool autodelete)
Definition: yateclass.h:1435
~TempObjectCounter()
Definition: yateclass.h:5834
static bool stripBOM(char *&str)
Definition: yateclass.h:2026
void abortOnBug()
bool debugEnabled() const
Definition: yateclass.h:342
int at(unsigned int offs, int defvalue=-1) const
Definition: yateclass.h:3845
bool update(const DataBlock &data)
Definition: yateclass.h:4084
Type
Definition: yateclass.h:8143
ObjList * getHashList(unsigned int hash) const
Definition: yateclass.h:3337
DnsRecord()
Definition: yateclass.h:7498
NamedList parameters iterator.
Definition: yateclass.h:4858
A vector holding GenObjects.
Definition: yateclass.h:1467
virtual bool terminate()
Definition: yateclass.h:6517
A SRV record.
Definition: yateclass.h:7595
Random(u_int32_t seed=Time::now()&0xffffffff)
Definition: yateclass.h:3730
Obj * operator->() const
Definition: yateclass.h:1148
Lockable * locked() const
Definition: yateclass.h:5387
Mutex * mutex(unsigned int idx) const
Definition: yateclass.h:5266
void YIGNORE(primitive value)
bool matches(const char *value) const
UChar(signed char code)
Definition: yateclass.h:1761
Family
Definition: yateclass.h:5855
Mutex support.
Definition: yateclass.h:5131
unsigned int hash() const
Definition: yateclass.h:2040
A standard MD5 digest calculator.
Definition: yateclass.h:4213
RefPointerBase()
Definition: yateclass.h:1061
An abstract data (de)compressor.
Definition: yateclass.h:7983
String & operator=(const String *value)
Definition: yateclass.h:2233
Engine globals.
Definition: yatengine.h:1161
Definition: yateclass.h:830
SocketAddr()
Definition: yateclass.h:5875
void debugEnabled(bool enable)
Definition: yateclass.h:349
unsigned int overAlloc() const
Definition: yateclass.h:3866
String & operator<<(uint32_t value)
Definition: yateclass.h:2390
int getRows() const
Definition: yateclass.h:1702
bool controlReturn(NamedList *params, bool ret, const char *retVal=0)
static Direction direction(const char *name, Direction defdir=Bidir)
Definition: yateclass.h:7856
String & operator+=(const char *value)
Definition: yateclass.h:2291
Atomic counter with name.
Definition: yateclass.h:3232
void YCLASS2(class type, class base1, class base2)