本文整理汇总了C++中Json::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ Json::Value方法的具体用法?C++ Json::Value怎么用?C++ Json::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Json
的用法示例。
在下文中一共展示了Json::Value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool Stations::Load() {
char appDataPath[MAX_PATH];
SHGetFolderPath(nullptr, CSIDL_COMMON_APPDATA, nullptr,
SHGFP_TYPE_CURRENT, appDataPath);
string path = string(appDataPath) + "\\InternetRadio\\stations.json";
stringstream ssArchive;
try {
HTTP::Get(
"http://internetradio.clemensboos.net/stations/archive.json",
&ssArchive);
} catch(...) { }
Reader jsonReader;
Value archiveRootValue;
jsonReader.parse(ssArchive, archiveRootValue);
map<int, string> staVersions;
for (size_t i = 0; i < (size_t)archiveRootValue.size(); ++i) {
string versionStr = archiveRootValue.getMemberNames().at(i);
Value versionMinVerVal = archiveRootValue.get(versionStr, Value(
nullValue));
if (!versionMinVerVal.isString())
continue;
staVersions.insert(pair<int, string>(
atoi(versionStr.c_str()), versionMinVerVal.asString()));
}
uint16_t installedVersion[4];
VersionUtil::GetInstalledVersion(installedVersion);
for (map<int, string>::reverse_iterator it =
staVersions.rbegin(); it != staVersions.rend(); ++it) {
uint16_t staVer[4];
VersionUtil::VersionStrToArr(it->second, staVer);
if (VersionUtil::CompareVersions(installedVersion, staVer) !=
VCR_Older) {
stringstream ssVer;
ssVer << it->first;
stringstream ssNewStaChecksumsF;
try {
HTTP::Get("http://internetradio.clemensboos.net/stations/" +
ssVer.str() + "/checksums", &ssNewStaChecksumsF);
} catch(...) {
break;
}
while (ssNewStaChecksumsF.good()) {
string filePathAndChecksum;
ssNewStaChecksumsF >> filePathAndChecksum;
if (filePathAndChecksum == "")
continue;
vector<string> filePathAndChecksumSplit =
StringUtil::Explode(filePathAndChecksum, ":");
if (filePathAndChecksumSplit.size() != 2)
continue;
string fileName = filePathAndChecksumSplit[0];
string locPath = string(appDataPath) + "\\InternetRadio\\"
+ fileName;
StringUtil::SearchAndReplace(locPath, "/", "\\");
string remoteChecksum = filePathAndChecksumSplit[1];
bool update = false;
ifstream fileStream(locPath);
if (fileStream.is_open()) {
fileStream.close();
string localChecksum = CryptUtil::FileMD5Hash(locPath);
if (remoteChecksum != localChecksum)
update = true;
} else {
update = true;
}
if (!update)
continue;
string fileRemURL =
"http://internetradio.clemensboos.net/stations/" +
ssVer.str() + "/" + fileName;
StringUtil::SearchAndReplace(fileRemURL, "\\", "/");
stringstream ssRemFile;
try {
HTTP::Get(fileRemURL, &ssRemFile);
} catch(...) {
continue;
}
string locDir = locPath.substr(0,
locPath.find_last_of("\\"));
CreateDirectory(locDir.c_str(), nullptr);
//.........这里部分代码省略.........