Anope IRC Services  Version 2.0
anope.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  */
12 
13 #ifndef ANOPE_H
14 #define ANOPE_H
15 
16 #include <signal.h>
17 
18 #include "hashcomp.h"
19 
20 namespace Anope
21 {
28  {
29  private:
35  public:
39  typedef std::string::iterator iterator;
40  typedef std::string::const_iterator const_iterator;
41  typedef std::string::reverse_iterator reverse_iterator;
42  typedef std::string::const_reverse_iterator const_reverse_iterator;
43  typedef std::string::size_type size_type;
44  static const size_type npos = static_cast<size_type>(-1);
45 
49  string() : _string("") { }
50  string(char chr) : _string() { _string = chr; }
51  string(size_type n, char chr) : _string(n, chr) { }
52  string(const char *_str) : _string(_str) { }
53  string(const char *_str, size_type n) : _string(_str, n) { }
54  string(const std::string &_str) : _string(_str) { }
55  string(const ci::string &_str) : _string(_str.c_str()) { }
56  string(const string &_str, size_type pos, size_type n = npos) : _string(_str._string, pos, n) { }
57  template <class InputIterator> string(InputIterator first, InputIterator last) : _string(first, last) { }
58 
62  inline string &operator=(char chr) { this->_string = chr; return *this; }
63  inline string &operator=(const char *_str) { this->_string = _str; return *this; }
64  inline string &operator=(const std::string &_str) { this->_string = _str; return *this; }
65  inline string &operator=(const string &_str) { if (this != &_str) this->_string = _str._string; return *this; }
66 
70  inline bool operator==(const char *_str) const { return this->_string == _str; }
71  inline bool operator==(const std::string &_str) const { return this->_string == _str; }
72  inline bool operator==(const string &_str) const { return this->_string == _str._string; }
73 
74  inline bool equals_cs(const char *_str) const { return this->_string == _str; }
75  inline bool equals_cs(const std::string &_str) const { return this->_string == _str; }
76  inline bool equals_cs(const string &_str) const { return this->_string == _str._string; }
77 
78  inline bool equals_ci(const char *_str) const { return ci::string(this->_string.c_str()) == _str; }
79  inline bool equals_ci(const std::string &_str) const { return ci::string(this->_string.c_str()) == _str.c_str(); }
80  inline bool equals_ci(const string &_str) const { return ci::string(this->_string.c_str()) == _str._string.c_str(); }
81 
85  inline bool operator!=(const char *_str) const { return !operator==(_str); }
86  inline bool operator!=(const std::string &_str) const { return !operator==(_str); }
87  inline bool operator!=(const string &_str) const { return !operator==(_str); }
88 
92  inline string &operator+=(char chr) { this->_string += chr; return *this; }
93  inline string &operator+=(const char *_str) { this->_string += _str; return *this; }
94  inline string &operator+=(const std::string &_str) { this->_string += _str; return *this; }
95  inline string &operator+=(const string &_str) { if (this != &_str) this->_string += _str._string; return *this; }
96 
100  inline const string operator+(char chr) const { return string(*this) += chr; }
101  inline const string operator+(const char *_str) const { return string(*this) += _str; }
102  inline const string operator+(const std::string &_str) const { return string(*this) += _str; }
103  inline const string operator+(const string &_str) const { return string(*this) += _str; }
104 
105  friend const string operator+(char chr, const string &str);
106  friend const string operator+(const char *_str, const string &str);
107  friend const string operator+(const std::string &_str, const string &str);
108 
112  inline bool operator<(const string &_str) const { return this->_string < _str._string; }
113 
117  inline const char *c_str() const { return this->_string.c_str(); }
118  inline const char *data() const { return this->_string.data(); }
119  inline std::string &str() { return this->_string; }
120  inline const std::string &str() const { return this->_string; }
121  inline ci::string ci_str() const { return ci::string(this->_string.c_str()); }
122 
126  inline bool empty() const { return this->_string.empty(); }
127 
131  inline size_type length() const { return this->_string.length(); }
132 
137  inline size_type capacity() const { return this->_string.capacity(); }
138 
142  inline void push_back(char c) { return this->_string.push_back(c); }
143 
144  inline string& append(const string &s) { this->_string.append(s.str()); return *this; }
145  inline string& append(const char *s, size_t n) { this->_string.append(s, n); return *this; }
146 
150  inline void resize(size_type n) { return this->_string.resize(n); }
151 
155  inline iterator erase(const iterator &i) { return this->_string.erase(i); }
156  inline iterator erase(const iterator &first, const iterator &last) { return this->_string.erase(first, last); }
157  inline void erase(size_type pos = 0, size_type n = std::string::npos) { this->_string.erase(pos, n); }
158 
163  inline string& ltrim(const Anope::string &what = " \t\r\n")
164  {
165  while (!this->_string.empty() && what.find(this->_string[0]) != Anope::string::npos)
166  this->_string.erase(this->_string.begin());
167  return *this;
168  }
169 
170  inline string& rtrim(const Anope::string &what = " \t\r\n")
171  {
172  while (!this->_string.empty() && what.find(this->_string[this->_string.length() - 1]) != Anope::string::npos)
173  this->_string.erase(this->_string.length() - 1);
174  return *this;
175  }
176 
177  inline string& trim(const Anope::string &what = " \t\r\n")
178  {
179  this->ltrim(what);
180  this->rtrim(what);
181  return *this;
182  }
183 
187  inline void clear() { this->_string.clear(); }
188 
192  inline size_type find(const string &_str, size_type pos = 0) const { return this->_string.find(_str._string, pos); }
193  inline size_type find(char chr, size_type pos = 0) const { return this->_string.find(chr, pos); }
194  inline size_type find_ci(const string &_str, size_type pos = 0) const { return ci::string(this->_string.c_str()).find(ci::string(_str._string.c_str()), pos); }
195  inline size_type find_ci(char chr, size_type pos = 0) const { return ci::string(this->_string.c_str()).find(chr, pos); }
196 
197  inline size_type rfind(const string &_str, size_type pos = npos) const { return this->_string.rfind(_str._string, pos); }
198  inline size_type rfind(char chr, size_type pos = npos) const { return this->_string.rfind(chr, pos); }
199  inline size_type rfind_ci(const string &_str, size_type pos = npos) const { return ci::string(this->_string.c_str()).rfind(ci::string(_str._string.c_str()), pos); }
200  inline size_type rfind_ci(char chr, size_type pos = npos) const { return ci::string(this->_string.c_str()).rfind(chr, pos); }
201 
202  inline size_type find_first_of(const string &_str, size_type pos = 0) const { return this->_string.find_first_of(_str._string, pos); }
203  inline size_type find_first_of_ci(const string &_str, size_type pos = 0) const { return ci::string(this->_string.c_str()).find_first_of(ci::string(_str._string.c_str()), pos); }
204 
205  inline size_type find_first_not_of(const string &_str, size_type pos = 0) const { return this->_string.find_first_not_of(_str._string, pos); }
206  inline size_type find_first_not_of_ci(const string &_str, size_type pos = 0) const { return ci::string(this->_string.c_str()).find_first_not_of(ci::string(_str._string.c_str()), pos); }
207 
208  inline size_type find_last_of(const string &_str, size_type pos = npos) const { return this->_string.find_last_of(_str._string, pos); }
209  inline size_type find_last_of_ci(const string &_str, size_type pos = npos) const { return ci::string(this->_string.c_str()).find_last_of(ci::string(_str._string.c_str()), pos); }
210 
211  inline size_type find_last_not_of(const string &_str, size_type pos = npos) const { return this->_string.find_last_not_of(_str._string, pos); }
212  inline size_type find_last_not_of_ci(const string &_str, size_type pos = npos) const { return ci::string(this->_string.c_str()).find_last_not_of(ci::string(_str._string.c_str()), pos); }
213 
217  inline bool is_number_only() const { return this->find_first_not_of("0123456789.-") == npos; }
218  inline bool is_pos_number_only() const { return this->find_first_not_of("0123456789.") == npos; }
219 
223  inline string replace(size_type pos, size_type n, const string &_str) { return string(this->_string.replace(pos, n, _str._string)); }
224  inline string replace(size_type pos, size_type n, const string &_str, size_type pos1, size_type n1) { return string(this->_string.replace(pos, n, _str._string, pos1, n1)); }
225  inline string replace(size_type pos, size_type n, size_type n1, char chr) { return string(this->_string.replace(pos, n, n1, chr)); }
226  inline string replace(iterator first, iterator last, const string &_str) { return string(this->_string.replace(first, last, _str._string)); }
227  inline string replace(iterator first, iterator last, size_type n, char chr) { return string(this->_string.replace(first, last, n, chr)); }
228  template <class InputIterator> inline string replace(iterator first, iterator last, InputIterator f, InputIterator l) { return string(this->_string.replace(first, last, f, l)); }
229  inline string replace_all_cs(const string &_orig, const string &_repl) const
230  {
231  Anope::string new_string = *this;
232  size_type pos = new_string.find(_orig), orig_length = _orig.length(), repl_length = _repl.length();
233  while (pos != npos)
234  {
235  new_string = new_string.substr(0, pos) + _repl + new_string.substr(pos + orig_length);
236  pos = new_string.find(_orig, pos + repl_length);
237  }
238  return new_string;
239  }
240  inline string replace_all_ci(const string &_orig, const string &_repl) const
241  {
242  Anope::string new_string = *this;
243  size_type pos = new_string.find_ci(_orig), orig_length = _orig.length(), repl_length = _repl.length();
244  while (pos != npos)
245  {
246  new_string = new_string.substr(0, pos) + _repl + new_string.substr(pos + orig_length);
247  pos = new_string.find_ci(_orig, pos + repl_length);
248  }
249  return new_string;
250  }
251 
255  inline string lower() const
256  {
257  Anope::string new_string = *this;
258  for (size_type i = 0; i < new_string.length(); ++i)
259  new_string[i] = Anope::tolower(new_string[i]);
260  return new_string;
261  }
262 
266  inline string upper() const
267  {
268  Anope::string new_string = *this;
269  for (size_type i = 0; i < new_string.length(); ++i)
270  new_string[i] = Anope::toupper(new_string[i]);
271  return new_string;
272  }
273 
277  inline string substr(size_type pos = 0, size_type n = npos) const { return string(this->_string.substr(pos, n)); }
278 
282  inline iterator begin() { return this->_string.begin(); }
283  inline const_iterator begin() const { return this->_string.begin(); }
284  inline iterator end() { return this->_string.end(); }
285  inline const_iterator end() const { return this->_string.end(); }
286  inline reverse_iterator rbegin() { return this->_string.rbegin(); }
287  inline const_reverse_iterator rbegin() const { return this->_string.rbegin(); }
288  inline reverse_iterator rend() { return this->_string.rend(); }
289  inline const_reverse_iterator rend() const { return this->_string.rend(); }
290 
294  inline char &operator[](size_type n) { return this->_string[n]; }
295  inline const char &operator[](size_type n) const { return this->_string[n]; }
296 
300  friend std::ostream &operator<<(std::ostream &os, const string &_str);
301  friend std::istream &operator>>(std::istream &is, string &_str);
302  };
303 
304  inline std::ostream &operator<<(std::ostream &os, const string &_str) { return os << _str._string; }
305  /* This is not standard to make operator>> behave like operator<< in that it will allow extracting a whole line, not just one word */
306  inline std::istream &operator>>(std::istream &is, string &_str) { return std::getline(is, _str._string); }
307 
308  inline const string operator+(char chr, const string &str) { string tmp(chr); tmp += str; return tmp; }
309  inline const string operator+(const char *_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
310  inline const string operator+(const std::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
311 
312  struct hash_ci
313  {
314  inline size_t operator()(const string &s) const
315  {
316  return TR1NS::hash<std::string>()(s.lower().str());
317  }
318  };
319 
320  struct hash_cs
321  {
322  inline size_t operator()(const string &s) const
323  {
324  return TR1NS::hash<std::string>()(s.str());
325  }
326  };
327 
328  struct compare
329  {
330  inline bool operator()(const string &s1, const string &s2) const
331  {
332  return s1.equals_ci(s2);
333  }
334  };
335 
336  template<typename T> class map : public std::map<string, T, ci::less> { };
337  template<typename T> class multimap : public std::multimap<string, T, ci::less> { };
338  template<typename T> class hash_map : public TR1NS::unordered_map<string, T, hash_ci, compare> { };
339 
340  static const char *const compiled = __TIME__ " " __DATE__;
341 
344  extern CoreExport time_t StartTime;
345 
348  extern int ReturnValue;
349 
350  extern sig_atomic_t Signal;
351  extern CoreExport bool Quitting;
352  extern CoreExport bool Restarting;
354 
358  extern CoreExport time_t CurTime;
359 
362  extern CoreExport int Debug;
363 
367 
371 
375 
383 
386  extern CoreExport int CurrentUplink;
387 
390  extern CoreExport string Version();
391  extern CoreExport string VersionShort();
392  extern CoreExport string VersionBuildString();
393  extern CoreExport int VersionMajor();
394  extern CoreExport int VersionMinor();
395  extern CoreExport int VersionPatch();
396 
401  extern bool AtTerm();
402 
407  extern void Fork();
408 
411  extern void HandleSignal();
412 
418  extern void Init(int ac, char **av);
419 
422  extern CoreExport void SaveDatabases();
423 
430  extern CoreExport bool Match(const string &str, const string &mask, bool case_sensitive = false, bool use_regex = false);
431 
436  extern CoreExport string Hex(const string &data);
437  extern CoreExport string Hex(const char *data, unsigned len);
438 
443  extern CoreExport void Unhex(const string &src, string &dest);
444  extern CoreExport void Unhex(const string &src, char *dest, size_t sz);
445 
450  extern CoreExport void B64Encode(const string &src, string &target);
451 
456  extern CoreExport void B64Decode(const string &src, string &target);
457 
462  extern CoreExport void Encrypt(const Anope::string &src, Anope::string &dest);
463 
470  extern CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest);
471 
479  extern CoreExport string printf(const char *fmt, ...);
480 
484  extern CoreExport int LastErrorCode();
485 
489  extern CoreExport const string LastError();
490 
493  extern CoreExport bool IsFile(const Anope::string &file);
494 
499  extern CoreExport time_t DoTime(const Anope::string &s);
500 
506  extern CoreExport Anope::string Duration(time_t seconds, const NickCore *nc = NULL);
507 
513  extern CoreExport Anope::string Expires(time_t seconds, const NickCore *nc = NULL);
514 
520  extern CoreExport Anope::string strftime(time_t t, const NickCore *nc = NULL, bool short_output = false);
521 
527 
531  extern void Process(const Anope::string &);
532 
538  extern Anope::string Resolve(const Anope::string &host, int type);
539 
543  extern CoreExport Anope::string Random(size_t len);
544 }
545 
552 {
553  private:
559  char sep;
562  size_t pos;
566  public:
569  sepstream(const Anope::string &source, char seperator, bool allowempty = false);
570 
575  bool GetToken(Anope::string &token);
576 
582  bool GetToken(Anope::string &token, int num);
583 
587  template<typename T> void GetTokens(T& token)
588  {
589  token.clear();
590  Anope::string t;
591  while (this->GetToken(t))
592  token.push_back(t);
593  }
594 
600  bool GetTokenRemainder(Anope::string &token, int num);
601 
605  int NumTokens();
606 
610  const Anope::string GetRemaining();
611 
615  bool StreamEnd();
616 };
617 
620 class commasepstream : public sepstream
621 {
622  public:
625  commasepstream(const Anope::string &source, bool allowempty = false) : sepstream(source, ',', allowempty) { }
626 };
627 
630 class spacesepstream : public sepstream
631 {
632  public:
635  spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
636 };
637 
644 class CoreException : public std::exception
645 {
646  protected:
653  public:
656  CoreException() : err("Core threw an exception"), source("The core") { }
659  CoreException(const Anope::string &message) : err(message), source("The core") { }
663  CoreException(const Anope::string &message, const Anope::string &src) : err(message), source(src) { }
668  virtual ~CoreException() throw() { }
672  virtual const Anope::string &GetReason() const
673  {
674  return err;
675  }
676 
677  virtual const Anope::string &GetSource() const
678  {
679  return source;
680  }
681 };
682 
684 {
685  public:
688  ModuleException() : CoreException("Module threw an exception", "A Module") { }
689 
692  ModuleException(const Anope::string &message) : CoreException(message, "A Module") { }
697  virtual ~ModuleException() throw() { }
698 };
699 
701 {
702  public:
703  ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
704 
705  virtual ~ConvertException() throw() { }
706 };
707 
710 template<typename T> inline Anope::string stringify(const T &x)
711 {
712  std::ostringstream stream;
713 
714  if (!(stream << x))
715  throw ConvertException("Stringify fail");
716 
717  return stream.str();
718 }
719 
720 template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true)
721 {
722  leftover.clear();
723  std::istringstream i(s.str());
724  char c;
725  if (!(i >> x))
726  throw ConvertException("Convert fail");
727  if (failIfLeftoverChars)
728  {
729  if (i.get(c))
730  throw ConvertException("Convert fail");
731  }
732  else
733  {
734  std::string left;
735  getline(i, left);
736  leftover = left;
737  }
738 }
739 
740 template<typename T> inline void convert(const Anope::string &s, T &x, bool failIfLeftoverChars = true)
741 {
742  Anope::string Unused;
743  convert(s, x, Unused, failIfLeftoverChars);
744 }
745 
746 template<typename T> inline T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars = true)
747 {
748  T x;
749  convert(s, x, leftover, failIfLeftoverChars);
750  return x;
751 }
752 
753 template<typename T> inline T convertTo(const Anope::string &s, bool failIfLeftoverChars = true)
754 {
755  T x;
756  convert(s, x, failIfLeftoverChars);
757  return x;
758 }
759 
764 #ifdef DEBUG_BUILD
765 # include <typeinfo>
766 template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
767 {
768  T ret = dynamic_cast<T>(ptr);
769  if (ptr != NULL && ret == NULL)
770  throw CoreException(Anope::string("anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
771  return ret;
772 }
773 #else
774 template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
775 {
776  return static_cast<T>(ptr);
777 }
778 #endif
779 
780 #endif // ANOPE_H
bool operator()(const string &s1, const string &s2) const
Definition: anope.h:330
string & operator+=(const char *_str)
Definition: anope.h:93
CoreExport bool ReadOnly
Definition: main.cpp:28
char & operator[](size_type n)
Definition: anope.h:294
string & operator=(const std::string &_str)
Definition: anope.h:64
CoreExport Anope::string ModuleDir
Definition: init.cpp:33
bool equals_cs(const char *_str) const
Definition: anope.h:74
size_type find_first_of_ci(const string &_str, size_type pos=0) const
Definition: anope.h:203
CoreExport bool Restarting
Definition: main.cpp:35
size_t operator()(const string &s) const
Definition: anope.h:314
sig_atomic_t Signal
Definition: main.cpp:33
char sep
Definition: anope.h:559
void clear()
Definition: anope.h:187
string & append(const string &s)
Definition: anope.h:144
bool equals_cs(const std::string &_str) const
Definition: anope.h:75
string(InputIterator first, InputIterator last)
Definition: anope.h:57
std::string::size_type size_type
Definition: anope.h:43
bool is_pos_number_only() const
Definition: anope.h:218
std::string & str()
Definition: anope.h:119
size_t operator()(const string &s) const
Definition: anope.h:322
CoreExport bool NoThird
Definition: main.cpp:28
void Init(int ac, char **av)
Definition: init.cpp:284
CoreExport time_t StartTime
Definition: main.cpp:40
void push_back(char c)
Definition: anope.h:142
CoreExport string Version()
Definition: misc.cpp:625
CoreExport const string LastError()
Definition: misc.cpp:606
CoreExport bool IsFile(const Anope::string &file)
Definition: misc.cpp:266
string(const char *_str)
Definition: anope.h:52
ConvertException(const Anope::string &reason="")
Definition: anope.h:703
CoreException(const Anope::string &message, const Anope::string &src)
Definition: anope.h:663
CoreExport string printf(const char *fmt,...)
Definition: misc.cpp:536
bool equals_ci(const string &_str) const
Definition: anope.h:80
const char * data() const
Definition: anope.h:118
void GetTokens(T &token)
Definition: anope.h:587
int ReturnValue
Definition: main.cpp:32
bool allow_empty
Definition: anope.h:565
iterator erase(const iterator &first, const iterator &last)
Definition: anope.h:156
bool AtTerm()
Definition: init.cpp:98
size_type rfind_ci(char chr, size_type pos=npos) const
Definition: anope.h:200
ModuleException()
Definition: anope.h:688
virtual const Anope::string & GetSource() const
Definition: anope.h:677
size_type find_ci(char chr, size_type pos=0) const
Definition: anope.h:195
const_iterator end() const
Definition: anope.h:285
string replace(size_type pos, size_type n, size_type n1, char chr)
Definition: anope.h:225
string upper() const
Definition: anope.h:266
bool operator==(const string &_str) const
Definition: anope.h:72
size_type rfind(const string &_str, size_type pos=npos) const
Definition: anope.h:197
CoreExport int LastErrorCode()
Definition: misc.cpp:597
virtual ~ModuleException()
Definition: anope.h:697
CoreException()
Definition: anope.h:656
string & operator=(const string &_str)
Definition: anope.h:65
string & ltrim(const Anope::string &what=" \t\r\n")
Definition: anope.h:163
std::string::reverse_iterator reverse_iterator
Definition: anope.h:41
ModuleException(const Anope::string &message)
Definition: anope.h:692
bool equals_ci(const char *_str) const
Definition: anope.h:78
size_type find_first_of(const string &_str, size_type pos=0) const
Definition: anope.h:202
string lower() const
Definition: anope.h:255
CoreExport time_t CurTime
Definition: main.cpp:41
Anope::string source
Definition: anope.h:652
size_type find_first_not_of_ci(const string &_str, size_type pos=0) const
Definition: anope.h:206
commasepstream(const Anope::string &source, bool allowempty=false)
Definition: anope.h:625
CoreExport string Hex(const string &data)
Definition: misc.cpp:546
size_type rfind_ci(const string &_str, size_type pos=npos) const
Definition: anope.h:199
iterator erase(const iterator &i)
Definition: anope.h:155
size_type find_ci(const string &_str, size_type pos=0) const
Definition: anope.h:194
reverse_iterator rend()
Definition: anope.h:288
bool equals_cs(const string &_str) const
Definition: anope.h:76
string substr(size_type pos=0, size_type n=npos) const
Definition: anope.h:277
void Fork()
Definition: init.cpp:103
unsigned char tolower(unsigned char)
Definition: hashcomp.cpp:31
bool operator==(const char *_str) const
Definition: anope.h:70
Anope::string err
Definition: anope.h:649
CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest)
Definition: misc.cpp:518
size_type length() const
Definition: anope.h:131
CoreExport bool Quitting
Definition: main.cpp:34
void erase(size_type pos=0, size_type n=std::string::npos)
Definition: anope.h:157
string replace(iterator first, iterator last, size_type n, char chr)
Definition: anope.h:227
std::string _string
Definition: anope.h:34
CoreExport void B64Encode(const string &src, string &target)
Definition: base64.cpp:82
CoreExport bool Match(const string &str, const string &mask, bool case_sensitive=false, bool use_regex=false)
Definition: misc.cpp:407
bool operator<(const string &_str) const
Definition: anope.h:112
string replace(iterator first, iterator last, InputIterator f, InputIterator l)
Definition: anope.h:228
string & operator=(const char *_str)
Definition: anope.h:63
CoreExport Anope::string ServicesDir
Definition: main.cpp:29
string & operator=(char chr)
Definition: anope.h:62
CoreExport int VersionMajor()
Definition: misc.cpp:660
static const size_type npos
Definition: anope.h:44
CoreExport time_t DoTime(const Anope::string &s)
Definition: misc.cpp:275
bool operator==(const std::string &leftval, const ci::string &rightval)
Definition: hashcomp.h:171
const string operator+(const string &_str) const
Definition: anope.h:103
string replace_all_cs(const string &_orig, const string &_repl) const
Definition: anope.h:229
CoreExport void B64Decode(const string &src, string &target)
Definition: base64.cpp:123
string replace_all_ci(const string &_orig, const string &_repl) const
Definition: anope.h:240
CoreExport string VersionShort()
Definition: misc.cpp:634
const string operator+(char chr) const
Definition: anope.h:100
spacesepstream(const Anope::string &source)
Definition: anope.h:635
string & rtrim(const Anope::string &what=" \t\r\n")
Definition: anope.h:170
CoreException(const Anope::string &message)
Definition: anope.h:659
std::string::const_iterator const_iterator
Definition: anope.h:40
unsigned char toupper(unsigned char)
Definition: hashcomp.cpp:36
bool operator!=(const std::string &_str) const
Definition: anope.h:86
string & trim(const Anope::string &what=" \t\r\n")
Definition: anope.h:177
CoreExport Anope::string NormalizeBuffer(const Anope::string &)
Definition: misc.cpp:664
const char & operator[](size_type n) const
Definition: anope.h:295
bool empty() const
Definition: anope.h:126
string & operator+=(char chr)
Definition: anope.h:92
bool operator==(const std::string &_str) const
Definition: anope.h:71
string(const std::string &_str)
Definition: anope.h:54
string(const char *_str, size_type n)
Definition: anope.h:53
ci::string ci_str() const
Definition: anope.h:121
const std::string & str() const
Definition: anope.h:120
string(const ci::string &_str)
Definition: anope.h:55
string(char chr)
Definition: anope.h:50
string & operator+=(const std::string &_str)
Definition: anope.h:94
bool operator!=(const string &_str) const
Definition: anope.h:87
std::basic_string< char, ci_char_traits, std::allocator< char > > string
Definition: hashcomp.h:133
size_type find(char chr, size_type pos=0) const
Definition: anope.h:193
CoreExport Anope::string ServicesBin
Definition: main.cpp:30
CoreExport bool ProtocolDebug
Definition: main.cpp:28
CoreExport Anope::string Random(size_t len)
Definition: misc.cpp:754
CoreExport Anope::string LogDir
Definition: init.cpp:33
CoreExport string VersionBuildString()
Definition: misc.cpp:639
size_type find_first_not_of(const string &_str, size_type pos=0) const
Definition: anope.h:205
CoreExport Anope::string ConfigDir
Definition: init.cpp:33
std::string::const_reverse_iterator const_reverse_iterator
Definition: anope.h:42
size_type find_last_of_ci(const string &_str, size_type pos=npos) const
Definition: anope.h:209
Anope::string stringify(const T &x)
Definition: anope.h:710
#define CoreExport
Definition: services.h:62
size_type rfind(char chr, size_type pos=npos) const
Definition: anope.h:198
CoreExport int CurrentUplink
Definition: main.cpp:43
CoreExport Anope::string DataDir
Definition: init.cpp:33
void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars=true)
Definition: anope.h:720
string(size_type n, char chr)
Definition: anope.h:51
CoreExport bool NoExpire
Definition: main.cpp:28
void HandleSignal()
Definition: init.cpp:118
Anope::string Resolve(const Anope::string &host, int type)
Definition: misc.cpp:730
const string operator+(char chr, const string &str)
Definition: anope.h:308
Anope::string tokens
Definition: anope.h:556
iterator end()
Definition: anope.h:284
CoreExport int Debug
Definition: main.cpp:27
T anope_dynamic_static_cast(O ptr)
Definition: anope.h:774
string replace(size_type pos, size_type n, const string &_str, size_type pos1, size_type n1)
Definition: anope.h:224
Anope::string name
Definition: access.cpp:22
CoreExport Anope::string LocaleDir
Definition: init.cpp:33
virtual const Anope::string & GetReason() const
Definition: anope.h:672
std::string::iterator iterator
Definition: anope.h:39
CoreExport bool NoFork
Definition: main.cpp:28
std::istream & operator>>(std::istream &is, string &_str)
Definition: anope.h:306
CoreExport void Encrypt(const Anope::string &src, Anope::string &dest)
Definition: misc.cpp:511
string & operator+=(const string &_str)
Definition: anope.h:95
reverse_iterator rbegin()
Definition: anope.h:286
const char * c_str() const
Definition: anope.h:117
CoreExport int VersionPatch()
Definition: misc.cpp:662
size_t pos
Definition: anope.h:562
bool operator!=(const char *_str) const
Definition: anope.h:85
size_type capacity() const
Definition: anope.h:137
CoreExport Anope::string Duration(time_t seconds, const NickCore *nc=NULL)
Definition: misc.cpp:315
string replace(iterator first, iterator last, const string &_str)
Definition: anope.h:226
const_iterator begin() const
Definition: anope.h:283
bool equals_ci(const std::string &_str) const
Definition: anope.h:79
const_reverse_iterator rend() const
Definition: anope.h:289
CoreExport int VersionMinor()
Definition: misc.cpp:661
virtual ~ConvertException()
Definition: anope.h:705
void Process(const Anope::string &)
Definition: process.cpp:19
CoreExport Anope::string strftime(time_t t, const NickCore *nc=NULL, bool short_output=false)
Definition: misc.cpp:356
std::ostream & operator<<(std::ostream &os, const string &_str)
Definition: anope.h:304
string(const string &_str, size_type pos, size_type n=npos)
Definition: anope.h:56
T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars=true)
Definition: anope.h:746
CoreExport void SaveDatabases()
Definition: main.cpp:67
const string operator+(const char *_str) const
Definition: anope.h:101
iterator begin()
Definition: anope.h:282
size_type find_last_not_of(const string &_str, size_type pos=npos) const
Definition: anope.h:211
static const char *const compiled
Definition: anope.h:340
bool is_number_only() const
Definition: anope.h:217
size_type find(const string &_str, size_type pos=0) const
Definition: anope.h:192
size_type find_last_of(const string &_str, size_type pos=npos) const
Definition: anope.h:208
CoreExport Anope::string Expires(time_t seconds, const NickCore *nc=NULL)
Definition: misc.cpp:371
CoreExport Anope::string QuitReason
Definition: main.cpp:36
size_type find_last_not_of_ci(const string &_str, size_type pos=npos) const
Definition: anope.h:212
Definition: anope.h:20
string replace(size_type pos, size_type n, const string &_str)
Definition: anope.h:223
const_reverse_iterator rbegin() const
Definition: anope.h:287
void resize(size_type n)
Definition: anope.h:150
const string operator+(const std::string &_str) const
Definition: anope.h:102
virtual ~CoreException()
Definition: anope.h:668
string & append(const char *s, size_t n)
Definition: anope.h:145
CoreExport void Unhex(const string &src, string &dest)
Definition: misc.cpp:575