本文整理汇总了C++中RawData::getDataLength方法的典型用法代码示例。如果您正苦于以下问题:C++ RawData::getDataLength方法的具体用法?C++ RawData::getDataLength怎么用?C++ RawData::getDataLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RawData
的用法示例。
在下文中一共展示了RawData::getDataLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isLoadable
bool AnimationLoader::isLoadable(const std::string& filename) {
bfs::path animPath(filename);
std::string animationFilename = animPath.string();
try {
RawData* data = m_vfs->open(animationFilename);
if (data) {
if (data->getDataLength() != 0) {
// TODO - this could be expanded to do more checks
TiXmlDocument doc;
doc.Parse(data->readString(data->getDataLength()).c_str());
if (doc.Error()) {
return false;
}
}
// done with data delete resource
delete data;
data = 0;
}
}
catch (NotFound&) {
return false;
}
return true;
}
示例2: load
AnimationPtr AnimationLoader::load(const std::string& filename) {
bfs::path animPath(filename);
std::string animationFilename = animPath.string();
TiXmlDocument doc;
AnimationPtr animation;
try {
RawData* data = m_vfs->open(animationFilename);
if (data) {
if (data->getDataLength() != 0) {
doc.Parse(data->readString(data->getDataLength()).c_str());
if (doc.Error()) {
return animation;
}
// done with data delete resource
delete data;
data = 0;
}
}
}
catch (NotFound& e) {
FL_ERR(_log, e.what());
// TODO - should we abort here
// or rethrow the exception
// or just keep going
return animation;
}
// if we get here then everything loaded properly
// so we can just parse out the contents
TiXmlElement* root = doc.RootElement();
if (root) {
animation.reset(new Animation());
int animDelay = 0;
root->QueryValueAttribute("delay", &animDelay);
int animXoffset = 0;
int animYoffset = 0;
int action = -1;
root->QueryValueAttribute("x_offset", &animXoffset);
root->QueryValueAttribute("y_offset", &animYoffset);
root->QueryValueAttribute("action", &action);
for (TiXmlElement* frameElement = root->FirstChildElement("frame"); frameElement; frameElement = frameElement->NextSiblingElement("frame")) {
if (animation) {
animation->setActionFrame(action);
const std::string* sourceId = frameElement->Attribute(std::string("source"));
if (sourceId) {
bfs::path framePath(filename);
if (HasParentPath(framePath)) {
framePath = GetParentPath(framePath) / *sourceId;
} else {
framePath = bfs::path(*sourceId);
}
ImagePtr imagePtr;
if(!m_imageManager->exists(framePath.string())) {
imagePtr = m_imageManager->create(framePath.string());
}
else {
imagePtr = m_imageManager->getPtr(framePath.string());
}
if (imagePtr) {
int frameXoffset = 0;
int frameYoffset = 0;
int success = root->QueryValueAttribute("x_offset", &frameXoffset);
if (success == TIXML_SUCCESS) {
imagePtr->setXShift(frameXoffset);
}
else {
imagePtr->setXShift(animXoffset);
}
success = root->QueryValueAttribute("y_offset", &frameYoffset);
if (success == TIXML_SUCCESS) {
imagePtr->setYShift(frameYoffset);
}
else {
imagePtr->setYShift(animYoffset);
}
int frameDelay = 0;
success = root->QueryValueAttribute("delay", &frameDelay);
//.........这里部分代码省略.........