]> git.stg.codes - stg.git/commitdiff
Remove x2str/unsigned2str in favor of std::to_string.
authorMaksym Mamontov <madf@madf.info>
Mon, 27 Jan 2020 20:53:35 +0000 (22:53 +0200)
committerMaksym Mamontov <madf@madf.info>
Mon, 27 Jan 2020 20:53:35 +0000 (22:53 +0200)
28 files changed:
libs/common/common.cpp
libs/common/include/stg/common.h
libs/json/include/stg/json_generator.h
libs/pinger/pinger.cpp
libs/srvconf/parsers/chg_admin.cpp
libs/srvconf/parsers/chg_tariff.cpp
libs/srvconf/parsers/get_tariff.cpp
libs/srvconf/parsers/get_user.cpp
libs/srvconf/parsers/server_info.cpp
sgconf/actions.h
sgconf/config.h
sgconf/users.cpp
stargazer/plugins/capture/nfqueue/nfqueue.cpp
stargazer/plugins/configuration/rpcconfig/user_helper.cpp
stargazer/plugins/configuration/sgconfig/conn.h
stargazer/plugins/configuration/sgconfig/dumphelpers.h
stargazer/plugins/configuration/sgconfig/parser_admins.cpp
stargazer/plugins/configuration/sgconfig/parser_server_info.cpp
stargazer/plugins/configuration/sgconfig/parser_services.cpp
stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp
stargazer/plugins/configuration/sgconfig/parser_user_info.cpp
stargazer/plugins/configuration/sgconfig/parser_users.cpp
stargazer/plugins/other/radius/config.cpp
stargazer/plugins/other/radius/radius.cpp
stargazer/plugins/other/smux/sensors.cpp
stargazer/plugins/other/smux/sensors.h
stargazer/plugins/store/files/file_store.cpp
stargazer/plugins/store/mysql/mysql_store.cpp

index 8cfcf402f7fb9888515ad08f63bfee12373e9d84..954fc3819626e40ccbcd0fb901158a44c6eb0210 100644 (file)
@@ -824,24 +824,6 @@ return 0;
 }
 #endif
 //---------------------------------------------------------------------------
-const std::string & x2str(uint32_t x, std::string & s)
-{
-return unsigned2str(x, s);
-}
-//---------------------------------------------------------------------------
-const std::string & x2str(uint64_t x, std::string & s)
-{
-return unsigned2str(x, s);
-}
-//---------------------------------------------------------------------------
-const std::string & x2str(double x, std::string & s)
-{
-char buf[256];
-snprintf(buf, sizeof(buf), "%f", x);
-s = buf;
-return s;
-}
-//---------------------------------------------------------------------------
 std::string & TrimL(std::string & val)
 {
 size_t pos = val.find_first_not_of(" \t");
@@ -1125,7 +1107,7 @@ std::string ToPrintable(const std::string & src)
         if (std::isprint(src[i]))
             dest += src[i];
         else
-            dest += "\\" + x2str(src[i]);
+            dest += "\\" + std::to_string(src[i]);
 
     return dest;
 }
index 94cf9f060a7eac50e4db38d41ffab9c7c720ec69..ca8c3b452a62e1bf8ae1e597700fa457df0b1d8c 100644 (file)
@@ -171,22 +171,9 @@ int str2x(const std::string & str, int64_t & x);
 int str2x(const std::string & str, uint64_t & x);
 #endif
 //-----------------------------------------------------------------------------
-const std::string & x2str(uint32_t x, std::string & s);
-const std::string & x2str(uint64_t x, std::string & s);
-//-----------------------------------------------------------------------------
-const std::string & x2str(double x, std::string & s);
-//-----------------------------------------------------------------------------
 
 template <typename varT>
 int str2x(const std::string & str, varT & x);
-template <typename varT>
-const std::string & x2str(varT x, std::string & s);
-template <typename varT>
-std::string x2str(varT x) { std::string s; return x2str(x, s); }
-template <typename varT>
-const std::string & unsigned2str(varT x, std::string & s);
-template <typename varT>
-std::string unsigned2str(varT x) { std::string s; return unsigned2str(x, s); }
 
 //-----------------------------------------------------------------------------
 template <typename varT>
@@ -227,89 +214,6 @@ int str2x(const std::string & str, varT & x)
     return 0;
 }
 //-----------------------------------------------------------------------------
