summaryrefslogtreecommitdiff
path: root/datastore-leveldb/src
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2013-04-20 22:26:55 +0200
committerYves Fischer <yvesf-git@xapek.org>2013-04-20 22:27:00 +0200
commit0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61 (patch)
tree3d8222d4e3de49172b410c3d1136dfaaa18294d0 /datastore-leveldb/src
parentb5c71cfd18eb145acb72d0a9b58c5b10fbeac74d (diff)
downloadebus-alt-0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61.tar.gz
ebus-alt-0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61.zip
sachen rumgeschoben, leveldb: 32bit fix
Diffstat (limited to 'datastore-leveldb/src')
-rw-r--r--datastore-leveldb/src/web.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/datastore-leveldb/src/web.cpp b/datastore-leveldb/src/web.cpp
index 125a4ad..d938a66 100644
--- a/datastore-leveldb/src/web.cpp
+++ b/datastore-leveldb/src/web.cpp
@@ -11,10 +11,18 @@ static inline uint64_t now() {
std::chrono::high_resolution_clock::now().time_since_epoch()).count();
}
+inline void strToL(unsigned long int *l, std::string s) {
+ *l = std::stoul(s);
+}
+inline void strToL(unsigned long long int *l, std::string s) {
+ *l = std::stoull(s);
+}
+
+
static inline bool parse_key(leveldb::Slice &&key, uint64_t *value) {
if (key.size() != 20+3)
return false;
- *value = std::stoul(key.data()+3);
+ strToL(value, key.data()+3);
return true;
}
@@ -38,7 +46,7 @@ const boost::regex web_handle_api_value_timestamp_R(
"/api/value/([a-zA-Z0-9\\.]+)/([0-9]+)");
void web_handle_api_value_timestamp(const boost::cmatch &match, struct mg_connection *conn) {
std::string sensor(match[1].str());
- uint64_t timestamp = std::stoul(match[2].str());
+ uint64_t timestamp; strToL(&timestamp, match[2].str());
char buf[1024];
int bytesRead = mg_read(conn, buf, 1024);
std::string value(buf, bytesRead);
@@ -80,8 +88,8 @@ const boost::regex web_handle_api_range_R(
"/api/range/([a-zA-Z0-9\\.]+)/([0-9]+)/([0-9]+)");
void web_handle_api_range(const boost::cmatch &match, struct mg_connection *conn) {
std::string sensor(match[1].str());
- uint64_t start = std::stoul(match[2].str());
- uint64_t end = std::stoul(match[3].str());
+ uint64_t start; strToL(&start, match[2].str());
+ uint64_t end; strToL(&end, match[3].str());
std::string key_start(std::move(make_key(start)));
std::string key_end(std::move(make_key(end)));
@@ -122,9 +130,9 @@ const boost::regex web_handle_api_range_size_R(
"/api/range/([a-zA-Z0-9\\.]+)/([0-9]+)/([0-9]+)/([0-9]+)");
void web_handle_api_range_size(const boost::cmatch &match, struct mg_connection *conn) {
std::string sensor(match[1].str());
- uint64_t start = std::stoul(match[2].str());
- uint64_t end = std::stoul(match[3].str());
- uint64_t size = std::stoul(match[4].str());
+ uint64_t start; strToL(&start, match[2].str());
+ uint64_t end; strToL(&end, match[3].str());
+ uint64_t size; strToL(&size, match[4].str());
leveldb::DB *db = getDB(sensor);
if (db == nullptr) {
@@ -152,7 +160,7 @@ void web_handle_api_range_size(const boost::cmatch &match, struct mg_connection
uint64_t actual_size = 0;
std::ostringstream outbuf;
leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
- for (uint64_t key = start; key <= end; key += step) {
+ for (uint64_t key = start; key < end; key += step) {
it->Seek(make_key(key));
if (!it->Valid()) continue;