本文整理汇总了C++中JSONCPP_STRING::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONCPP_STRING::empty方法的具体用法?C++ JSONCPP_STRING::empty怎么用?C++ JSONCPP_STRING::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONCPP_STRING
的用法示例。
在下文中一共展示了JSONCPP_STRING::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runTest
static int runTest(Options const& opts)
{
int exitCode = 0;
JSONCPP_STRING input = readInputTestFile(opts.path.c_str());
if (input.empty()) {
printf("Failed to read input or empty input: %s\n", opts.path.c_str());
return 3;
}
JSONCPP_STRING basePath = removeSuffix(opts.path, ".json");
if (!opts.parseOnly && basePath.empty()) {
printf("Bad input path. Path does not end with '.expected':\n%s\n",
opts.path.c_str());
return 3;
}
JSONCPP_STRING const actualPath = basePath + ".actual";
JSONCPP_STRING const rewritePath = basePath + ".rewrite";
JSONCPP_STRING const rewriteActualPath = basePath + ".actual-rewrite";
Json::Value root;
exitCode = parseAndSaveValueTree(
input, actualPath, "input",
opts.features, opts.parseOnly, &root);
if (exitCode || opts.parseOnly) {
return exitCode;
}
JSONCPP_STRING rewrite;
exitCode = rewriteValueTree(rewritePath, root, opts.write, &rewrite);
if (exitCode) {
return exitCode;
}
Json::Value rewriteRoot;
exitCode = parseAndSaveValueTree(
rewrite, rewriteActualPath, "rewrite",
opts.features, opts.parseOnly, &rewriteRoot);
if (exitCode) {
return exitCode;
}
return 0;
}
示例2: getDOM
Json::Value getDOM(std::string const& path) {
JSONCPP_STRING input = readInputTestFile(path.c_str());
if (input.empty()) {
throw std::runtime_error("Empty input file");
}
Json::Features mode = Json::Features::strictMode();
mode.allowComments_ = true;
Json::Value root;
Json::Reader reader(mode);
bool parsingSuccessful = reader.parse(input.data(), input.data() + input.size(), root);
if (!parsingSuccessful) {
throw std::runtime_error(
std::string("Failed to parse file: ") +
reader.getFormattedErrorMessages());
}
return root;
}