-template <typename varT>
-inline
-const std::string & x2str(varT x, std::string & s)
-{
-    varT xx = x;
-    int pos = 1;
-
-    x /= 10;
-    while (x != 0)
-    {
-        x /= 10;
-        pos++;
-    }
-
-    if (xx < 0)
-    {
-        pos++;
-        s.resize(pos, 0);
-        s[0] = '-';
-    }
-    else if (xx > 0)
-    {
-        s.resize(pos, 0);
-    }
-    else
-    {
-        s.resize(1, 0);
-        s[0] = '0';
-        return s;
-    }
-
-    x = xx;
-
-    while (x != 0)
-    {
-        if (x < 0)
-            s[--pos] = -(x % 10) + '0';
-        else
-            s[--pos] = x % 10 + '0';
-
-        x /= 10;
-    }
-
-    return s;
-}
-//-----------------------------------------------------------------------------
-template <typename varT>
-inline
-const std::string & unsigned2str(varT x, std::string & s)
-{
-    varT xx = x;
-    int pos = 1;
-
-    x /= 10;
-    while (x != 0)
-    {
-        x /= 10;
-        pos++;
-    }
-
-    if (xx > 0)
-    {
-        s.resize(pos, 0);
-    }
-    else
-    {
-        s.resize(1, 0);
-        s[0] = '0';
-        return s;
-    }
-
-    x = xx;
-
-    while (x != 0)
-    {
-        s[--pos] = x % 10 + '0';
-
-        x /= 10;
-    }
-
-    return s;
-}
-//-----------------------------------------------------------------------------
 char * stg_strptime(const char *, const char *, struct tm *);
 time_t stg_timegm(struct tm *);
 
index 4f1523fc92f61929616adc4971aa13ae3ef60fb4..831b0e05a931d7735c1f410623995e1c6cd353a2 100644 (file)
@@ -69,7 +69,7 @@ class NumberGen : public Gen
     public:
         explicit NumberGen(const std::string& value) : m_value(value) {}
         template <typename T>
-        explicit NumberGen(const T& value) : m_value(x2str(value)) {}
+        explicit NumberGen(const T& value) : m_value(std::to_string(value)) {}
         virtual void run(yajl_gen_t* handle) const;
     private:
         std::string m_value;
index 1689e29403b89c6dd22a0d88fb5dd491d0ec055e..07415812a6bbf61f831b9f797cb16fbad8573f9f 100644 (file)
@@ -174,8 +174,7 @@ while (iter != pingIP.end())
     {
     uint32_t ip = iter->first;
     time_t t = iter->second;
-    std::string s;
-    x2str(t, s);
+    std::string s = std::to_string(t);
     printf("ip = %s, time = %9s\n", inet_ntostring(ip).c_str(), s.c_str());
     ++iter;
     }
index 14679dff6f04c8d0c61d2d6bc6b914ff1e450279..ca2d800367a5cba7781da887772e3adc9dd8b5bf 100644 (file)
@@ -35,6 +35,6 @@ if (!conf.login.empty())
 if (!conf.password.empty())
     params += " password=\"" + conf.password.data() + "\"";
 if (!conf.priv.empty())
-    params += " priv=\"" + unsigned2str(conf.priv.data().ToInt()) + "\"";
+    params += " priv=\"" + std::to_string(conf.priv.data().ToInt()) + "\"";
 return params;
 }
index 16c4b198dbf1d4e605de0a51d22c39f46abf8d4e..d0fc13a7baf4b0e83e7abd3c07b381b3fcc078a1 100644 (file)
@@ -44,7 +44,7 @@ for (typename A::size_type i = 0; i < array.size(); ++i)
         return;
     if (!res.empty())
         res += "/";
-    res += x2str((array[i].*field).data());
+    res += std::to_string((array[i].*field).data());
     }
 stream << "<" << name << " value=\"" << res << "\"/>";
 }
index 7a6f9053c55811b272e304ea44f2e2b9464e3c54..b7acafa5cab530435db0d92dde15beb815ca2616 100644 (file)
@@ -153,7 +153,7 @@ GET_TARIFF::PARSER::PARSER(CALLBACK f, void * d, const std::string & e)
     AddParser(propertyParsers, "changePolicy", info.tariffConf.changePolicy, GetChangePolicy);
     AddParser(propertyParsers, "changePolicyTimeout", info.tariffConf.changePolicyTimeout);
     for (size_t i = 0; i < DIR_NUM; ++i)
-        AddParser(propertyParsers, "time" + unsigned2str(i), info.dirPrice[i], GetTimeSpan);
+        AddParser(propertyParsers, "time" + std::to_string(i), info.dirPrice[i], GetTimeSpan);
     AddAOSParser(propertyParsers, "priceDayA", info.dirPrice, &DIRPRICE_DATA::priceDayA, GetSlashedValue);
     AddAOSParser(propertyParsers, "priceDayB", info.dirPrice, &DIRPRICE_DATA::priceDayB, GetSlashedValue);
     AddAOSParser(propertyParsers, "priceNightA", info.dirPrice, &DIRPRICE_DATA::priceNightA, GetSlashedValue);
