]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/inspircd.h
This is better, and proved working
[user/henk/code/inspircd.git] / include / inspircd.h
index 2224dca63f56aa8ed68b19488f6968aab3266682..678ebf0a5c1015d7e9b51bf694cd92829ef79b73 100644 (file)
@@ -62,9 +62,51 @@ template<typename T> inline void DELETE(T* x)
        x = NULL;
 }
 
-/** Template function to convert any input type to std::string
+/** Template functions to convert any input type to std::string
  */
-template<typename T> inline std::string ConvToStr(const T &in)
+template<typename T> inline std::string ConvNumeric(const T &in)
+{
+       char res[MAXBUF];
+       char* out = res;
+       T quotient = in;
+       while (quotient) {
+               *out = "0123456789"[ std::abs( (long)quotient % 10 ) ];
+               ++out;
+               quotient /= 10;
+       }
+       if ( in < 0)
+               *out++ = '-';
+       *out = 0;
+       std::reverse(res,out);
+       return res;
+}
+
+inline std::string ConvToStr(const int in)
+{
+       return ConvNumeric(in);
+}
+
+inline std::string ConvToStr(const long in)
+{
+       return ConvNumeric(in);
+}
+
+inline std::string ConvToStr(const unsigned long in)
+{
+       return ConvNumeric(in);
+}
+
+inline std::string ConvToStr(const char* in)
+{
+       return in;
+}
+
+inline std::string ConvToStr(const bool in)
+{
+       return (in ? "1" : "0");
+}
+
+template <class T> inline std::string ConvToStr(const T &in)
 {
        std::stringstream tmp;
        if (!(tmp << in)) return std::string();
@@ -894,7 +936,10 @@ class InspIRCd : public classbase
         * on if cached results are available and haven't expired. It is
         * however safe to force this value to false, forcing a remote DNS
         * lookup, but not an update of the cache.
-        * @return True if the resolver was added
+        * @return True if the operation completed successfully. Note that
+        * if this method returns true, you should not attempt to access
+        * the resolver class you pass it after this call, as depending upon
+        * the request given, the object may be deleted!
         */
         bool AddResolver(Resolver* r, bool cached);
 
@@ -1166,6 +1211,11 @@ class InspIRCd : public classbase
         */
        void RehashUsersAndChans();
 
+       /** Resets the cached max bans value on all channels.
+        * Called by rehash.
+        */
+       void ResetMaxBans();
+
        /** Begin execution of the server.
         * NOTE: this function NEVER returns. Internally,
         * after performing some initialisation routines,