本文整理汇总了C++中BinaryNode::getRAW方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryNode::getRAW方法的具体用法?C++ BinaryNode::getRAW怎么用?C++ BinaryNode::getRAW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryNode
的用法示例。
在下文中一共展示了BinaryNode::getRAW方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromOtb
bool ItemDatabase::loadFromOtb(const FileName& datafile, wxString& error, wxArrayString& warnings)
{
std::string filename = nstr((datafile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + datafile.GetFullName()));
DiskNodeFileReadHandle f(filename, StringVector(1, "OTBI"));
if(!f.isOk()) {
error = wxT("Couldn't open file \"") + wxstr(filename) + wxT("\":") + wxstr(f.getErrorMessage());
return false;
}
BinaryNode* root = f.getRootNode();
#define safe_get(node, func, ...) do {\
if(!node->get##func(__VA_ARGS__)) {\
error = wxstr(f.getErrorMessage()); \
return false; \
} \
} while(false)
// Read root flags
root->skip(1); // Type info
//uint32_t flags =
root->skip(4); // Unused?
uint8_t attr;
safe_get(root, U8, attr);
if(attr == ROOT_ATTR_VERSION) {
uint16_t datalen;
if(!root->getU16(datalen) || datalen != 4 + 4 + 4 + 1*128) {
error = wxT("items.otb: Size of version header is invalid, updated .otb version?");
return false;
}
safe_get(root, U32, MajorVersion); // items otb format file version
safe_get(root, U32, MinorVersion); // client version
safe_get(root, U32, BuildNumber); // revision
std::string csd;
csd.resize(128);
if(!root->getRAW((uint8_t*)csd.data(), 128)) { // CSDVersion ??
error = wxstr(f.getErrorMessage());
return false;
}
} else {
error = wxT("Expected ROOT_ATTR_VERSION as first node of items.otb!");
}
if(settings.getInteger(Config::CHECK_SIGNATURES)) {
if(gui.GetCurrentVersion().getOTBVersion().format_version != MajorVersion) {
error = wxT("Unsupported items.otb version (version ") + i2ws(MajorVersion) + wxT(")");
return false;
}
}
BinaryNode* itemNode = root->getChild();
switch(MajorVersion) {
case 1: return loadFromOtbVer1(itemNode, error, warnings);
case 2: return loadFromOtbVer2(itemNode, error, warnings);
case 3: return loadFromOtbVer3(itemNode, error, warnings);
}
return true;
}