index 03327c4dc588a6f9c4d2c86fbcb2d373957ea4d2..30005626242dddfdab5b88b0b29a4952222e9eb0 100644 (file)
@@ -41,10 +41,10 @@ if (!attr)
 std::map<std::string, long long *> props;
 for (size_t i = 0; i < DIR_NUM; ++i)
     {
-    props.insert(std::pair<std::string, long long *>("su" + unsigned2str(i), &value.su[i]));
-    props.insert(std::pair<std::string, long long *>("sd" + unsigned2str(i), &value.sd[i]));
-    props.insert(std::pair<std::string, long long *>("mu" + unsigned2str(i), &value.mu[i]));
-    props.insert(std::pair<std::string, long long *>("md" + unsigned2str(i), &value.md[i]));
+    props.insert(std::pair<std::string, long long *>("su" + std::to_string(i), &value.su[i]));
+    props.insert(std::pair<std::string, long long *>("sd" + std::to_string(i), &value.sd[i]));
+    props.insert(std::pair<std::string, long long *>("mu" + std::to_string(i), &value.mu[i]));
+    props.insert(std::pair<std::string, long long *>("md" + std::to_string(i), &value.md[i]));
     }
 size_t pos = 0;
 while (attr[pos])
@@ -95,7 +95,7 @@ GET_USER::PARSER::PARSER(CALLBACK f, void * d, const std::string & e)
     AddParser(propertyParsers, "lastActivityTime", info.lastActivityTime);
 
     for (size_t i = 0; i < USERDATA_NUM; ++i)
-        AddParser(propertyParsers, "userData" + unsigned2str(i), info.userData[i], "koi8-ru", GetEncodedValue);
+        AddParser(propertyParsers, "userData" + std::to_string(i), info.userData[i], "koi8-ru", GetEncodedValue);
 }
 //-----------------------------------------------------------------------------
 GET_USER::PARSER::~PARSER()
index f00336115323c24b2f43a9831e15fccecdaed955..86211971072a4000c12b7363cbd6c72b080a1df5 100644 (file)
@@ -44,7 +44,7 @@ SERVER_INFO::PARSER::PARSER(CALLBACK f, void * d, const std::string & e)
     AddParser(propertyParsers, "tariff_num", info.tariffNum);
 
     for (size_t i = 0; i < DIR_NUM; i++)
-        AddParser(propertyParsers, "dir_name_" + unsigned2str(i), info.dirName[i], GetEncodedValue);
+        AddParser(propertyParsers, "dir_name_" + std::to_string(i), info.dirName[i], GetEncodedValue);
 }
 //-----------------------------------------------------------------------------
 int SERVER_INFO::PARSER::ParseStart(const char *el, const char **attr)
index 08dc177eb9d3eadc575a3427260eec6d4aba376a..69407de22f54f6e40c76efae9367c5f1637d7be9 100644 (file)
@@ -109,7 +109,7 @@ template <typename T>
 inline
 std::string PARAM_ACTION<T>::DefaultDescription() const
 {
-return m_hasDefault ? " (default: '" + x2str(m_defaltValue) + "')"
+return m_hasDefault ? " (default: '" + std::to_string(m_defaltValue) + "')"
                     : "";
 }
 
index 271837cc9d341309d60f8f9da228e88a215e4dbf..bb4f360a4bebfec29c6b357ec6a4e6657ac83707 100644 (file)
@@ -70,11 +70,11 @@ struct CONFIG
     if (!server.empty())
         res += "server: '" + server.data() + "'\n";
     if (!port.empty())
-        res += "port: " + x2str(port.data()) + "\n";
+        res += "port: " + std::to_string(port.data()) + "\n";
     if (!localAddress.empty())
         res += "local address: '" + localAddress.data() + "'\n";
     if (!localPort.empty())
-        res += "local port: " + x2str(localPort.data()) + "\n";
+        res += "local port: " + std::to_string(localPort.data()) + "\n";
     if (!userName.empty())
         res += "userName: '" + userName.data() + "'\n";
     if (!userPass.empty())
index 018556df5d18895b2d985c514cbf6e393436964c..4fcd3559ae232a59a552d2260a21ff458215d36e 100644 (file)
@@ -189,7 +189,7 @@ void ConvSessionTraff(std::string value, USER_STAT_RES & res)
 value.erase(std::remove(value.begin(), value.end(), ' '), value.end());
 std::vector<TRAFF> traff(Split<std::vector<TRAFF> >(value, ',', ConvTraff));
 if (traff.size() != DIR_NUM)
