bool FrmReports::parseXMLFile(const QString itemName, QString& strName, QString& strAuthor, QString& strPixmap, QString& strDescription) { QString strFileName(qApp->translate("dir", strReportsDir) + tr("\\") + itemName + tr(".bdrt")); QFile file(strFileName); if (!file.exists()) return false; if (!file.open(QFile::ReadOnly | QFile::Text)) return false; //Just try to parse the xml QXmlSimpleReader xmlReader; QXmlInputSource *source = new QXmlInputSource(&file); if (!xmlReader.parse(source)) { file.close(); //exit, but close the file first! return false; } delete source; file.close(); //Initialize the reader if (!file.open(QFile::ReadOnly | QFile::Text)) return false; QXmlStreamReader xml(&file); if (!readProperties(xml, strName, strAuthor, strPixmap, strDescription)) return false; file.close(); return true; }
bool QgsPaintEffect::readProperties( const QDomElement &element ) { if ( element.isNull() ) { return false; } //default implementation converts to a string map QgsStringMap props; QDomElement e = element.firstChildElement(); while ( !e.isNull() ) { if ( e.tagName() != QLatin1String( "prop" ) ) { QgsDebugMsg( "unknown tag " + e.tagName() ); } else { QString propKey = e.attribute( QStringLiteral( "k" ) ); QString propValue = e.attribute( QStringLiteral( "v" ) ); props[propKey] = propValue; } e = e.nextSiblingElement(); } readProperties( props ); return true; }
void Text::read(XmlReader* r) { while (r->readElement()) { if (!readProperties(r)) r->unknown(); } }
bool OleStorage::init(shared_ptr<ZLInputStream> stream, size_t streamSize) { clear(); myInputStream = stream; myStreamSize = streamSize; myInputStream->seek(0, true); char oleBuf[BBD_BLOCK_SIZE]; size_t ret = myInputStream->read(oleBuf, BBD_BLOCK_SIZE); if (ret != BBD_BLOCK_SIZE) { clear(); return false; } static const char OLE_SIGN[] = {0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1, 0}; if (strncmp(oleBuf, OLE_SIGN, 8) != 0) { clear(); return false; } mySectorSize = 1 << OleUtil::getU2Bytes(oleBuf, 0x1e); //offset for value of big sector size myShortSectorSize = 1 << OleUtil::getU2Bytes(oleBuf, 0x20); //offset for value of small sector size if (readDIFAT(oleBuf) && readBBD(oleBuf) && readSBD(oleBuf) && readProperties(oleBuf) && readAllEntries()) { return true; } clear(); return false; }
MobV2SAO::MobV2SAO(ServerEnvironment *env, v3f pos, Settings *init_properties): ServerActiveObject(env, pos), m_move_type("ground_nodes"), m_speed(0,0,0), m_last_sent_position(0,0,0), m_oldpos(0,0,0), m_yaw(0), m_counter1(0), m_counter2(0), m_age(0), m_touching_ground(false), m_hp(10), m_walk_around(false), m_walk_around_timer(0), m_next_pos_exists(false), m_shoot_reload_timer(0), m_shooting(false), m_shooting_timer(0), m_falling(false), m_disturb_timer(100000), m_random_disturb_timer(0), m_shoot_y(0) { ServerActiveObject::registerType(getType(), create); m_properties = new Settings(); if(init_properties) m_properties->update(*init_properties); m_properties->setV3F("pos", pos); setPropertyDefaults(); readProperties(); }
static void sendParamsByMail(char ifname[], char user[], char pptpd_original_ip[]) { printf("test: sendParamsByMail\n"); char to[1000]; char body[] = "PPTPD log in by "; char sep[] = " | "; strcat(body, user); strcat(body, sep); strcat(body, ifname); strcat(body, sep); strcat(body, pptpd_original_ip); printf("test: strcat: %s\n", body); // char *buf; // size_t sz; // sz = snprintf(NULL, 0, "select key from answer WHERE key = %s LIMIT 5;", tmp); // buf = (char *)malloc(sz + 1); /* make sure you check for != NULL in real code */ // snprintf(buf, sz+1, "select key from answer WHERE key = %s LIMIT 5;", tmp); readProperties(to); //printf("test: main result: %s\n", to); sendMail(to, body); }
void Text::read(const QDomElement& de) { for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!readProperties(e)) domError(e); } }
void Ambitus::read(XmlReader& e) { while (e.readNextStartElement()) { if (!readProperties(e)) e.unknown(); } }
// --- std::map <int, QGAMES::BasicBoardAddsOn::SquareDefinition> QGAMES::BasicBoardAddsOn::readSquares (TiXmlElement* e) { std::map <int, QGAMES::BasicBoardAddsOn::SquareDefinition> result; for (TiXmlElement* element = e -> FirstChildElement (); element != NULL; element = element -> NextSiblingElement ()) { QGAMES::BasicBoardAddsOn::SquareDefinition def; element -> Attribute (__QGAMES_BOARDSQUAREATTRID__, &def._id); for (TiXmlElement* subElement = element -> FirstChildElement (); subElement != NULL; subElement = subElement -> NextSiblingElement ()) { if (strcmp (subElement -> Value (), __QGAMES_BOARDRESOURCESTAG__) == 0) def._resources = readResources (subElement); if (strcmp (subElement -> Value (), __QGAMES_BOARDDATASTAG__) == 0) def._properties = readProperties (subElement); } result.insert (std::map <int, QGAMES::BasicBoardAddsOn::SquareDefinition>::value_type (def._id, def)); } return (result); }
ViewProperties::PropertiesNode::PropertiesNode(QFile* file) : m_empty(true) { m_isValidForSubDirs = false; if ((file != 0) && file->open(IO_ReadOnly)) { m_empty = false; const int max_len = 41; static char buffer[max_len]; // TODO: use memset for (int i = 0; i < max_len; ++i) { buffer[i] = 0; } file->readLine(buffer, max_len); // Check version of viewproperties file. The initial format // sadly had no version numbering, which is indicated by a missing 'V' // as first letter. The current scheme uses V + 2 digits. int version = 0; int startInc = 0; if (buffer[0] == 'V') { startInc = 3; // skip version info (e. g. V01) version = 1; // currently no further versions are available: assert(buffer[1] == '0'); assert(buffer[2] == '1'); } int readBytes = readProperties(m_props, &buffer[startInc], version); assert(readBytes >= 0); // check whether sub directory properties are available m_isValidForSubDirs = (buffer[startInc + readBytes] != '0'); if (m_isValidForSubDirs) { readBytes = readProperties(m_subDirProps, &buffer[startInc + readBytes + 1], version); } file->close(); m_empty = (readBytes <= 0); } }
//=================== // LInputDevice Class //=================== // === PUBLIC === LInputDevice::LInputDevice(unsigned int id, unsigned int type){ devID = id; devType = type; //ATOM_FLOAT = 0; //init this when needed later //devName = name; getProperties(); //need to populate the name/atom correlations for properties readProperties(); //populate the hash with the current values of the properties }
/** * Returns the value of a specified property. * @param property * @return */ std::string readProperty(std::string property) { readProperties(); if (testForProperty(property)) { return properties[property].property; } else { return NULL; } }
SoundSource::OpenResult SoundSourceMediaFoundation::tryOpen(const AudioSourceConfig& audioSrcCfg) { if (SUCCEEDED(m_hrCoInitialize)) { qWarning() << "Cannot reopen MediaFoundation file" << getUrlString(); return OpenResult::FAILED; } const QString fileName(getLocalFileName()); if (sDebug) { qDebug() << "open()" << fileName; } // Initialize the COM library. m_hrCoInitialize = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(m_hrCoInitialize)) { qWarning() << "SSMF: failed to initialize COM"; return OpenResult::FAILED; } // Initialize the Media Foundation platform. m_hrMFStartup = MFStartup(MF_VERSION); if (FAILED(m_hrCoInitialize)) { qWarning() << "SSMF: failed to initialize Media Foundation"; return OpenResult::FAILED; } // Create the source reader to read the input file. // Note: we cannot use QString::toStdWString since QT 4 is compiled with // '/Zc:wchar_t-' flag and QT 5 not const ushort* const fileNameUtf16 = fileName.utf16(); static_assert(sizeof(wchar_t) == sizeof(ushort), "QString::utf16(): wchar_t and ushort have different sizes"); HRESULT hr = MFCreateSourceReaderFromURL( reinterpret_cast<const wchar_t*>(fileNameUtf16), nullptr, &m_pReader); if (FAILED(hr)) { qWarning() << "SSMF: Error opening input file:" << fileName; return OpenResult::FAILED; } if (!configureAudioStream(audioSrcCfg)) { qWarning() << "SSMF: Error configuring audio stream."; return OpenResult::FAILED; } if (!readProperties()) { qWarning() << "SSMF::readProperties failed"; return OpenResult::FAILED; } //Seek to position 0, which forces us to skip over all the header frames. //This makes sure we're ready to just let the Analyzer rip and it'll //get the number of samples it expects (ie. no header frames). seekSampleFrame(0); return OpenResult::SUCCEEDED; }
void Ottava::read(XmlReader& e) { qDeleteAll(spannerSegments()); spannerSegments().clear(); e.addSpanner(e.intAttribute("id", -1), this); while (e.readNextStartElement()) readProperties(e); updateStyledProperties(); }
void polyForceTwoShear::updateProperties(const dictionary& newDict) { //- the main controller properties should be updated first updateStateControllerProperties(newDict); propsDict_ = newDict.subDict(typeName + "Properties"); readProperties(); }
/** * Removes a property from the property file. Returns true on success. * @param key * @return */ bool removeProperty(std::string key) { readProperties(); if (testForProperty(key)) { properties.erase(key); flush(); return true; } else { return false; } }
void TextStyleData::read(XmlReader& e) { frameWidth = Spatium(0.0); name = e.attribute("name"); while (e.readNextStartElement()) { if (!readProperties(e)) e.unknown(); } }
void StaffTextBase::read(XmlReader& e) { for (int voice = 0; voice < VOICES; ++voice) _channelNames[voice].clear(); clearAeolusStops(); while (e.readNextStartElement()) { if (!readProperties(e)) e.unknown(); } }
Properties::Properties(FILE* file, const char* name, const char* id) : _namespace(name) { if (id) { _id = id; } readProperties(file); _propertiesItr = _properties.end(); _namespacesItr = _namespaces.end(); }
void Ottava::read(XmlReader& e) { eraseSpannerSegments(); if (score()->mscVersion() < 301) e.addSpanner(e.intAttribute("id", -1), this); while (e.readNextStartElement()) readProperties(e); if (_ottavaType != OttavaType::OTTAVA_8VA || _numbersOnly != propertyDefault(Pid::NUMBERS_ONLY).toBool()) styleChanged(); }
// Reads the input file into memory returning 1 if it // was read unsuccessfully, otherwise 0. DataSetInitStatus readFile(char* fileName) { DataSetInitStatus status = DATA_SET_INIT_STATUS_SUCCESS; FILE *inputFilePtr; // Open the file and hold on to the pointer. inputFilePtr = fopen(fileName, "rb"); // If the file didn't open return -1. if (inputFilePtr == NULL) { return DATA_SET_INIT_STATUS_FILE_NOT_FOUND; } // Read the various data segments if the version is // one we can read. status = readVersion(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } status = readCopyright(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } status = readStrings(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } status = readProperties(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } status = readDevices(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } status = readLookupList(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } status = readNodes(inputFilePtr); if (status != DATA_SET_INIT_STATUS_SUCCESS) { fclose(inputFilePtr); return status; } fclose(inputFilePtr); return status; }
void Part::read(XmlReader& e) { while (e.readNextStartElement()) { if (readProperties(e)) ; else e.unknown(); } if (_partName.isEmpty()) _partName = instrument()->trackName(); }
void TextLine::read(const QDomElement& de) { foreach(SpannerSegment* seg, spannerSegments()) delete seg; spannerSegments().clear(); setId(de.attribute("id", "-1").toInt()); for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (!readProperties(e)) domError(e); } }
void TextLine::read(XmlReader& e) { qDeleteAll(spannerSegments()); spannerSegments().clear(); setId(e.intAttribute("id", -1)); while (e.readNextStartElement()) { if (!readProperties(e)) e.unknown(); } }
void SimpleAbstractStreamReader::readChild(AST::UiObjectDefinition *uiObjectDefinition) { Q_ASSERT(uiObjectDefinition); setSourceLocation(uiObjectDefinition->firstSourceLocation()); elementStart(toString(uiObjectDefinition->qualifiedTypeNameId)); readProperties(uiObjectDefinition); readChildren(uiObjectDefinition); elementEnd(); }
/** * Adds a property to the property file. Returns true on success. * @param key * @param value * @return */ bool addProperty(std::string key, std::string value) { readProperties(); if (testForProperty(key)) { return false; } else { Property buffer; buffer.property = value; buffer.line = last_line + 1; properties.insert(std::pair<std::string, Property>(key, buffer)); flush(); return true; } }
/** * Modifies a property. * @param key * @param value * @return */ bool modifyProperty(std::string key, std::string value) { readProperties(); if (testForProperty(key)) { std::map<std::string, Property>::mapped_type buffer = properties[key]; buffer.property = value; properties.erase(key); properties.insert(std::pair<std::string, Property>(key, buffer)); flush(); return true; } else { return false; } }
Properties::Properties(Data* data, ssize_t* dataIdx, const std::string& name, const char* id, const char* parentID, Properties* parent) : _namespace(name), _variables(NULL), _dirPath(NULL), _parent(parent), _dataIdx(dataIdx), _data(data) { if (id) { _id = id; } if (parentID) { _parentID = parentID; } readProperties(); rewind(); }
int SoundSourceMediaFoundation::open() { if (sDebug) { qDebug() << "open()" << m_qFilename; } QString qurlStr(m_qFilename); int wcFilenameLength(m_qFilename.toWCharArray(m_wcFilename)); // toWCharArray does not append a null terminator to the string! m_wcFilename[wcFilenameLength] = '\0'; HRESULT hr(S_OK); // Initialize the COM library. hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hr)) { qWarning() << "SSMF: failed to initialize COM"; return ERR; } // Initialize the Media Foundation platform. hr = MFStartup(MF_VERSION); if (FAILED(hr)) { qWarning() << "SSMF: failed to initialize Media Foundation"; return ERR; } // Create the source reader to read the input file. hr = MFCreateSourceReaderFromURL(m_wcFilename, NULL, &m_pReader); if (FAILED(hr)) { qWarning() << "SSMF: Error opening input file:" << m_qFilename; return ERR; } if (!configureAudioStream()) { qWarning() << "SSMF: Error configuring audio stream."; return ERR; } if (!readProperties()) { qWarning() << "SSMF::readProperties failed"; return ERR; } //Seek to position 0, which forces us to skip over all the header frames. //This makes sure we're ready to just let the Analyser rip and it'll //get the number of samples it expects (ie. no header frames). seek(0); return OK; }
/** Pops a job from the queue @param job: the output job being popped @return: 1 if it worked; 0 otherwise */ int JobQueue::popJob(job_descriptor* job) { queue_properties props = readProperties(); if(props.jobCount > 0){ int charIndex = props.tailIndex*sizeof(job_descriptor) + sizeof(queue_properties); memory->read((void*)job,charIndex,sizeof(job_descriptor)); props.tailIndex = props.tailIndex + 1; props.jobCount = props.jobCount - 1; writeProperties(props); return 1; } return 0; }