/// Parses relation as simple relation with non-relation children. If child is single, then
 /// calls visitor with this child instead of relation.
 void processSimpleRelation(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   auto relation = parseRelation(featureId, feature.get_child("geometry.coordinates"));
   if (relation.elements.size()==1) {
     parseProperties(*relation.elements[0], featureId, feature.get_child("properties"));
     visitor.add(*relation.elements[0]);
   } else {
     parseProperties(relation, featureId, feature.get_child("properties"));
     visitor.add(relation);
   }
 }
// File 'complex.mkv': container: Matroska [duration:106752000000 segment_uid:00000000000000000000000000000000]
void
FileIdentifier::parseContainerLine(QString const &line) {
  QRegExp re{"^File\\s.*container:\\s+([^\\[]+)"};

  if (-1 == re.indexIn(line))
    return;

  m_file->setContainer(re.cap(1));
  m_file->m_properties       = parseProperties(line);
  m_file->m_isPlaylist       = m_file->m_properties["playlist"] == "1";
  m_file->m_playlistDuration = m_file->m_properties["playlist_duration"].toULongLong();
  m_file->m_playlistSize     = m_file->m_properties["playlist_size"].toULongLong();
  m_file->m_playlistChapters = m_file->m_properties["playlist_chapters"].toULongLong();

  if (m_file->m_isPlaylist && !m_file->m_properties["playlist_file"].isEmpty())
    for (auto const &fileName : m_file->m_properties["playlist_file"].split("\t"))
      m_file->m_playlistFiles << QFileInfo{fileName};

  if (m_file->m_properties["other_file"].isEmpty())
    return;

  for (auto &fileName : m_file->m_properties["other_file"].split("\t")) {
    auto additionalPart              = std::make_shared<SourceFile>(fileName);
    additionalPart->m_additionalPart = true;
    additionalPart->m_appendedTo     = m_file.get();
    m_file->m_additionalParts       << additionalPart;
  }
}
bool LuaScript::load(FS::IFile& file)
{
	m_properties.clear();
	m_source_code.set((const char*)file.getBuffer(), (int)file.size());
	parseProperties();
	m_size = file.size();
	return true;
}
Beispiel #4
0
        Model::EntityDefinition* DefParser::nextDefinition() {
            Token token = m_tokenizer.nextToken();
            while (token.type() != Eof && token.type() != ODefinition)
                token = m_tokenizer.nextToken();
            if (token.type() == Eof)
                return NULL;

            expect(ODefinition, token);
            
            StringList baseClasses;
            ClassInfo classInfo;
            
            token = m_tokenizer.nextToken();
            expect(Word, token);
            classInfo.name = token.data();

            token = m_tokenizer.peekToken();
            expect(OParenthesis | Newline, token);
            if (token.type() == OParenthesis) {
                classInfo.setColor(parseColor());
                
                token = m_tokenizer.peekToken();
                expect(OParenthesis | Question, token);
                if (token.type() == OParenthesis) {
                    classInfo.setSize(parseBounds());
                } else {
                    m_tokenizer.nextToken();
                }
                
                token = m_tokenizer.peekToken();
                if (token.type() == Word) {
                    Model::FlagsPropertyDefinition::Ptr spawnflags = parseFlags();
                    classInfo.properties[spawnflags->name()] = spawnflags;
                }
            }

            expect(Newline, token = m_tokenizer.nextToken());
            parseProperties(classInfo.properties, classInfo.models, baseClasses);
            
            classInfo.setDescription(parseDescription());
            expect(CDefinition, token = m_tokenizer.nextToken());

            Model::EntityDefinition* definition = NULL;
            
            if (classInfo.hasColor) {
                ClassInfo::resolveBaseClasses(m_baseClasses, baseClasses, classInfo);
                if (classInfo.hasSize) { // point definition
                    definition = new Model::PointEntityDefinition(classInfo.name, classInfo.color, classInfo.size, classInfo.description, classInfo.propertyList(), classInfo.models);
                } else {
                    definition = new Model::BrushEntityDefinition(classInfo.name, classInfo.color, classInfo.description, classInfo.propertyList());
                }
            } else { // base definition
                m_baseClasses[classInfo.name] = classInfo;
                definition = nextDefinition();
            }
            
            return definition;
        }