-    throw SGCONF::ACTION::ERROR("There should be prcisely " + x2str(DIR_NUM) + " records of session traffic.");
+    throw SGCONF::ACTION::ERROR("There should be prcisely " + std::to_string(DIR_NUM) + " records of session traffic.");
 for (size_t i = 0; i < DIR_NUM; ++i)
     {
     res.sessionUp[i] = traff[i].up;
@@ -202,7 +202,7 @@ void ConvMonthTraff(std::string value, USER_STAT_RES & res)
 value.erase(std::remove(value.begin(), value.end(), ' '), value.end());
 std::vector<TRAFF> traff(Split<std::vector<TRAFF> >(value, ',', ConvTraff));
 if (traff.size() != DIR_NUM)
-    throw SGCONF::ACTION::ERROR("There should be prcisely " + x2str(DIR_NUM) + " records of month traffic.");
+    throw SGCONF::ACTION::ERROR("There should be prcisely " + std::to_string(DIR_NUM) + " records of month traffic.");
 for (size_t i = 0; i < DIR_NUM; ++i)
     {
     res.monthUp[i] = traff[i].up;
index 0c14c10f570f44e932fc42eab7238e351a772daa..e0248df632d820256082609e67caddeef1f161ef 100644 (file)
@@ -146,14 +146,14 @@ if (nfq_bind_pf(nfqHandle, AF_INET) < 0)
 queueHandle = nfq_create_queue(nfqHandle, queueNumber, &Callback, this);
 if (queueHandle == NULL)
     {
-    errorStr = "Failed to create queue " + x2str(queueNumber) + ".";
+    errorStr = "Failed to create queue " + std::to_string(queueNumber) + ".";
     logger(errorStr);
     return -1;
     }
 
 if (nfq_set_mode(queueHandle, NFQNL_COPY_PACKET, 0xffFF) < 0)
     {
-    errorStr = "Failed to set queue " + x2str(queueNumber) + " mode.";
+    errorStr = "Failed to set queue " + std::to_string(queueNumber) + " mode.";
     logger(errorStr);
     return -1;
     }
index ac6e72615a95e43ec6da8feacc7fe796be59f042..d101e297dc0fc34e356131df1d7b90025d35b072 100644 (file)
@@ -94,15 +94,10 @@ supload = ptr->GetSessionDownload();
 
 for (int j = 0; j < DIR_NUM; j++)
     {
-    std::string value;
-    x2str(upload[j], value);
-    mu[j] = xmlrpc_c::value_string(value);
-    x2str(download[j], value);
-    md[j] = xmlrpc_c::value_string(value);
-    x2str(supload[j], value);
-    su[j] = xmlrpc_c::value_string(value);
-    x2str(sdownload[j], value);
-    sd[j] = xmlrpc_c::value_string(value);
+    mu[j] = xmlrpc_c::value_string(std::to_string(upload[j]));
+    md[j] = xmlrpc_c::value_string(std::to_string(download[j]));
+    su[j] = xmlrpc_c::value_string(std::to_string(supload[j]));
+    sd[j] = xmlrpc_c::value_string(std::to_string(sdownload[j]));
     }
 
 traffInfo["mu"] = xmlrpc_c::value_array(mu);
index 9f56c4df19cc0ff4662abaceb51f183010535a65..e38588114191c53849273f8fe8ef9912dde0725d 100644 (file)
@@ -65,7 +65,7 @@ class Conn
         uint32_t IP() const { return *(uint32_t *)(&m_addr.sin_addr); }
         uint16_t Port() const { return ntohs(m_addr.sin_port); }
 
-        std::string endpoint() const { return inet_ntostring(IP()) + ":" + x2str(Port()); }
+        std::string endpoint() const { return inet_ntostring(IP()) + ":" + std::to_string(Port()); }
 
         bool Read();
 
index cc02d14d64c471b0c51025912d623536ebfb0833..86bf197e0d22d6941ce788b1ff6013d305505786 100644 (file)
@@ -73,13 +73,13 @@ class Dumper
 
         std::string twoDigit(int value) const
         {
-            std::string res = x2str(value);
+            std::string res = std::to_string(value);
             if (res.length() < 2)
                 res = "0" + res;
             return res;
         }
 };
 
-} // namespace Caster
+} // namespace STG
 
 #endif
index 0db867bb3e680e1132e59a7c7a1aaaac29a0891f..f3a9aa31f24ea1994826af8190da47f801a03410 100644 (file)
@@ -57,7 +57,7 @@ void GET_ADMINS::CreateAnswer()
                          (ac.priv.userAddDel << 8) +
                          (ac.priv.adminChg << 10) +
                          (ac.priv.tariffChg << 12);
-        m_answer += "<admin login=\"" + ac.login + "\" priv=\"" + x2str(p) + "\"/>";
+        m_answer += "<admin login=\"" + ac.login + "\" priv=\"" + std::to_string(p) + "\"/>";
     }
     m_admins.CloseSearch(h);
     m_answer += "</Admins>";
