Skip to content

Instantly share code, notes, and snippets.

@tarasglek
Last active December 24, 2015 02:49
Show Gist options
  • Save tarasglek/6733166 to your computer and use it in GitHub Desktop.
Save tarasglek/6733166 to your computer and use it in GitHub Desktop.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6790471..523232d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@ set(CPACK_PACKAGE_VERSION_MINOR 1)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
+set(CMAKE_VERBOSE_MAKEFILE on)
include(mozsvc)
include(externals)
diff --git a/cmake/mozsvc.cmake b/cmake/mozsvc.cmake
index ef7f5e5..beb0b2f 100644
--- a/cmake/mozsvc.cmake
+++ b/cmake/mozsvc.cmake
@@ -25,11 +25,11 @@ else()
# Predefined Macros: clang|gcc -dM -E -x c /dev/null
# Compiler options: http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html#Invoking-GCC
set(CMAKE_C_FLAGS "-std=c11 -pedantic -Werror -Wall -Wextra -fPIC")
- set(CMAKE_CXX_FLAGS "-std=c++11 -pedantic -Werror -Wall -Wextra -fPIC -isystem /usr/local/include -isystem /opt/local/include")
+ set(CMAKE_CXX_FLAGS "-std=c++11 -pedantic -Wall -Wextra -fPIC -isystem /usr/local/include -isystem /opt/local/include")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
- set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+ set(CMAKE_C_FLAGS_RELEASE "-g -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CPACK_GENERATOR "TGZ")
diff --git a/common/Histogram.cpp b/common/Histogram.cpp
index f2694ed..d2d69a2 100644
--- a/common/Histogram.cpp
+++ b/common/Histogram.cpp
@@ -19,38 +19,38 @@ namespace mozilla {
namespace telemetry {
////////////////////////////////////////////////////////////////////////////////
-HistogramDefinition::HistogramDefinition(const rapidjson::Value& aValue)
+HistogramDefinition::HistogramDefinition(const rapidjsonValue& aValue)
{
- const rapidjson::Value& k = aValue["kind"];
+ const rapidjsonValue& k = aValue["kind"];
if (!k.IsString()) {
throw runtime_error("missing kind element");
}
mKind = boost::lexical_cast<int>(k.GetString());
- const rapidjson::Value& mn = aValue["min"];
+ const rapidjsonValue& mn = aValue["min"];
if (!mn.IsInt()) {
throw runtime_error("missing min element");
}
mMin = mn.GetInt();
- const rapidjson::Value& mx = aValue["max"];
+ const rapidjsonValue& mx = aValue["max"];
if (!mx.IsInt()) {
throw runtime_error("missing max element");
}
mMax = mx.GetInt();
- const rapidjson::Value& b = aValue["bucket_count"];
+ const rapidjsonValue& b = aValue["bucket_count"];
if (!b.IsInt()) {
throw runtime_error("missing bucket_count element");
}
mBucketCount = b.GetInt();
- const rapidjson::Value& a = aValue["buckets"];
+ const rapidjsonValue& a = aValue["buckets"];
if (!a.IsArray()) {
throw runtime_error("missing bucket array element");
}
int index = 0;
- for (rapidjson::Value::ConstValueIterator it = a.Begin(); it != a.End();
+ for (rapidjsonValue::ConstValueIterator it = a.Begin(); it != a.End();
++it, ++index) {
if (!it->IsInt()) {
throw runtime_error("buckets array must contain integer elements");
@@ -79,7 +79,7 @@ HistogramDefinition::GetBucketIndex(long aLowerBound) const
////////////////////////////////////////////////////////////////////////////////
Histogram::Histogram(const std::string& aJSON)
{
- rapidjson::Document doc;
+ rapidjsonDocument doc;
if (doc.Parse<0>(aJSON.c_str()).HasParseError()) {
stringstream ss;
ss << "json parse failed: " << doc.GetParseError();
@@ -116,13 +116,13 @@ Histogram::GetDefinition(const char* aName) const
/// Private Member Functions
////////////////////////////////////////////////////////////////////////////////
void
-Histogram::LoadDefinitions(const rapidjson::Document& aDoc)
+Histogram::LoadDefinitions(const rapidjsonDocument& aDoc)
{
- const rapidjson::Value& histograms = aDoc["histograms"];
+ const rapidjsonValue& histograms = aDoc["histograms"];
if (!histograms.IsObject()) {
throw runtime_error("histograms element must be an object");
}
- for (rapidjson::Value::ConstMemberIterator it = histograms.MemberBegin();
+ for (rapidjsonValue::ConstMemberIterator it = histograms.MemberBegin();
it != histograms.MemberEnd(); ++it) {
const char* name = it->name.GetString();
if (!it->value.IsObject()) {
diff --git a/common/Histogram.cpp.cstar b/common/Histogram.cpp.cstar
index 09a1f08..596cebb 100644
--- a/common/Histogram.cpp.cstar
+++ b/common/Histogram.cpp.cstar
@@ -19,38 +19,38 @@ namespace mozilla {
namespace telemetry {
////////////////////////////////////////////////////////////////////////////////
-HistogramDefinition::HistogramDefinition(const rapidjson::Value& aValue)
+HistogramDefinition::HistogramDefinition(const rapidjsonValue& aValue)
{
- const rapidjson::Value& k = aValue["kind"];
+ const rapidjsonValue& k = aValue["kind"];
if (!k.IsString()) {
throw runtime_error("missing kind element");
}
mKind = boost::lexical_cast<int>(k.GetString());
- const rapidjson::Value& mn = aValue["min"];
+ const rapidjsonValue& mn = aValue["min"];
if (!mn.IsInt()) {
throw runtime_error("missing min element");
}
mMin = mn.GetInt();
- const rapidjson::Value& mx = aValue["max"];
+ const rapidjsonValue& mx = aValue["max"];
if (!mx.IsInt()) {
throw runtime_error("missing max element");
}
mMax = mx.GetInt();
- const rapidjson::Value& b = aValue["bucket_count"];
+ const rapidjsonValue& b = aValue["bucket_count"];
if (!b.IsInt()) {
throw runtime_error("missing bucket_count element");
}
mBucketCount = b.GetInt();
- const rapidjson::Value& a = aValue["buckets"];
+ const rapidjsonValue& a = aValue["buckets"];
if (!a.IsArray()) {
throw runtime_error("missing bucket array element");
}
int index = 0;
- for (rapidjson::Value::ConstValueIterator it = a.Begin(); it != a.End();
+ for (rapidjsonValue::ConstValueIterator it = a.Begin(); it != a.End();
++it, ++index) {
if (!it->IsInt()) {
throw runtime_error("buckets array must contain integer elements");
@@ -97,7 +97,7 @@ Histogram::Histogram(const boost::filesystem::path& fileName)
ifs.close();
buffer.get()[len] = 0;
- rapidjson::Document doc;
+ rapidjsonDocument doc;
if (doc.ParseInsitu<0>(buffer.get()).HasParseError()) {
stringstream ss;
ss << "json parse failed: " << doc.GetParseError();
@@ -132,13 +132,13 @@ Histogram::GetDefinition(const char* aName) const
/// Private Member Functions
////////////////////////////////////////////////////////////////////////////////
void
-Histogram::LoadDefinitions(const rapidjson::Document& aDoc)
+Histogram::LoadDefinitions(const rapidjsonDocument& aDoc)
{
- const rapidjson::Value& histograms = aDoc["histograms"];
+ const rapidjsonValue& histograms = aDoc["histograms"];
if (!histograms.IsObject()) {
throw runtime_error("histograms element must be an object");
}
- for (rapidjson::Value::ConstMemberIterator it = histograms.MemberBegin();
+ for (rapidjsonValue::ConstMemberIterator it = histograms.MemberBegin();
it != histograms.MemberEnd(); ++it) {
const char* name = it->name.GetString();
if (!it->value.IsObject()) {
diff --git a/common/Histogram.h b/common/Histogram.h
index bcac6ca..8c3db2c 100644
--- a/common/Histogram.h
+++ b/common/Histogram.h
@@ -20,6 +20,9 @@ Accessor and utility functions functions for the Histogram.json data structure.
#include <unordered_map>
#include <vector>
+typedef rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonDocument;
+typedef rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonValue;
+
namespace mozilla {
namespace telemetry {
@@ -31,7 +34,7 @@ class HistogramDefinition : boost::noncopyable
{
public:
- HistogramDefinition(const rapidjson::Value& aValue);
+ HistogramDefinition(const rapidjsonValue& aValue);
/**
* Returns the index of the associated bucket based on the bucket's lower
@@ -120,7 +123,7 @@ private:
* @param aValue "histograms" object from the JSON document.
*
*/
- void LoadDefinitions(const rapidjson::Document& aDoc);
+ void LoadDefinitions(const rapidjsonDocument& aDoc);
std::unordered_map<char*, HistogramDefinition*, Cstring_hash,
Cstring_equal_to> mDefinitions;
diff --git a/common/Histogram.h.cstar b/common/Histogram.h.cstar
index b1a6025..81eb836 100644
--- a/common/Histogram.h.cstar
+++ b/common/Histogram.h.cstar
@@ -29,7 +29,7 @@ class HistogramDefinition
{
public:
- HistogramDefinition(const rapidjson::Value& aValue);
+ HistogramDefinition(const rapidjsonValue& aValue);
/**
* Returns the index of the associated bucket based on the bucket's lower
@@ -104,7 +104,7 @@ private:
* @param aValue "histograms" object from the JSON document.
*
*/
- void LoadDefinitions(const rapidjson::Document& aDoc);
+ void LoadDefinitions(const rapidjsonDocument& aDoc);
std::unordered_map<std::string, std::shared_ptr<HistogramDefinition> > mDefinitions;
diff --git a/common/HistogramConverter.cpp b/common/HistogramConverter.cpp
index 484afd3..932ba19 100644
--- a/common/HistogramConverter.cpp
+++ b/common/HistogramConverter.cpp
@@ -19,34 +19,34 @@ namespace mozilla {
namespace telemetry {
bool RewriteValues(shared_ptr<HistogramDefinition> aDef,
- const rapidjson::Value& aData,
+ const rapidjsonValue& aData,
vector<int>& aRewrite);
-bool RewriteHistogram(shared_ptr<Histogram>& aHist, rapidjson::Value& aValue);
+bool RewriteHistogram(shared_ptr<Histogram>& aHist, rapidjsonValue& aValue);
////////////////////////////////////////////////////////////////////////////////
-bool ConvertHistogramData(HistogramCache& aCache, rapidjson::Document& aDoc)
+bool ConvertHistogramData(HistogramCache& aCache, rapidjsonDocument& aDoc)
{
- const rapidjson::Value& info = aDoc["info"];
+ const rapidjsonValue& info = aDoc["info"];
if (!info.IsObject()) {
//cerr << "ConvertHistogramData - missing info object\n";
return false;
}
- const rapidjson::Value& revision = info["revision"];
+ const rapidjsonValue& revision = info["revision"];
if (!revision.IsString()) {
//cerr << "ConvertHistogramData - missing info.revision\n";
return false;
}
- rapidjson::Value& histograms = aDoc["histograms"];
+ rapidjsonValue& histograms = aDoc["histograms"];
if (!histograms.IsObject()) {
//cerr << "ConvertHistogramData - missing hintograms object\n";
return false;
}
- rapidjson::Value& ver = aDoc["ver"];
+ rapidjsonValue& ver = aDoc["ver"];
if (!ver.IsInt() || ver.GetInt() != 1) {
//cerr << "ConvertHistogramData - missing ver\n";
return false;
@@ -83,15 +83,15 @@ bool ConvertHistogramData(HistogramCache& aCache, rapidjson::Document& aDoc)
////////////////////////////////////////////////////////////////////////////////
bool RewriteValues(const HistogramDefinition* aDef,
- const rapidjson::Value& aData,
+ const rapidjsonValue& aData,
std::vector<int>& aRewrite)
{
- const rapidjson::Value& values = aData["values"];
+ const rapidjsonValue& values = aData["values"];
if (!values.IsObject()) {
cerr << "RewriteValues - value object not found\n";
return false;
}
- for (rapidjson::Value::ConstMemberIterator it = values.MemberBegin();
+ for (rapidjsonValue::ConstMemberIterator it = values.MemberBegin();
it != values.MemberEnd(); ++it) {
if (!it->value.IsInt()) {
cerr << "RewriteValues - invalid value object\n";
@@ -110,14 +110,14 @@ bool RewriteValues(const HistogramDefinition* aDef,
}
////////////////////////////////////////////////////////////////////////////////
-bool RewriteHistogram(shared_ptr<Histogram>& aHist, rapidjson::Value& aValue)
+bool RewriteHistogram(shared_ptr<Histogram>& aHist, rapidjsonValue& aValue)
{
- rapidjson::Document doc;
- rapidjson::Document::AllocatorType& alloc = doc.GetAllocator();
+ rapidjsonDocument doc;
+ rapidjsonDocument::AllocatorType& alloc = doc.GetAllocator();
vector<double> summary(kExtraBucketsSize);
bool result = true;
- for (rapidjson::Value::MemberIterator it = aValue.MemberBegin(); result &&
+ for (rapidjsonValue::MemberIterator it = aValue.MemberBegin(); result &&
it != aValue.MemberEnd(); ++it) {
if (it->value.IsObject()) {
const char* name = reinterpret_cast<const char*>(it->name.GetString());
@@ -139,7 +139,7 @@ bool RewriteHistogram(shared_ptr<Histogram>& aHist, rapidjson::Value& aValue)
if (result) {
// save off the summary values before rewriting the histogram data
for (int x = 0; kExtraBuckets[x] != nullptr; ++x) {
- const rapidjson::Value& v = it->value[kExtraBuckets[x]];
+ const rapidjsonValue& v = it->value[kExtraBuckets[x]];
if (v.IsNumber()) {
summary[x] = v.GetDouble();
} else {
diff --git a/common/HistogramConverter.h b/common/HistogramConverter.h
index a9af2d5..90d390e 100644
--- a/common/HistogramConverter.h
+++ b/common/HistogramConverter.h
@@ -13,10 +13,13 @@
#include <rapidjson/document.h>
+typedef rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonDocument;
+typedef rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonValue;
+
namespace mozilla {
namespace telemetry {
-bool ConvertHistogramData(HistogramCache& aCache, rapidjson::Document& aDoc);
+bool ConvertHistogramData(HistogramCache& aCache, rapidjsonDocument& aDoc);
}
}
diff --git a/common/TelemetryRecord.cpp b/common/TelemetryRecord.cpp
index 81db4de..2817334 100644
--- a/common/TelemetryRecord.cpp
+++ b/common/TelemetryRecord.cpp
@@ -83,7 +83,7 @@ uint64_t TelemetryRecord::GetTimestamp()
}
////////////////////////////////////////////////////////////////////////////////
-rapidjson::Document& TelemetryRecord::GetDocument()
+rapidjsonDocument& TelemetryRecord::GetDocument()
{
return mDocument;
}
diff --git a/common/TelemetryRecord.h b/common/TelemetryRecord.h
index 6d19c21..35451e8 100644
--- a/common/TelemetryRecord.h
+++ b/common/TelemetryRecord.h
@@ -15,6 +15,9 @@
#include <cstdint>
#include <rapidjson/document.h>
+typedef rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonDocument;
+typedef rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonValue;
+
namespace mozilla {
namespace telemetry {
@@ -35,7 +38,7 @@ public:
const char* GetPath();
uint64_t GetTimestamp();
- rapidjson::Document& GetDocument();
+ rapidjsonDocument& GetDocument();
private:
bool FindRecord(std::istream& aInput);
@@ -43,7 +46,7 @@ private:
bool ProcessRecord();
int Inflate();
- rapidjson::Document mDocument;
+ rapidjsonDocument mDocument;
uint16_t mPathLength;
size_t mPathSize;
diff --git a/common/TelemetrySchema.cpp b/common/TelemetrySchema.cpp
index ccab78b..9773fab 100644
--- a/common/TelemetrySchema.cpp
+++ b/common/TelemetrySchema.cpp
@@ -19,16 +19,16 @@ namespace mozilla {
namespace telemetry {
////////////////////////////////////////////////////////////////////////////////
-TelemetrySchema::TelemetryDimension::TelemetryDimension(const rapidjson::Value& aValue)
+TelemetrySchema::TelemetryDimension::TelemetryDimension(const rapidjsonValue& aValue)
{
namespace bx = boost::xpressive;
- const rapidjson::Value& fn = aValue["field_name"];
+ const rapidjsonValue& fn = aValue["field_name"];
if (!fn.IsString()) {
throw runtime_error("missing field_name element");
}
mName = fn.GetString();
- const rapidjson::Value& av = aValue["allowed_values"];
+ const rapidjsonValue& av = aValue["allowed_values"];
switch (av.GetType()) {
case rapidjson::kStringType:
mType = kValue;
@@ -36,7 +36,7 @@ TelemetrySchema::TelemetryDimension::TelemetryDimension(const rapidjson::Value&
break;
case rapidjson::kArrayType:
mType = kSet;
- for (rapidjson::Value::ConstValueIterator it = av.Begin(); it != av.End();
+ for (rapidjsonValue::ConstValueIterator it = av.Begin(); it != av.End();
++it) {
if (!it->IsString()) {
throw runtime_error("allowed_values must be strings");
@@ -47,11 +47,11 @@ TelemetrySchema::TelemetryDimension::TelemetryDimension(const rapidjson::Value&
case rapidjson::kObjectType:
{
mType = kRange;
- const rapidjson::Value& mn = av["min"];
+ const rapidjsonValue& mn = av["min"];
if (!mn.IsNumber()) {
throw runtime_error("allowed_values range is missing min element");
}
- const rapidjson::Value& mx = av["max"];
+ const rapidjsonValue& mx = av["max"];
if (!mx.IsNumber()) {
throw runtime_error("allowed_values range is missing max element");
}
@@ -76,14 +76,14 @@ TelemetrySchema::TelemetrySchema(const boost::filesystem::path& fileName)
}
string json((istream_iterator<char>(ifs)), istream_iterator<char>());
- rapidjson::Document doc;
+ rapidjsonDocument doc;
if (doc.Parse<0>(json.c_str()).HasParseError()) {
stringstream ss;
ss << "json parse failed: " << doc.GetParseError();
throw runtime_error(ss.str());
}
- const rapidjson::Value& version = doc["version"];
+ const rapidjsonValue& version = doc["version"];
if (!version.IsInt()) {
throw runtime_error("version element is missing");
}
@@ -93,9 +93,9 @@ TelemetrySchema::TelemetrySchema(const boost::filesystem::path& fileName)
////////////////////////////////////////////////////////////////////////////////
boost::filesystem::path
-TelemetrySchema::GetDimensionPath(const rapidjson::Document& aDoc) const
+TelemetrySchema::GetDimensionPath(const rapidjsonDocument& aDoc) const
{
- const rapidjson::Value& info = aDoc["info"];
+ const rapidjsonValue& info = aDoc["info"];
if (!info.IsObject()) {
throw runtime_error("info element must be an object");
}
@@ -103,7 +103,7 @@ TelemetrySchema::GetDimensionPath(const rapidjson::Document& aDoc) const
boost::filesystem::path p;
auto end = mDimensions.end();
for (auto it = mDimensions.begin(); it != end; ++it){
- const rapidjson::Value& v = info[(*it)->mName.c_str()];
+ const rapidjsonValue& v = info[(*it)->mName.c_str()];
if (v.IsString()) {
string dim = v.GetString();
switch ((*it)->mType) {
@@ -145,13 +145,13 @@ TelemetrySchema::GetDimensionPath(const rapidjson::Document& aDoc) const
/// Private Member Functions
////////////////////////////////////////////////////////////////////////////////
void
-TelemetrySchema::LoadDimensions(const rapidjson::Document& aDoc)
+TelemetrySchema::LoadDimensions(const rapidjsonDocument& aDoc)
{
- const rapidjson::Value& dimensions = aDoc["dimensions"];
+ const rapidjsonValue& dimensions = aDoc["dimensions"];
if (!dimensions.IsArray()) {
throw runtime_error("dimensions element must be an array");
}
- for (rapidjson::Value::ConstValueIterator it = dimensions.Begin();
+ for (rapidjsonValue::ConstValueIterator it = dimensions.Begin();
it != dimensions.End(); ++it) {
if (!it->IsObject()) {
throw runtime_error("dimension elemenst must be objects");
diff --git a/common/TelemetrySchema.h b/common/TelemetrySchema.h
index 6bd20a2..35fa20a 100644
--- a/common/TelemetrySchema.h
+++ b/common/TelemetrySchema.h
@@ -20,6 +20,9 @@ structure.
#include <string>
#include <vector>
+typedef rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonDocument;
+typedef rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator> rapidjsonValue;
+
namespace mozilla {
namespace telemetry {
@@ -42,13 +45,13 @@ public:
*
* @return boost::filesystem::path
*/
- boost::filesystem::path GetDimensionPath(const rapidjson::Document& aDoc) const;
+ boost::filesystem::path GetDimensionPath(const rapidjsonDocument& aDoc) const;
private:
struct TelemetryDimension
{
- TelemetryDimension(const rapidjson::Value& aValue);
+ TelemetryDimension(const rapidjsonValue& aValue);
enum Type {
kValue,
@@ -70,7 +73,7 @@ private:
* @param aValue "histograms" object from the JSON document.
*
*/
- void LoadDimensions(const rapidjson::Document& aDoc);
+ void LoadDimensions(const rapidjsonDocument& aDoc);
static std::string SafePath(const std::string& s);
diff --git a/common/test/TestHistogramConverter.cpp b/common/test/TestHistogramConverter.cpp
index eef5705..4791bdc 100644
--- a/common/test/TestHistogramConverter.cpp
+++ b/common/test/TestHistogramConverter.cpp
@@ -22,7 +22,7 @@ BOOST_AUTO_TEST_CASE(test_converter)
const char* conv = "{\"ver\":2,\"histograms\":{\"A11Y_IATABLE_USAGE_FLAG\":[1,0,0,0,-1,-1,1.2342,0]},\"info\":{\"revision\":\"http://hg.mozilla.org/releases/mozilla-release/rev/a55c55edf302\"}}";
- rapidjson::Document d;
+ rapidjsonDocument d;
d.Parse<0>(hist);
BOOST_REQUIRE(!d.HasParseError());
diff --git a/common/test/TestTelemetrySchema.cpp b/common/test/TestTelemetrySchema.cpp
index d73bd2a..e8f4af8 100644
--- a/common/test/TestTelemetrySchema.cpp
+++ b/common/test/TestTelemetrySchema.cpp
@@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(test_load)
string fn(kDataPath + "telemetry_schema.json");
try {
TelemetrySchema t(fn);
- rapidjson::Document d;
+ rapidjsonDocument d;
d.Parse<0>(info);
boost::filesystem::path p = t.GetDimensionPath(d);
BOOST_REQUIRE_EQUAL("idle_daily/Firefox/release/23.0.1/20130814063812/other", p);
diff --git a/convert.cpp b/convert.cpp
index ca344e1..d6e630d 100644
--- a/convert.cpp
+++ b/convert.cpp
@@ -51,62 +51,62 @@ void read_config(const char* aFile, ConvertConfig& aConfig)
}
string json((istream_iterator<char>(ifs)), istream_iterator<char>());
- rapidjson::Document doc;
+ rapidjsonDocument doc;
if (doc.Parse<0>(json.c_str()).HasParseError()) {
stringstream ss;
ss << "json parse failed: " << doc.GetParseError();
throw runtime_error(ss.str());
}
- rapidjson::Value& idir = doc["input_directory"];
+ rapidjsonValue& idir = doc["input_directory"];
if (!idir.IsString()) {
throw runtime_error("input_directory not specified");
}
aConfig.mInputDirectory = idir.GetString();
- rapidjson::Value& ts = doc["telemetry_schema"];
+ rapidjsonValue& ts = doc["telemetry_schema"];
if (!ts.IsString()) {
throw runtime_error("telemetry_schema not specified");
}
aConfig.mTelemetrySchema = ts.GetString();
- rapidjson::Value& hs = doc["histogram_server"];
+ rapidjsonValue& hs = doc["histogram_server"];
if (!hs.IsString()) {
throw runtime_error("histogram_server not specified");
}
aConfig.mHistogramServer = hs.GetString();
- rapidjson::Value& sp = doc["storage_path"];
+ rapidjsonValue& sp = doc["storage_path"];
if (!sp.IsString()) {
throw runtime_error("storage_path not specified");
}
aConfig.mStoragePath = sp.GetString();
- rapidjson::Value& lp = doc["log_path"];
+ rapidjsonValue& lp = doc["log_path"];
if (!lp.IsString()) {
throw runtime_error("log_path not specified");
}
aConfig.mLogPath = lp.GetString();
- rapidjson::Value& up = doc["upload_path"];
+ rapidjsonValue& up = doc["upload_path"];
if (!up.IsString()) {
throw runtime_error("upload_path not specified");
}
aConfig.mUploadPath = up.GetString();
- rapidjson::Value& mu = doc["max_uncompressed"];
+ rapidjsonValue& mu = doc["max_uncompressed"];
if (!mu.IsUint64()) {
throw runtime_error("max_uncompressed not specified");
}
aConfig.mMaxUncompressed = mu.GetUint64();
- rapidjson::Value& mc = doc["memory_constraint"];
+ rapidjsonValue& mc = doc["memory_constraint"];
if (!mc.IsUint()) {
throw runtime_error("memory_constraint not specified");
}
aConfig.mMemoryConstraint = mc.GetUint();
- rapidjson::Value& cpr = doc["compression_preset"];
+ rapidjsonValue& cpr = doc["compression_preset"];
if (!cpr.IsInt()) {
throw runtime_error("compression_preset not specified");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment