00001 #include "Converter.hpp"
00002 #include <iostream>
00003
00004 #include <cstdlib>
00005 #include <cstdio>
00006
00007 namespace aitools {
00008 namespace invertedindex {
00009
00010 uint32_t
00011 Converter::str_to_ui32(const std::string& str)
00012 {
00013 return std::strtoul(str.c_str(), NULL, 10);
00014
00015
00016
00017
00018
00019 }
00020
00021 uint64_t
00022 Converter::str_to_ui64(const std::string& str)
00023 {
00024 return std::strtoull(str.c_str(), NULL, 10);
00025
00026
00027
00028
00029
00030 }
00031
00032 std::string
00033 Converter::ui32_to_str(uint32_t number)
00034 {
00035 char buffer[32];
00036 std::sprintf(buffer, "%u", number);
00037 return std::string(buffer);
00038
00039
00040
00041
00042 }
00043
00044 std::string
00045 Converter::ui64_to_str(uint64_t number)
00046 {
00047 char buffer[32];
00048 std::sprintf(buffer, "%lu", number);
00049 return std::string(buffer);
00050
00051
00052
00053
00054 }
00055
00056 std::string
00057 Converter::float_to_str(float number)
00058 {
00059 char buffer[32];
00060 std::sprintf(buffer, "%f", number);
00061 return std::string(buffer);
00062
00063
00064
00065
00066 }
00067
00068 std::string
00069 Converter::double_to_str(double number)
00070 {
00071 char buffer[32];
00072 std::sprintf(buffer, "%f", number);
00073 return std::string(buffer);
00074
00075
00076
00077
00078 }
00079
00080 }
00081 }