index 75be7537ba85359cdc27aed00bd533c68d01b626..1b47d571bcc6222202577d22267da29adc4a42c6 100644 (file)
@@ -47,15 +47,15 @@ void GET_SERVER_INFO::CreateAnswer()
                        utsn.nodename;
 
     m_answer = std::string("<ServerInfo><version value=\"") + SERVER_VERSION + "\"/>" +
-               "<tariff_num value=\"" + x2str(m_tariffs.Count()) + "\"/>" +
+               "<tariff_num value=\"" + std::to_string(m_tariffs.Count()) + "\"/>" +
                "<tariff value=\"2\"/>" +
-               "<user_num value=\"" + x2str(m_users.Count()) + "\"/>" +
+               "<user_num value=\"" + std::to_string(m_users.Count()) + "\"/>" +
                "<uname value=\"" + name + "\"/>" +
-               "<dir_num value=\"" + x2str(DIR_NUM) + "\"/>" +
-               "<day_fee value=\"" + x2str(m_settings.GetDayFee()) + "\"/>";
+               "<dir_num value=\"" + std::to_string(DIR_NUM) + "\"/>" +
+               "<day_fee value=\"" + std::to_string(m_settings.GetDayFee()) + "\"/>";
 
     for (size_t i = 0; i< DIR_NUM; i++)
-        m_answer += "<dir_name_" + x2str(i) + " value=\"" + Encode12str(m_settings.GetDirName(i)) + "\"/>";
+        m_answer += "<dir_name_" + std::to_string(i) + " value=\"" + Encode12str(m_settings.GetDirName(i)) + "\"/>";
 
     m_answer += "</ServerInfo>";
 }
index a9599d54953a2bfdd5d56121be28e191a53fb280..b8a0977576f48d77577a675414ec01d750800c86 100644 (file)
@@ -53,8 +53,8 @@ void GET_SERVICES::CreateAnswer()
     {
         m_answer += "<Service name=\"" + conf.name +
                     "\" comment=\"" + Encode12str(conf.comment) +
-                    "\" cost=\"" + x2str(conf.cost) +
-                    "\" payDay=\"" + x2str(conf.payDay) + "\"/>";
+                    "\" cost=\"" + std::to_string(conf.cost) +
+                    "\" payDay=\"" + std::to_string(conf.payDay) + "\"/>";
     }
     m_services.CloseSearch(h);
     m_answer += "</Services>";
@@ -86,8 +86,8 @@ void GET_SERVICE::CreateAnswer()
     else
         m_answer += "<" + m_tag + " name=\"" + conf.name +
                     "\" comment=\"" + Encode12str(conf.comment) +
-                    "\" cost=\"" + x2str(conf.cost) +
-                    "\" payDay=\"" + x2str(conf.payDay) + "\"/>";
+                    "\" cost=\"" + std::to_string(conf.cost) +
+                    "\" payDay=\"" + std::to_string(conf.payDay) + "\"/>";
 }
 
 int ADD_SERVICE::Start(void *, const char * el, const char ** attr)
index 9c75267480e9591544e920ddb2b28788ff3f08ac..dfe6b55212cac49b498222d7889a374718b9d425 100644 (file)
@@ -51,7 +51,7 @@ std::string AOS2String(const A & array, size_t size, const F C::* field, F multi
     {
         if (!res.empty())
             res += "/";
-        res += x2str((array[i].*field) * multiplier);
+        res += std::to_string((array[i].*field) * multiplier);
     }
     return res;
 }
@@ -98,9 +98,9 @@ void GET_TARIFFS::CreateAnswer()
         m_answer += "<tariff name=\"" + it->tariffConf.name + "\">";
 
         for (size_t i = 0; i < DIR_NUM; i++)
-            m_answer += "<Time" + x2str(i) + " value=\"" +
-                x2str(it->dirPrice[i].hDay)   + ":" + x2str(it->dirPrice[i].mDay)   + "-" +
-                x2str(it->dirPrice[i].hNight) + ":" + x2str(it->dirPrice[i].mNight) + "\"/>";
+            m_answer += "<Time" + std::to_string(i) + " value=\"" +
+                std::to_string(it->dirPrice[i].hDay)   + ":" + std::to_string(it->dirPrice[i].mDay)   + "-" +
+                std::to_string(it->dirPrice[i].hNight) + ":" + std::to_string(it->dirPrice[i].mNight) + "\"/>";
 
         m_answer += "<PriceDayA value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceDayA, pt_mega) + "\"/>" +
                   "<PriceDayB value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::priceDayB, pt_mega) + "\"/>" +
