TGUI_API Widget::Ptr loadPanel(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { if (widget) return loadContainer(node, std::static_pointer_cast<Panel>(widget)); else return loadContainer(node, std::make_shared<Panel>()); }
bool CppcheckLibraryData::open(QIODevice &file) { clear(); QStringList comments; QXmlStreamReader xmlReader(&file); while (!xmlReader.atEnd()) { const QXmlStreamReader::TokenType t = xmlReader.readNext(); switch (t) { case QXmlStreamReader::Comment: comments.append(xmlReader.text().toString()); break; case QXmlStreamReader::StartElement: if (xmlReader.name() == "container") containers.append(loadContainer(xmlReader)); if (xmlReader.name() == "define") defines.append(loadDefine(xmlReader)); else if (xmlReader.name() == "function") functions.append(loadFunction(xmlReader, comments)); else if (xmlReader.name() == "memory" || xmlReader.name() == "resource") memoryresource.append(loadMemoryResource(xmlReader)); else if (xmlReader.name() == "podtype") podtypes.append(loadPodType(xmlReader)); comments.clear(); break; default: break; } } return true; }
void VideoDecoder::loadFile(char* filename, VideoBufferInfo *bufferInfo) { if(fileLoaded) { logError("[VideoPlayer::loadFile] Tried to load a new file. Ignoring...\n"); return; } if(filename == NULL || strcmp(filename, "")==0) { logError("[VideoPlayer::loadFile] Invalid arguments supplied!\n"); throw std::invalid_argument("Filename should not be empty!"); } if(debugLoggingActive) { //Print all available information about the streams inside of the file. av_dump_format(formatContext, 0, filename, 0); } //Try to open the file int err = avformat_open_input(&formatContext, filename, NULL, NULL); if(err < 0) { char error[1024]; av_strerror(err, error, 1024); logError("[VideoPlayer::loadFile] Error opening file (%s): %s\n", filename, error); throw std::runtime_error("Could not open file!"); } loadContainer(bufferInfo); }
void VideoDecoder::loadFile(FillFileBufferFunc func, void* funcData, CleanupFunc cleanupFunc, VideoBufferInfo* bufferInfo) { if(fileLoaded) { logError("[VideoPlayer::loadFile] Tried to load a new file. Ignoring...\n"); return; } if(func == NULL) { logError("[VideoPlayer::loadFile] Invalid arguments supplied!\n"); throw std::invalid_argument("FillFileBufferFunc should be a valid function"); } fillFileBufferFunc = func; customFileBufferFuncData = funcData; this->cleanupFunc = cleanupFunc; avioBuffer = (u_int8_t*)av_malloc(CUSTOMIO_BUFFER_SIZE); avioContext = avio_alloc_context(avioBuffer, CUSTOMIO_BUFFER_SIZE, 0, (void*)this, &readFunction, NULL, NULL); formatContext = avformat_alloc_context(); formatContext->pb = avioContext; int err = avformat_open_input(&formatContext, "dummyFileName", NULL, NULL);if(err < 0) { char error[1024]; av_strerror(err, error, 1024); logError("[VideoPlayer::loadFile] Error opening file: %s\n", error); throw std::runtime_error("Could not open file!"); } loadContainer(bufferInfo); }
int FwLoader::load(const char *path, unsigned int pid) { if (!dev.open(IODevice::SIFTEO_VID, pid)) { fprintf(stderr, "Note: Please ensure your device is in update mode, with the red LED illuminated\n"); return ENODEV; } FILE *f = fopen(path, "rb"); if (!f) { fprintf(stderr, "could not open %s: %s\n", path, strerror(errno)); return ENOENT; } uint64_t magic; if (fread(&magic, sizeof(magic), 1, f) != 1) { fprintf(stderr, "magic number mismatch\n"); return EIO; } int rv; if (magic == Deployer::MAGIC) { rv = loadSingle(f); } else if (magic == Deployer::MAGIC_CONTAINER) { rv = loadContainer(f); } else { fprintf(stderr, "invalid file format\n"); rv = EINVAL; } fclose(f); return rv; }
db_x509req::db_x509req(QString DBfile, MainWindow *mw) :db_x509super(DBfile, mw) { class_name = "requests"; pkitype << x509_req; updateHeaders(); loadContainer(); }
db_key::db_key(MainWindow *mw) :db_base(mw) { class_name = "keys"; sqlHashTable = "public_keys"; pkitype << asym_key << smartCard; updateHeaders(); loadContainer(); }
bool Item::loadItem(xmlNodePtr node, Container* parent) { if(!xmlStrcmp(node->name, (const xmlChar*)"item")) return false; int32_t intValue; std::string strValue; Item* item = NULL; if(readXMLInteger(node, "id", intValue)) item = Item::CreateItem(intValue); if(!item) return false; if(readXMLString(node, "attributes", strValue)) { StringVec v, attr = explodeString(strValue, ";"); for(StringVec::iterator it = attr.begin(); it != attr.end(); ++it) { v = explodeString((*it), ","); if(v.size() < 2) continue; if(atoi(v[1].c_str()) || v[1] == "0") item->setAttribute(v[0].c_str(), atoi(v[1].c_str())); else item->setAttribute(v[0].c_str(), v[1]); } } //compatibility if(readXMLInteger(node, "subtype", intValue) || readXMLInteger(node, "subType", intValue)) item->setSubType(intValue); if(readXMLInteger(node, "actionId", intValue) || readXMLInteger(node, "actionid", intValue) || readXMLInteger(node, "aid", intValue)) item->setActionId(intValue); if(readXMLInteger(node, "uniqueId", intValue) || readXMLInteger(node, "uniqueid", intValue) || readXMLInteger(node, "uid", intValue)) item->setUniqueId(intValue); if(readXMLString(node, "text", strValue)) item->setText(strValue); if(item->getContainer()) loadContainer(node, item->getContainer()); if(parent) parent->addItem(item); return true; }
db_x509req::db_x509req(QString DBfile, MainWindow *mw) :db_x509super(DBfile, mw) { allHeaders << new dbheader(HD_req_signed, true, tr("Signed"), tr("whether the request is already signed or not")) << new dbheader(HD_req_unstr_name, false, tr("Unstructured name")) << new dbheader(HD_req_chall_pass, false, tr("Challange password")); class_name = "requests"; pkitype << x509_req; loadContainer(); }
db_key::db_key(QString db, MainWindow *mw) :db_base(db, mw) { rootItem->setIntName("[key root]"); class_name = "keys"; pkitype << asym_key << smartCard; allHeaders << new dbheader(HD_key_type, true, tr("Type")) << new dbheader(HD_key_size, true, tr("Size")) << new dbheader(HD_key_use, true, tr("Use")) << new dbheader(HD_key_passwd, true, tr("Password")); loadContainer(); }
bool Item::loadItem(xmlNodePtr node, Container* parent) { if (xmlStrcmp(node->name, (const xmlChar*)"item") == 0) { int32_t intValue; std::string strValue; Item* item = NULL; if (readXMLInteger(node, "id", intValue)) { item = Item::CreateItem(intValue); } if (!item) { return false; } //optional if (readXMLInteger(node, "subtype", intValue)) { item->setSubType(intValue); } if (readXMLInteger(node, "actionid", intValue)) { item->setActionId(intValue); } if (readXMLString(node, "text", strValue)) { item->setText(strValue); } if (item->getContainer()) { loadContainer(node, item->getContainer()); } if (parent) { parent->addItem(item); } return true; } return false; }
TGUI_API Widget::Ptr loadChildWindow(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { ChildWindow::Ptr childWindow; if (widget) childWindow = std::static_pointer_cast<ChildWindow>(widget); else childWindow = std::make_shared<ChildWindow>(); if (node->propertyValuePairs["titlealignment"]) { if (toLower(node->propertyValuePairs["titlealignment"]->value) == "left") childWindow->setTitleAlignment(ChildWindow::TitleAlignment::Left); else if (toLower(node->propertyValuePairs["titlealignment"]->value) == "center") childWindow->setTitleAlignment(ChildWindow::TitleAlignment::Center); else if (toLower(node->propertyValuePairs["titlealignment"]->value) == "right") childWindow->setTitleAlignment(ChildWindow::TitleAlignment::Right); else throw Exception{"Failed to parse TitleAlignment property. Only the values Left, Center and Right are correct."}; } if (node->propertyValuePairs["title"]) childWindow->setTitle(DESERIALIZE_STRING("title")); if (node->propertyValuePairs["icon"]) childWindow->setIcon(Deserializer::deserialize(ObjectConverter::Type::Texture, node->propertyValuePairs["icon"]->value).getTexture()); if (node->propertyValuePairs["keepinparent"]) childWindow->keepInParent(parseBoolean(node->propertyValuePairs["keepinparent"]->value)); for (auto& childNode : node->children) { if (toLower(childNode->name) == "closebutton") childWindow->setCloseButton(std::static_pointer_cast<Button>(WidgetLoader::getLoadFunction("button")(childNode))); } REMOVE_CHILD("closebutton"); loadContainer(node, childWindow); return childWindow; }
bool IOMapSerialize::loadItem(PropStream& propStream, Cylinder* parent, bool depotTransfer/* = false*/) { Tile* tile = NULL; if(!parent->getItem()) tile = parent->getTile(); uint16_t id = 0; propStream.getShort(id); Item* item = NULL; const ItemType& iType = Item::items[id]; if(iType.movable || iType.forceSerialize || (!depotTransfer && !tile)) { if(!(item = Item::CreateItem(id))) return true; if(!item->unserializeAttr(propStream)) { std::clog << "[Warning - IOMapSerialize::loadItem] Unserialization error [0] for item type " << id << std::endl; delete item; return false; } if(Container* container = item->getContainer()) { if(!loadContainer(propStream, container)) { delete item; return false; } } if(parent) { parent->__internalAddThing(item); item->__startDecaying(); } else delete item; return true; } if(tile) { //Stationary items if(TileItemVector* items = tile->getItemList()) { for(ItemVector::iterator it = items->begin(); it != items->end(); ++it) { if((*it)->getID() == id) { item = *it; break; } if(iType.isBed() && (*it)->getBed()) { item = *it; break; } if(iType.isDoor() && (*it)->getDoor()) { item = *it; break; } } } } if(item) { if(item->unserializeAttr(propStream)) { Container* container = item->getContainer(); if(container && !loadContainer(propStream, container)) return false; if(!item->getDoor() || item->getID() == iType.transformUseTo) item = g_game.transformItem(item, id); } else std::clog << "[Warning - IOMapSerialize::loadItem] Unserialization error [1] for item type " << id << std::endl; return true; } //The map changed since the last save, just read the attributes if(!(item = Item::CreateItem(id))) return true; item->unserializeAttr(propStream); if(Container* container = item->getContainer()) { if(!loadContainer(propStream, container)) { delete item; return false; } if(depotTransfer) { for(ItemList::const_iterator it = container->getItems(); it != container->getEnd(); ++it) parent->__addThing(NULL, (*it)); container->itemlist.clear(); } } delete item; return true; }
bool IOMapSerialize::loadItem(PropStream& propStream, Cylinder* parent) { uint16_t id; if (!propStream.read<uint16_t>(id)) { return false; } Tile* tile = nullptr; if (parent->getParent() == nullptr) { tile = parent->getTile(); } const ItemType& iType = Item::items[id]; if (iType.moveable || !tile) { //create a new item Item* item = Item::CreateItem(id); if (item) { if (item->unserializeAttr(propStream)) { Container* container = item->getContainer(); if (container && !loadContainer(propStream, container)) { delete item; return false; } parent->internalAddThing(item); item->startDecaying(); } else { std::cout << "WARNING: Unserialization error in IOMapSerialize::loadItem()" << id << std::endl; delete item; return false; } } } else { // Stationary items like doors/beds/blackboards/bookcases Item* item = nullptr; if (const TileItemVector* items = tile->getItemList()) { for (Item* findItem : *items) { if (findItem->getID() == id) { item = findItem; break; } else if (iType.isDoor() && findItem->getDoor()) { item = findItem; break; } else if (iType.isBed() && findItem->getBed()) { item = findItem; break; } } } if (item) { if (item->unserializeAttr(propStream)) { Container* container = item->getContainer(); if (container && !loadContainer(propStream, container)) { return false; } g_game.transformItem(item, id); } else { std::cout << "WARNING: Unserialization error in IOMapSerialize::loadItem()" << id << std::endl; } } else { //The map changed since the last save, just read the attributes std::unique_ptr<Item> dummy(Item::CreateItem(id)); if (dummy) { dummy->unserializeAttr(propStream); Container* container = dummy->getContainer(); if (container) { if (!loadContainer(propStream, container)) { return false; } } else if (BedItem* bedItem = dynamic_cast<BedItem*>(dummy.get())) { uint32_t sleeperGUID = bedItem->getSleeper(); if (sleeperGUID != 0) { g_game.removeBedSleeper(sleeperGUID); } } } } } return true; }
bool IOMapSerialize::loadItem(PropStream& propStream, Cylinder* parent) { Item* item = NULL; uint16_t id = 0; propStream.GET_USHORT(id); const ItemType& iType = Item::items[id]; Tile* tile = NULL; if (parent->getParent() == NULL) { tile = parent->getTile(); } if (iType.moveable || !tile) { //create a new item item = Item::CreateItem(id); if (item) { if (item->unserializeAttr(propStream)) { Container* container = item->getContainer(); if (container && !loadContainer(propStream, container)) { delete item; return false; } parent->__internalAddThing(item); item->__startDecaying(); } else { std::cout << "WARNING: Unserialization error in IOMapSerialize::loadItem()" << id << std::endl; delete item; return false; } } } else { // Stationary items like doors/beds/blackboards/bookcases if (const TileItemVector* items = tile->getItemList()) { for (ItemVector::const_iterator it = items->begin(), end = items->end(); it != end; ++it) { Item* findItem = (*it); if (findItem->getID() == id) { item = findItem; break; } else if (iType.isDoor() && findItem->getDoor()) { item = findItem; break; } else if (iType.isBed() && findItem->getBed()) { item = findItem; break; } } } if (item) { if (item->unserializeAttr(propStream)) { Container* container = item->getContainer(); if (container && !loadContainer(propStream, container)) { return false; } item = g_game.transformItem(item, id); } else { std::cout << "WARNING: Unserialization error in IOMapSerialize::loadItem()" << id << std::endl; } } else { //The map changed since the last save, just read the attributes Item* dummy = Item::CreateItem(id); if (dummy) { dummy->unserializeAttr(propStream); Container* container = dummy->getContainer(); if (container && !loadContainer(propStream, container)) { delete dummy; return false; } delete dummy; } } } return true; }