diff options
author | Erik Andersson <erik@packy.se> | 2016-11-22 23:56:43 +0100 |
---|---|---|
committer | Erik Andersson <erik@packy.se> | 2016-11-22 23:56:43 +0100 |
commit | 41954fffc10bfd230f857f57c6871b412d5f2e91 (patch) | |
tree | 010bcf28f294a58b4a22b7276cf615758648bcbe /src/misc_functions.cpp | |
parent | ed374a8dbcdaaf273964293d2805bdd61b148022 (diff) | |
download | ocelot-41954fffc10bfd230f857f57c6871b412d5f2e91.zip ocelot-41954fffc10bfd230f857f57c6871b412d5f2e91.tar.gz ocelot-41954fffc10bfd230f857f57c6871b412d5f2e91.tar.bz2 |
Diffstat (limited to 'src/misc_functions.cpp')
-rw-r--r-- | src/misc_functions.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/misc_functions.cpp b/src/misc_functions.cpp index 022e6b2..2b616f9 100644 --- a/src/misc_functions.cpp +++ b/src/misc_functions.cpp @@ -2,15 +2,15 @@ #include <iostream> #include <sstream> -long strtolong(const std::string& str) { - std::istringstream stream (str); - long i = 0; +int32_t strtoint32(const std::string& str) { + std::istringstream stream(str); + int32_t i = 0; stream >> i; return i; } -int64_t strtolonglong(const std::string& str) { - std::istringstream stream (str); +int64_t strtoint64(const std::string& str) { + std::istringstream stream(str); int64_t i = 0; stream >> i; return i; @@ -59,17 +59,17 @@ std::string hex_decode(const std::string &in) { std::string bintohex(const std::string &in) { std::string out; - out.reserve(40); size_t length = in.length(); + out.reserve(2*length); for (unsigned int i = 0; i < length; i++) { - unsigned char x = (unsigned char)in[i] >> 4; + unsigned char x = static_cast<unsigned char>((in[i] & 0xF0) >> 4); if (x > 9) { x += 'a' - 10; } else { x += '0'; } out.push_back(x); - x = in[i] & 0xF; + x = in[i] & 0x0F; if (x > 9) { x += 'a' - 10; } else { |