@@ -109,13 +109,13 @@ void GET_TARIFFS::CreateAnswer()
                   "<Threshold value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::threshold, 1) + "\"/>" +
                   "<SinglePrice value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::singlePrice, 1) + "\"/>" +
                   "<NoDiscount value=\"" + AOS2String(it->dirPrice, DIR_NUM, &DIRPRICE_DATA::noDiscount, 1) + "\"/>" +
-                  "<Fee value=\"" + x2str(it->tariffConf.fee) + "\"/>" +
-                  "<PassiveCost value=\"" + x2str(it->tariffConf.passiveCost) + "\"/>" +
-                  "<Free value=\"" + x2str(it->tariffConf.free) + "\"/>" +
+                  "<Fee value=\"" + std::to_string(it->tariffConf.fee) + "\"/>" +
+                  "<PassiveCost value=\"" + std::to_string(it->tariffConf.passiveCost) + "\"/>" +
+                  "<Free value=\"" + std::to_string(it->tariffConf.free) + "\"/>" +
                   "<TraffType value=\"" + TARIFF::TraffTypeToString(it->tariffConf.traffType) + "\"/>" +
                   "<Period value=\"" + TARIFF::PeriodToString(it->tariffConf.period) + "\"/>" +
                   "<ChangePolicy value=\"" + TARIFF::ChangePolicyToString(it->tariffConf.changePolicy) + "\"/>" +
-                  "<ChangePolicyTimeout value=\"" + x2str(it->tariffConf.changePolicyTimeout) + "\"/>" +
+                  "<ChangePolicyTimeout value=\"" + std::to_string(it->tariffConf.changePolicyTimeout) + "\"/>" +
                   "</tariff>";
         }
 
index 89dd3883a1ae56e4f85c348cbb5dda50c2de871d..91de27ac8de401ff01f345d87ac2339ba9e4ae5f 100644 (file)
@@ -50,8 +50,8 @@ void USER_INFO::CreateAnswer()
         return;
     }
 
-    m_answer = "<UserInfo lastAuthTime=\"" + x2str(u->GetAuthorizedModificationTime()) + "\"" +
-             " lastDisconnectTime=\"" + x2str(u->GetConnectedModificationTime()) + "\"" +
+    m_answer = "<UserInfo lastAuthTime=\"" + std::to_string(u->GetAuthorizedModificationTime()) + "\"" +
+             " lastDisconnectTime=\"" + std::to_string(u->GetConnectedModificationTime()) + "\"" +
              " connected=\"" + (u->GetConnected() ? "true" : "false") + "\"" +
              " lastDisconnectReason=\"" + u->GetLastDisconnectReason() + "\">";
     std::vector<std::string> list(u->GetAuthorizers());
index 5707b726200e97b5792646496667f6ffe7aa2755..4f9d3021be135cd09fa8a2c7e46f577423bfa327 100644 (file)
@@ -67,11 +67,11 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
     }
 
     if (user.GetProperty().cash.ModificationTime() > lastTime)
-        answer += "<Cash value=\"" + x2str(user.GetProperty().cash.Get()) + "\"/>";
+        answer += "<Cash value=\"" + std::to_string(user.GetProperty().cash.Get()) + "\"/>";
     if (user.GetProperty().freeMb.ModificationTime() > lastTime)
-        answer += "<FreeMb value=\"" + x2str(user.GetProperty().freeMb.Get()) + "\"/>";
+        answer += "<FreeMb value=\"" + std::to_string(user.GetProperty().freeMb.Get()) + "\"/>";
     if (user.GetProperty().credit.ModificationTime() > lastTime)