Beispiel #5
0
QDBusMetaObjectGenerator::QDBusMetaObjectGenerator(const QString &interfaceName,
                                                   const QDBusIntrospection::Interface *parsedData)
    : data(parsedData), interface(interfaceName)
{
    if (data) {
        parseProperties();
        parseSignals();             // call parseSignals first so that slots override signals
        parseMethods();
    }
}
bool Material::initWithFile(const std::string& validfilename)
{
    // Warning: properties is not a "Ref" object, must be manually deleted
    Properties* properties = Properties::createNonRefCounted(validfilename);

    // get the first material
    parseProperties((strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace());

    CC_SAFE_DELETE(properties);
    return true;
}
Beispiel #7
0
bool Material::initWithFile(const std::string& validfilename)
{
    Data data = FileUtils::getInstance()->getDataFromFile(validfilename);
    char* bytes = (char*)data.getBytes();
    bytes[data.getSize()-1]='\0';

    // Warning: properties is not a "Ref" object, must be manually deleted
    Properties* properties = Properties::createNonRefCounted(validfilename);

    // get the first material
    parseProperties((strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace());

    CC_SAFE_DELETE(properties);
    return true;
}
 /// Parses relation with relations from multipolygon and notifies visitor.
 void parseMultiPolygon(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   utymap::entities::Relation relation;
   parseProperties(relation, featureId, feature.get_child("properties"));
   for (const ptree::value_type &geometry : feature.get_child("geometry.coordinates")) {
     auto child = parseRelation(featureId, geometry.second);
     if (child.elements.size()==1) {
       FoldRelation fold;
       child.elements[0]->accept(fold);
       relation.elements.push_back(fold.element);
     } else {
       relation.elements.push_back(std::make_shared<utymap::entities::Relation>(child));
     }
   }
   visitor.add(relation);
 }
void LuaScript::loaded(FS::IFile& file, bool success, FS::FileSystem& fs)
{
	if (success)
	{
		m_source_code.set((const char*)file.getBuffer(), file.size());
		parseProperties();
		m_size = file.size();
		decrementDepCount();
	}
	else
	{
		g_log_error.log("lua_script") << "Could not load script "
									  << m_path.c_str();
		onFailure();
	}
}
// Attachment ID 1: type "cue", size 1844 bytes, description "dummy", file name "cuewithtags2.cue"
void
FileIdentifier::parseAttachmentLine(QString const &line) {
  QRegExp re{"^Attachment ID (\\d+): type \"(.*)\", size (\\d+) bytes, description \"(.*)\", file name \"(.*)\"$"};

  if (-1 == re.indexIn(line))
    return;

  auto track                     = std::make_shared<Track>(m_file.get(), Track::Attachment);
  track->m_properties            = parseProperties(line);
  track->m_id                    = re.cap(1).toLongLong();
  track->m_codec                 = re.cap(2);
  track->m_size                  = re.cap(3).toLongLong();
  track->m_attachmentDescription = re.cap(4);
  track->m_name                  = re.cap(5);

  m_file->m_tracks << track;
}
// Track ID 0: video (V_MS/VFW/FOURCC, DIV3) [number:1 ...]
// Track ID 7: audio (A_PCM/INT/LIT) [number:8 uid:289972206 codec_id:A_PCM/INT/LIT codec_private_length:0 language:und default_track:0 forced_track:0 enabled_track:1 default_duration:31250000 audio_sampling_frequency:48000 audio_channels:2]
// Track ID 8: subtitles (S_TEXT/UTF8) [number:9 ...]
void
FileIdentifier::parseTrackLine(QString const &line) {
  QRegExp re{"Track\\s+ID\\s+(\\d+):\\s+(audio|video|subtitles|buttons)\\s+\\(([^\\)]+)\\)", Qt::CaseInsensitive};
  if (-1 == re.indexIn(line))
    return;

  auto type                       = re.cap(2) == "audio"     ? Track::Audio
                                  : re.cap(2) == "video"     ? Track::Video
                                  : re.cap(2) == "subtitles" ? Track::Subtitles
                                  :                            Track::Buttons;
  auto track                      = std::make_shared<Track>(m_file.get(), type);
  track->m_id                     = re.cap(1).toLongLong();
  track->m_codec                  = re.cap(3);
  track->m_properties             = parseProperties(line);

  m_file->m_tracks << track;

  track->setDefaults();
}
Beispiel #12
0
void MetaInfoPrivate::parseNonQmlClassRecursively(const QMetaObject *qMetaObject)
{
    Q_ASSERT_X(qMetaObject, Q_FUNC_INFO, "invalid QMetaObject");

    QString typeName;
    int majorVersion = -1;
    int minorVersion = -1;
    typeInfo(qMetaObject, &typeName, &majorVersion, &minorVersion);

    if (typeName.isEmpty()) {
        qWarning() << "Meta type system: Registered class has no name.";
        return;
    }

    NodeMetaInfo existingInfo = m_q->nodeMetaInfo(typeName, majorVersion, minorVersion);
    if (existingInfo.isValid()
        && existingInfo.majorVersion() == majorVersion
        && existingInfo.minorVersion() == minorVersion) {
        return;
    }

    NodeMetaInfo nodeMetaInfo(*m_q);
    nodeMetaInfo.setType(typeName, majorVersion, minorVersion);
    parseProperties(nodeMetaInfo, qMetaObject);
    parseClassInfo(nodeMetaInfo, qMetaObject);

    QString superTypeName;
    int superTypeMajorVersion = -1;
    int superTypeMinorVersion = -1;

    if (qMetaObject->superClass()) {
        typeInfo(qMetaObject->superClass(), &superTypeName, &superTypeMajorVersion, &superTypeMinorVersion);
        nodeMetaInfo.setSuperClass(superTypeName, superTypeMajorVersion, superTypeMinorVersion);
    }
    if (debug)
        qDebug() << "adding non qml type" << nodeMetaInfo.typeName() << nodeMetaInfo.majorVersion() << nodeMetaInfo.minorVersion()
                 << ", parent type" << superTypeName << superTypeMajorVersion << superTypeMinorVersion;

    m_q->addNodeInfo(nodeMetaInfo);

    if (const QMetaObject *superClass = qMetaObject->superClass())
        parseNonQmlClassRecursively(superClass);
}
Beispiel #13
0
QJsonObject QParseObject::toJson( bool onlyChanged ) {
	Q_UNUSED( onlyChanged )
	QJsonObject data;
	foreach( QString property, parseProperties() ) {
		QVariant value = this->property( property.toLatin1().data() );
		// handle PARSE specific data
		if ( value.canConvert<QParseObject*>() ) {
			// pointer to Parse object
			data[property] = value.value<QParseObject*>()->getJsonPointer();
		} else if ( value.canConvert<QParseDate>() ) {
			// Parse Date type
			data[property] = value.value<QParseDate>().toJson();
		} else if ( value.canConvert<QParseFile*>() ) {
			// Parse File type
			data[property] = value.value<QParseFile*>()->toJson();
		} else {
			data[property] = QJsonValue::fromVariant(this->property( property.toLatin1().data() ));
		}
	}
com::typesafe::config::Config* com::typesafe::config::ConfigFactory::parseProperties(::java::util::Properties* properties)
{
    clinit();
    return parseProperties(properties, ConfigParseOptions::defaults());
}
void
TableLayout::parse(XmlReader& reader)
{
    int rows = -1, cols = -1;
    border = false;
    
    XmlReader::AttributeIterator iter(reader);
    while(iter.next()) {
        const char* attribute = (const char*) iter.getName();
        const char* value = (const char*) iter.getValue();

        if(parseAttribute(attribute, value)) {
            continue;
        } else if(strcmp(attribute, "rows") == 0) {
            if(sscanf(value, "%d", &rows) != 1) {
                std::stringstream msg;
                msg << "Error while parsing rows attribute: " << value;
                throw std::runtime_error(msg.str());
            }
        } else if(strcmp(attribute, "cols") == 0) {
            if(sscanf(value, "%d", &cols) != 1) {
                std::stringstream msg;
                msg << "Error while parsing cols attribute: " << value;
                throw std::runtime_error(msg.str());
            }
        } else if(strcmp(attribute, "border") == 0) {
            if(strcmp(value, "true") == 0) {
                border = true;
            } else if(strcmp(value, "false") == 0) {
                border = false;
            } else {
                std::cerr << "Invalid value for border attribute. "
                    "Please specify 'true' or 'false'\n";
            }
        } else {
            std::cerr << "Skipping unknown attribute '" << attribute << "'.\n";
        }
    }
    if(rows <= 0 || cols <= 0) {
        throw std::runtime_error("Invalid values for rows/cols");
    }
    
    rowproperties.assign(rows, RowColProperties());
    colproperties.assign(cols, RowColProperties());
    cells.assign(rows*cols, Cell());
    
    int depth = reader.getDepth();
    while(reader.read() && reader.getDepth() > depth) {
        if(reader.getNodeType() == XML_READER_TYPE_ELEMENT) {
            const std::string& element = (const char*) reader.getName();
            if(element == "rowsize") {
                RowColProperties props;
                int num = parseProperties(reader, props) - 1;
                if(num < 0 || num >= rows) {
                    std::cerr 
                        << "Invalid row specified in rowsize element.\n";
                    continue;
                }
                rowproperties[num] = props;
            } else if(element == "colsize") {
                RowColProperties props;
                int num = parseProperties(reader, props) - 1;
                if(num < 0 || num >= cols) {
                    std::cerr 
                        << "Invalid col specified in colsize element.\n";
                    continue;
                }
                colproperties[num] = props;
            } else if(element == "cell") {
                int row = -1, col = -1;
                int colspan = 1, rowspan = 1;
                Cell::Alignment halign = Cell::CENTER;
                Cell::Alignment valign = Cell::CENTER;
                XmlReader::AttributeIterator iter(reader);
                while(iter.next()) {
                    const char* name = (const char*) iter.getName();
                    const char* value = (const char*) iter.getValue();

                    if(strcmp(name, "row") == 0) {
                        if(sscanf(value, "%d", &row) != 1) {
                            std::cerr << "Couldn't parse integer value '"
                                << value << "' in row attribute.\n";
                        }
                    } else if(strcmp(name, "col") == 0) {
                        if(sscanf(value, "%d", &col) != 1) {
                            std::cerr << "Couldn't parse integer value '"
                                << value << "' in col attribute.\n";
                        }
                    } else if(strcmp(name, "rowspan") == 0) {
                        if(sscanf(value, "%d", &rowspan) != 1) {
                            std::cerr << "Couldn't parse integer value '"
                                << value << "' in rowspan attribute.\n";
                        }
                    } else if(strcmp(name, "colspan") == 0) {
                        if(sscanf(value, "%d", &colspan) != 1) {
                            std::cerr << "Couldn't parse integer value '"
                                << value << "' in colspan attribute.\n";
                        }
                    } else if(strcmp(name, "halign") == 0) {
                        if(strcmp(value, "left") == 0) {
                            halign = Cell::LEFT;
                        } else if(strcmp(value, "center") == 0) {
                            halign = Cell::CENTER;
                        } else if(strcmp(value, "right") == 0) {
                            halign = Cell::RIGHT;
                        } else {
                            std::cerr << "Skipping unknown halignment value '"
                                << value << "'.\n";
                        }
                    } else if(strcmp(name, "valign") == 0) {
                        if(strcmp(value, "top") == 0) {
                            valign = Cell::TOP;
                        } else if(strcmp(value, "center") == 0) {
                            valign = Cell::CENTER;
                        } else if(strcmp(value, "bottom") == 0) {
                            valign = Cell::BOTTOM;
                        } else {
                            std::cerr << "Skipping unknown valignment value '"
                                << value << "'.\n";
                        }
                    } else {
                        std::cerr << "Unknown attribute '" << name
                            << "' in cell element.\n";
                    }
                }
                row--;
                col--;
                if(row < 0 || row >= rows) {
                    std::cerr 
                        << "Skipping cell because row value is invalid.\n";
                    continue;
                }
                if(col < 0 || col >= cols) {
                    std::cerr
                        << "Skipping cell because col value is invalid.\n";
                    continue;
                }
                if(rowspan <= 0 || row + rowspan - 1 >= rows) {
                    std::cerr << "rowspan value invalid.\n";
                    rowspan = 1;
                }
                if(colspan <= 0 || col + colspan - 1 >= cols) {
                    std::cerr << "colspan value invalid.\n";
                    colspan = 1;
                }

                Component* component = parseEmbeddedComponent(reader);
                if(component == 0) {
                    std::cerr << "No Component specified in cell "
                        << (row+1) << ", " << (col+1) << "\n";
                    continue;
                }
                addChild(component);
                Cell cell(childs.size() - 1);
                cell.halign = halign;
                cell.valign = valign;
                cell.rowspan = rowspan;
                cell.colspan = colspan;
                cells[row*cols + col] = cell;
            } else {
                std::cerr << "Unknown element '" << element 
                    << "' in TableLayout.\n";
                reader.nextNode();
                continue;
            }
        }   
    }
}
Beispiel #16
0
 /// Parses node from point and notifies visitor.
 void parsePoint(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   utymap::entities::Node node;
   parseProperties(node, featureId, feature.get_child("properties"));
   node.coordinate = parseCoordinate(feature.get_child("geometry.coordinates"));
   visitor.add(node);
 }
bool Material::initWithProperties(Properties* materialProperties)
{
    return parseProperties(materialProperties);
}
Beispiel #18
0
Object *parseFile(FILE *file, Object *parent)
{
	/* State:
	   0 = read tag name [ ]
	   1 = wait for property list [(]
	   2 = check new objects [(]
	   3 = Read content if tag name is code
	*/
	int state = 0;
	int c;
	char **propertyList;
	char *name = MALLOCN(char, 255);
	int i = 0;
	int iChild = 0;
	Object **childs;
	childs = MALLOCN(Object *, 255);
	Object *obj;
	
	DMSG("parse file\n");
	
	for (c = fgetc(file); c != ')'; c = fgetc(file)) {
		switch (state) {
		case 0:
			switch (c) {
			case ' ':
				name[i] = '\0';
				state = 1;
				DMSG("switch to state 1\n");
				break;
			default:
				name[i++] = c;
				break;
			}
			break;
			
		case 1:
			switch (c) {
			case '(':
				propertyList = parseProperties(name, file);
				obj = createObject(name, propertyList);
				if (strcmp(name, "code") == 0) {
					state = 3;
					DMSG("switch to state 3\n");
				}
				else {
					state = 2;
					DMSG("switch to state 2\n");
				}
				break;
			}
			break;
			
		case 2:
			switch (c) {
			case '(':
				childs[iChild++] = parseFile(file, obj);
				childs[iChild] = NULL;
				break;
			}
			break;
			
		case 3:
			DMSG("Got code - search vor (\n");
			switch (c) {
			case '(':
				DMSG("Found\n");
				parseCode(file, obj, propertyList);
				state = 2;
				break;
			}
			break;
		}
		
	}
	
	DMSG("Set parent and childs\n");
	obj->parent = parent;
	obj->childs = childs;
	
	DMSG("Insert into Global index\n");
	insertGlobalIndex(obj);
	
	if (obj->onInit != NULL)
		execEvent(obj->onInit, obj);
	
	DMSG("parsing finished\n");
	
	return obj;
}
Beispiel #19
0
 /// Parses way from line string and notifies visitor.
 void parseLineString(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   utymap::entities::Way way;
   parseProperties(way, featureId, feature.get_child("properties"));
   way.coordinates = parseCoordinates(feature.get_child("geometry.coordinates"));
   visitor.add(way);
 }