Browse Source

Fixing compiler errors (include/malformed)

Sam Jaffe 8 years ago
parent
commit
1e75da82b5
5 changed files with 28 additions and 10 deletions
  1. 16 9
      json/json_binder_discard.cpp
  2. 1 0
      json/json_binder_parser.hpp
  3. 7 1
      json_binder_object.t.h
  4. 2 0
      json_common.cpp
  5. 2 0
      json_common.hpp

+ 16 - 9
json/json_binder_discard.cpp

@@ -9,16 +9,21 @@
 
 #include "json_binder_discard.hpp"
 
+#include <cstring>
+
 namespace json { namespace {
   struct discard_t {
     template <typename T> discard_t & operator= (T const &) { return *this; }
     template <typename T> discard_t & operator[](T const &) { return *this; }
   };
 } }
-template <>
-void json::helper::parse_numeric<json::discard_t>(json::discard_t &, char const * & data);
-template <>
-json::discard_t json::helper::parse_double_impl<json::discard_t>(const char *begin, const char *&end);
+
+namespace json { namespace helper {
+  template <>
+  void parse_numeric<json::discard_t>(json::discard_t &, char const * & data);
+  template <>
+  json::discard_t parse_double_impl<json::discard_t>(const char *begin, const char *&end);
+} }
 
 namespace json { namespace {
   void parse_object(discard_t& json, char const*& data);
@@ -69,16 +74,16 @@ namespace json { namespace {
   }
 } }
 
-namespace json {
+namespace json { namespace helper {
   template <>
-  discard_t helper::parse_double_impl<discard_t>(const char *begin, const char *&end) {
+  discard_t parse_double_impl<discard_t>(const char *begin, const char *&end) {
     std::strtod(begin, const_cast<char **>(&end));
     errno = 0;
-    return discard_t{};
+    return {};
   }
   
   template <>
-  void helper::parse_numeric<discard_t>(discard_t & d, char const * & data) {
+  void parse_numeric<discard_t>(discard_t & d, char const * & data) {
     numeric_token_info info = data;
     if ( info.is_double || info.parse_numeric() == DOUBLE ) {
       helper::parse_double(d, data);
@@ -86,7 +91,9 @@ namespace json {
       data = info.it;
     }
   }
-  
+} }
+
+namespace json {
   void parse_discard_token( char const * & data ) {
     json::discard_t tmp;
     parse_one_token( tmp, data );

+ 1 - 0
json/json_binder_parser.hpp

@@ -11,6 +11,7 @@
 #pragma once
 
 #include <iostream>
+#include <memory>
 
 namespace json {
   class value;

+ 7 - 1
json_binder_object.t.h

@@ -120,8 +120,14 @@ public:
                      json::unterminated_json_exception);
   }
   
+  std::string ify(double value) {
+    std::stringstream ss;
+    ss << std::fixed << value;
+    return ss.str();
+  }
+  
   void test_write_object_is_composed_of_correct_data() {
-    std::string const dbl = (std::stringstream{} << std::fixed << 1.0).str();
+    std::string const dbl = ify(1.0);
     std::string const expected = "{\"average\":"+dbl+",\"count\":10,\"data\":{\"key1\":[1,2],\"key2\":[3,4]}}";
     std::stringstream ss;
     TestObject const in = { 10, 1.0, { { "key1", {1, 2} }, { "key2", {3, 4} } } };

+ 2 - 0
json_common.cpp

@@ -6,6 +6,8 @@
 //
 
 #include "json_common.hpp"
+
+#include <cstring>
 #include <map>
 
 namespace json {

+ 2 - 0
json_common.hpp

@@ -9,8 +9,10 @@
 
 #include <cstdint>
 #include <cstdlib>
+#include <limits>
 #include <stdexcept>
 #include <string>
+#include <strings.h>
 #include <errno.h>
 
 namespace json {