-        answer += "<Credit value=\"" + x2str(user.GetProperty().credit.Get()) + "\"/>";
+        answer += "<Credit value=\"" + std::to_string(user.GetProperty().credit.Get()) + "\"/>";
 
     if (user.GetProperty().nextTariff.Get() != "")
     {
@@ -108,7 +108,7 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
 
     for (size_t i = 0; i < userdata.size(); i++)
         if (userdata[i]->ModificationTime() > lastTime)
-            answer += "<UserData" + x2str(i) + " value=\"" + Encode12str(userdata[i]->Get()) + "\" />";
+            answer += "<UserData" + std::to_string(i) + " value=\"" + Encode12str(userdata[i]->Get()) + "\" />";
 
     if (user.GetProperty().realName.ModificationTime() > lastTime)
         answer += "<Name value=\"" + Encode12str(user.GetProperty().realName) + "\"/>";
@@ -121,7 +121,7 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
     if (user.GetCurrIPModificationTime() > lastTime)
         answer += "<CurrIP value=\"" + inet_ntostring(user.GetCurrIP()) + "\"/>";
     if (user.GetPingTime() > lastTime)
-        answer += "<PingTime value=\"" + x2str(user.GetPingTime()) + "\"/>";
+        answer += "<PingTime value=\"" + std::to_string(user.GetPingTime()) + "\"/>";
     if (user.GetProperty().ips.ModificationTime() > lastTime)
         answer += "<IP value=\"" + user.GetProperty().ips.Get().GetIpStr() + "\"/>";
 
@@ -130,16 +130,16 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
     const DIR_TRAFF & download(user.GetProperty().down.Get());
     if (user.GetProperty().up.ModificationTime() > lastTime)
         for (size_t j = 0; j < DIR_NUM; j++)
-            answer += " MU" + x2str(j) + "=\"" + x2str(upload[j]) + "\"";
+            answer += " MU" + std::to_string(j) + "=\"" + std::to_string(upload[j]) + "\"";
     if (user.GetProperty().down.ModificationTime() > lastTime)
         for (size_t j = 0; j < DIR_NUM; j++)
-            answer += " MD" + x2str(j) + "=\"" + x2str(download[j]) + "\"";
+            answer += " MD" + std::to_string(j) + "=\"" + std::to_string(download[j]) + "\"";
     if (user.GetSessionUploadModificationTime() > lastTime)
         for (size_t j = 0; j < DIR_NUM; j++)
-            answer += " SU" + x2str(j) + "=\"" + x2str(user.GetSessionUpload()[j]) + "\"";
+            answer += " SU" + std::to_string(j) + "=\"" + std::to_string(user.GetSessionUpload()[j]) + "\"";
     if (user.GetSessionDownloadModificationTime() > lastTime)
         for (size_t j = 0; j < DIR_NUM; j++)
-            answer += " SD" + x2str(j) + "=\"" + x2str(user.GetSessionDownload()[j]) + "\"";
+            answer += " SD" + std::to_string(j) + "=\"" + std::to_string(user.GetSessionDownload()[j]) + "\"";
     answer += "/>";
 
     if (user.GetProperty().disabled.ModificationTime() > lastTime)
@@ -149,13 +149,13 @@ std::string UserToXML(const USER & user, bool loginInStart, bool showPass, time_
     if (user.GetProperty().passive.ModificationTime() > lastTime)
         answer += std::string("<Passive value=\"") + (user.GetProperty().passive.Get() ? "1" : "0") + "\"/>";
     if (user.GetProperty().lastCashAdd.ModificationTime() > lastTime)
-        answer += "<LastCash value=\"" + x2str(user.GetProperty().lastCashAdd.Get()) + "\"/>";
+        answer += "<LastCash value=\"" + std::to_string(user.GetProperty().lastCashAdd.Get()) + "\"/>";
     if (user.GetProperty().lastCashAddTime.ModificationTime() > lastTime)
-        answer += "<LastTimeCash value=\"" + x2str(user.GetProperty().lastCashAddTime.Get()) + "\"/>";
+        answer += "<LastTimeCash value=\"" + std::to_string(user.GetProperty().lastCashAddTime.Get()) + "\"/>";
     if (user.GetProperty().lastActivityTime.ModificationTime() > lastTime)
-        answer += "<LastActivityTime value=\"" + x2str(user.GetProperty().lastActivityTime.Get()) + "\"/>";
+        answer += "<LastActivityTime value=\"" + std::to_string(user.GetProperty().lastActivityTime.Get()) + "\"/>";
     if (user.GetProperty().creditExpire.ModificationTime() > lastTime)
-        answer += "<CreditExpire value=\"" + x2str(user.GetProperty().creditExpire.Get()) + "\"/>";
+        answer += "<CreditExpire value=\"" + std::to_string(user.GetProperty().creditExpire.Get()) + "\"/>";
 
     if (lastTime == 0)
     {
@@ -197,7 +197,7 @@ void GET_USERS::CreateAnswer()
     assert(h);
 
     if (m_lastUserUpdateTime > 0)
-        m_answer = "<Users LastUpdate=\"" + x2str(time(NULL)) + "\">";
+        m_answer = "<Users LastUpdate=\"" + std::to_string(time(NULL)) + "\">";
     else
         m_answer = "<Users>";
 
index 79822852a8ec9a59d2102d84929bb30e7e2740f0..0b486b349ece6e617a8254d357e919e34c9985b3 100644 (file)
@@ -41,7 +41,7 @@ struct ParserError : public std::runtime_error
           error(message)
     {}
     ParserError(size_t pos, const std::string& message)
-        : runtime_error("Parsing error at position " + x2str(pos) + ". " + message),
+        : runtime_error("Parsing error at position " + std::to_string(pos) + ". " + message),
           position(pos),
           error(message)
     {}
index 45a9d0e19446f80054df4c9bdf972b0ba79ef73f..ad9135a599331ada7b4f4aa41d6b0d1e21d79a0d 100644 (file)
@@ -362,7 +362,7 @@ void RADIUS::acceptTCP()
         m_logger(m_error);
         return;
     }
-    std::string remote = inet_ntostring(addr.sin_addr.s_addr) + ":" + x2str(ntohs(addr.sin_port));
+    std::string remote = inet_ntostring(addr.sin_addr.s_addr) + ":" + std::to_string(ntohs(addr.sin_port));
     printfd(__FILE__, "New TCP connection: '%s'\n", remote.c_str());
     m_conns.push_back(new Conn(*m_users, m_logger, *this, m_config, res, remote));
 }
index f52a413b7aeff6543e3a4ccf32da5e67012cc0cf..21e48ddc5f6ccc89d7d75a7b3ecfb243d89dafdd 100644 (file)
@@ -41,9 +41,7 @@ while (!users.SearchNext(handle, &user))
 
 users.CloseSearch(handle);
 
-std::string res;
-x2str(count, res);
-return res;
+return std::to_string(count);
 }
 #endif
 
index 35de996cb3377f4ef48189f639a7a27df70e505f..4cecfe076b822ed1d78ee27f1519b877f34496a9 100644 (file)
@@ -40,7 +40,7 @@ class TotalUsersSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(users.Count(), res); return res; }
+        { std::string res; std::to_string(users.Count(), res); return res; }
 #endif
 
     private:
@@ -185,7 +185,7 @@ class TotalTariffsSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(tariffs.Count(), res); return res; }
+        { std::string res; std::to_string(tariffs.Count(), res); return res; }
 #endif
 
     private:
@@ -205,7 +205,7 @@ class TotalAdminsSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(admins.Count(), res); return res; }
+        { std::string res; std::to_string(admins.Count(), res); return res; }
 #endif
 
     private:
@@ -225,7 +225,7 @@ class TotalServicesSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(services.Count(), res); return res; }
+        { std::string res; std::to_string(services.Count(), res); return res; }
 #endif
 
     private:
@@ -245,7 +245,7 @@ class TotalCorporationsSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(corporations.Count(), res); return res; }
+        { std::string res; std::to_string(corporations.Count(), res); return res; }
 #endif
 
     private:
@@ -265,7 +265,7 @@ class TotalRulesSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(traffcounter.RulesCount(), res); return res; }
+        { std::string res; std::to_string(traffcounter.RulesCount(), res); return res; }
 #endif
 
     private:
@@ -283,7 +283,7 @@ class ConstSensor : public Sensor {
 
 #ifdef DEBUG
         std::string ToString() const
-        { std::string res; x2str(value, res); return res; }
+        { std::string res; std::to_string(value, res); return res; }
 #endif
 
     private:
index 4c95aa31da4bb9b30e19ba31e34393a5a0c8da0f..39a05f4efbb9db02a0a63cb0191b5f7a1612e168 100644 (file)
@@ -1840,9 +1840,8 @@ stIter = statTree.begin();
 
 while (stIter != statTree.end())
     {
-    std::string u, d;
-    x2str(stIter->second.up, u);
-    x2str(stIter->second.down, d);
+    const auto u = std::to_string(stIter->second.up);
+    const auto d = std::to_string(stIter->second.down);
     #ifdef TRAFF_STAT_WITH_PORTS
     if (fprintf(statFile, "%17s:%hu\t%15d\t%15s\t%15s\t%f\n",
                 inet_ntostring(stIter->first.ip).c_str(),
@@ -1944,12 +1943,10 @@ strprintf(&fileName, "%s/%s/messages/%lld", storeSettings.GetUsersDir().c_str(),
 
 if (access(fileName.c_str(), F_OK) != 0)
     {
-    std::string idstr;
-    x2str(msg.header.id, idstr);
     STG_LOCKER lock(&mutex);
     errorStr = "Message for user \'";
     errorStr += login + "\' with ID \'";
-    errorStr += idstr + "\' does not exist.";
+    errorStr += std::to_string(msg.header.id) + "\' does not exist.";
     printfd(__FILE__, "FILES_STORE::EditMessage - %s\n", errorStr.c_str());
     return -1;
     }
index adb3b895633f30712eeac7b8d1746d24fd5f18dc..a1723efd216005b2519d6cb4d17eaacdc5d42a82 100644 (file)
@@ -701,7 +701,7 @@ int MYSQL_STORE::AddUser(const std::string & login) const
 std::string query = "INSERT INTO users SET login='" + login + "',Note='',NAS=''";
 
 for (int i = 0; i < USERDATA_NUM; i++)
-    query += ",Userdata" + x2str(i) + "=''";
+    query += ",Userdata" + std::to_string(i) + "=''";
 
 if(MysqlSetQuery(query.c_str()))
 {