// source-list = *WSP [ source *( 1*WSP source ) *WSP ] // / *WSP "'none'" *WSP // void CSPSourceList::parse(const UChar* begin, const UChar* end) { const UChar* position = begin; bool isFirstSourceInList = true; while (position < end) { skipWhile<isASCIISpace>(position, end); const UChar* beginSource = position; skipWhile<isSourceCharacter>(position, end); if (isFirstSourceInList && equalIgnoringCase("'none'", beginSource, position - beginSource)) return; // We represent 'none' as an empty m_list. isFirstSourceInList = false; String scheme, host; int port = 0; bool hostHasWildcard = false; bool portHasWildcard = false; if (parseSource(beginSource, position, scheme, host, port, hostHasWildcard, portHasWildcard)) { if (scheme.isEmpty()) scheme = m_origin->protocol(); m_list.append(CSPSource(scheme, host, port, hostHasWildcard, portHasWildcard)); } ASSERT(position == end || isASCIISpace(*position)); } }
bool FDPLoader::parse() { m_bindings.clear(); m_morphTargetsMeshInfos.clear(); m_faceEntityMeshInfo.clear(); // get the header DOMNodeList* nodes = m_pDoc->getElementsByTagName(XercesString("head")); if(!nodes || nodes->getLength() != 1) // sth wrong return false; if(!parseHeader(nodes->item(0)) ) return false; // get the source info nodes = m_pDoc->getElementsByTagName(XercesString("source")); if(!nodes || nodes->getLength() != 1) // sth wrong return false; parseSource(nodes->item(0)); // process fdp's now nodes = m_pDoc->getElementsByTagName(XercesString("fdp")); XMLSize_t sz = nodes->getLength(); for(XMLSize_t i = 0; i < sz; ++i) loadFDPItem(nodes->item(i)); return true; }
Slot* Parser::parseSlot(Node *_parent,const xmlDocPtr &_doc, xmlNodePtr _cur, std::map<std::string, std::string> *_map) { Slot *s = 0; xmlChar *name,*type, *var; name = parseAttribute(_cur, "name"); type = parseAttribute(_cur, "type"); var = parseAttribute(_cur, "var"); EnumParser<SVariable> p; EnumParser<Stype> p2; s = new Slot( _parent, (const char*)name, p2.parseEnum((const char*)_cur->name), p.parseEnum((const char*)var) ); _cur=_cur->children; while(_cur !=NULL) { if(!xmlStrcmp(_cur->name, (const xmlChar *)SLOTSOURCE)) { std::cout<<"in source slot"<<'\n'; std::string output, input; input = _parent->getName()+"."+ _parent->getID()+"."+ (char *)name; output = parseSource(_cur, _map); _map->insert(std::pair<std::string, std::string>(input, output)); } _cur=_cur->next; } xmlFree(name); xmlFree(type); xmlFree(var); return s; }
void Project::parseProject(QString filename) { QFile* file=new QFile(filename); if(!file->open(QIODevice::ReadOnly | QIODevice::Text)) { return; } QXmlStreamReader xml(file); while(!xml.atEnd() && !xml.hasError()) { QXmlStreamReader::TokenType token = xml.readNext(); if(token == QXmlStreamReader::StartDocument) { continue; } if(token == QXmlStreamReader::StartElement) { if(xml.name() == "project") { continue; } if(xml.name() == "name") { parseName(xml); } if(xml.name() == "source") { parseSource(xml); } } } delete file; }
void BasicShader::setSource(const std::string& source) { std::string parsedSource(source); parseSource(parsedSource); const GLchar* csource = parsedSource.c_str(); const GLint len = parsedSource.length(); glShaderSource(mName, 1, &csource, &len); }
int main() { try { GlobalEvrionment g; parseSource(readFile("1.txt"), g); registerBuildinFunctions(g); runMain(g); } catch (const std::exception& e) { cout << "Exception : " << e.what() << endl; } }
/**************************************************************************** NAME hfpHandleReceivedData DESCRIPTION Called when we get an indication from the firmware that there's more data received and waiting in the RFCOMM buffer. Parse it. RETURNS void */ void hfpHandleReceivedData(HFP *hfp, Source source) { uint16 len; /* Cancel all more data messages as we're about to process the whole buffer */ (void) MessageCancelAll(&hfp->task, MESSAGE_MORE_DATA); len = SourceSize(source); /* Only bother parsing if there is something to parse */ while (len > 0) { /* Keep parsing while we have data in the buffer */ if (!parseSource(source, &hfp->task)) break; /* Check we have more data to parse */ len = SourceSize(source); } }
// source-list = *WSP [ source *( 1*WSP source ) *WSP ] // / *WSP "'none'" *WSP // void ContentSecurityPolicySourceList::parse(const UChar* begin, const UChar* end) { const UChar* position = begin; while (position < end) { skipWhile<UChar, isASCIISpace>(position, end); if (position == end) return; const UChar* beginSource = position; skipWhile<UChar, isSourceCharacter>(position, end); String scheme, host, path; int port = 0; bool hostHasWildcard = false; bool portHasWildcard = false; if (parseNonceSource(beginSource, position)) continue; if (parseHashSource(beginSource, position)) continue; if (parseSource(beginSource, position, scheme, host, port, path, hostHasWildcard, portHasWildcard)) { // Wildcard hosts and keyword sources ('self', 'unsafe-inline', // etc.) aren't stored in m_list, but as attributes on the source // list itself. if (scheme.isEmpty() && host.isEmpty()) continue; if (isCSPDirectiveName(host)) m_policy.reportDirectiveAsSourceExpression(m_directiveName, host); m_list.append(ContentSecurityPolicySource(m_policy, scheme, host, port, path, hostHasWildcard, portHasWildcard)); } else m_policy.reportInvalidSourceExpression(m_directiveName, String(beginSource, position - beginSource)); ASSERT(position == end || isASCIISpace(*position)); } }
// source-list = *WSP [ source *( 1*WSP source ) *WSP ] // / *WSP "'none'" *WSP // void CSPSourceList::parse(const UChar* begin, const UChar* end) { // We represent 'none' as an empty m_list. if (isSourceListNone(begin, end)) return; const UChar* position = begin; while (position < end) { skipWhile<UChar, isASCIISpace>(position, end); if (position == end) return; const UChar* beginSource = position; skipWhile<UChar, isSourceCharacter>(position, end); String scheme, host, path; int port = 0; CSPSource::WildcardDisposition hostWildcard = CSPSource::NoWildcard; CSPSource::WildcardDisposition portWildcard = CSPSource::NoWildcard; if (parseSource(beginSource, position, scheme, host, port, path, hostWildcard, portWildcard)) { // Wildcard hosts and keyword sources ('self', 'unsafe-inline', // etc.) aren't stored in m_list, but as attributes on the source // list itself. if (scheme.isEmpty() && host.isEmpty()) continue; if (m_policy->isDirectiveName(host)) m_policy->reportDirectiveAsSourceExpression(m_directiveName, host); m_list.append(CSPSource(m_policy, scheme, host, port, path, hostWildcard, portWildcard)); } else { m_policy->reportInvalidSourceExpression(m_directiveName, String(beginSource, position - beginSource)); } ASSERT(position == end || isASCIISpace(*position)); } }
void ColladaLoader::startElement(const XML_Char *name, const XML_Char *atts[]) { int id = getTagID(name); switch (id) { case TAG_LIBRARY_MATERIALS: break; case TAG_LIBRARY_GEOMETRIES: break; case TAG_GEOMETRY: parseGeometry(atts); break; case TAG_MESH: break; case TAG_SOURCE: parseSource(atts); break; case TAG_FLOAT_ARRAY: parseFloatArray(atts); break; case TAG_TRIANGLES: parseTriangles(atts); break; } state.push_back(id); }
void ParseSppData(Task task, Source src) { parseSource(src, task); }
void mapcache_configuration_parse_xml(mapcache_context *ctx, const char *filename, mapcache_cfg *config) { ezxml_t doc, node; const char *mode; doc = ezxml_parse_file(filename); if (doc == NULL) { ctx->set_error(ctx,400, "failed to parse file %s. Is it valid XML?", filename); goto cleanup; } else { const char *err = ezxml_error(doc); if(err && *err) { ctx->set_error(ctx,400, "failed to parse file %s: %s", filename, err); goto cleanup; } } if(strcmp(doc->name,"mapcache")) { ctx->set_error(ctx,400, "failed to parse file %s. first node is not <mapcache>", filename); goto cleanup; } mode = ezxml_attr(doc,"mode"); if(mode) { if(!strcmp(mode,"combined_mirror")) { config->mode = MAPCACHE_MODE_MIRROR_COMBINED; } else if(!strcmp(mode,"split_mirror")) { config->mode = MAPCACHE_MODE_MIRROR_SPLIT; } else if(!strcmp(mode,"normal")) { config->mode = MAPCACHE_MODE_NORMAL; } else { ctx->set_error(ctx,400,"unknown mode \"%s\" for <mapcache>",mode); goto cleanup; } } else { config->mode = MAPCACHE_MODE_NORMAL; } for(node = ezxml_child(doc,"metadata"); node; node = node->next) { parseMetadata(ctx, node, config->metadata); if(GC_HAS_ERROR(ctx)) goto cleanup; } for(node = ezxml_child(doc,"source"); node; node = node->next) { parseSource(ctx, node, config); if(GC_HAS_ERROR(ctx)) goto cleanup; } for(node = ezxml_child(doc,"grid"); node; node = node->next) { parseGrid(ctx, node, config); if(GC_HAS_ERROR(ctx)) goto cleanup; } for(node = ezxml_child(doc,"format"); node; node = node->next) { parseFormat(ctx, node, config); if(GC_HAS_ERROR(ctx)) goto cleanup; } for(node = ezxml_child(doc,"cache"); node; node = node->next) { parseCache(ctx, node, config); if(GC_HAS_ERROR(ctx)) goto cleanup; } for(node = ezxml_child(doc,"tileset"); node; node = node->next) { parseTileset(ctx, node, config); if(GC_HAS_ERROR(ctx)) goto cleanup; } if ((node = ezxml_child(doc,"service")) != NULL) { ezxml_t service_node; for(service_node = node; service_node; service_node = service_node->next) { char *enabled = (char*)ezxml_attr(service_node,"enabled"); char *type = (char*)ezxml_attr(service_node,"type"); if(!strcasecmp(enabled,"true")) { if (!strcasecmp(type,"wms")) { mapcache_service *new_service = mapcache_service_wms_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_WMS] = new_service; } else if (!strcasecmp(type,"tms")) { mapcache_service *new_service = mapcache_service_tms_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_TMS] = new_service; } else if (!strcasecmp(type,"wmts")) { mapcache_service *new_service = mapcache_service_wmts_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_WMTS] = new_service; } else if (!strcasecmp(type,"kml")) { mapcache_service *new_service = mapcache_service_kml_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_KML] = new_service; } else if (!strcasecmp(type,"gmaps")) { mapcache_service *new_service = mapcache_service_gmaps_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_GMAPS] = new_service; } else if (!strcasecmp(type,"ve")) { mapcache_service *new_service = mapcache_service_ve_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_VE] = new_service; } else if (!strcasecmp(type,"demo")) { mapcache_service *new_service = mapcache_service_demo_create(ctx); if(new_service->configuration_parse_xml) { new_service->configuration_parse_xml(ctx,service_node,new_service,config); } config->services[MAPCACHE_SERVICE_DEMO] = new_service; } else { ctx->set_error(ctx,400,"unknown <service> type %s",type); } if(GC_HAS_ERROR(ctx)) goto cleanup; } } } else if ((node = ezxml_child(doc,"services")) != NULL) { ctx->log(ctx,MAPCACHE_WARN,"<services> tag is deprecated, use <service type=\"wms\" enabled=\"true|false\">"); parseServices(ctx, node, config); } else { ctx->set_error(ctx, 400, "no <services> configured"); } if(GC_HAS_ERROR(ctx)) goto cleanup; node = ezxml_child(doc,"default_format"); if(!node) node = ezxml_child(doc,"merge_format"); if (node) { mapcache_image_format *format = mapcache_configuration_get_image_format(config,node->txt); if(!format) { ctx->set_error(ctx, 400, "default_format tag references format %s but it is not configured", node->txt); goto cleanup; } config->default_image_format = format; } if ((node = ezxml_child(doc,"errors")) != NULL) { if(!strcmp(node->txt,"log")) { config->reporting = MAPCACHE_REPORT_LOG; } else if(!strcmp(node->txt,"report")) { config->reporting = MAPCACHE_REPORT_MSG; } else if(!strcmp(node->txt,"empty_img")) { config->reporting = MAPCACHE_REPORT_EMPTY_IMG; mapcache_image_create_empty(ctx, config); if(GC_HAS_ERROR(ctx)) goto cleanup; } else if(!strcmp(node->txt, "report_img")) { config->reporting = MAPCACHE_REPORT_ERROR_IMG; ctx->set_error(ctx,501,"<errors>: report_img not implemented"); goto cleanup; } else { ctx->set_error(ctx,400,"<errors>: unknown value %s (allowed are log, report, empty_img, report_img)", node->txt); goto cleanup; } } if((node = ezxml_child(doc,"lock_dir")) != NULL) { config->lockdir = apr_pstrdup(ctx->pool, node->txt); } else { config->lockdir = apr_pstrdup(ctx->pool,"/tmp"); } if((node = ezxml_child(doc,"lock_retry")) != NULL) { char *endptr; config->lock_retry_interval = (unsigned int)strtol(node->txt,&endptr,10); if(*endptr != 0 || config->lock_retry_interval < 0) { ctx->set_error(ctx, 400, "failed to parse lock_retry microseconds \"%s\". Expecting a positive integer", node->txt); return; } } if((node = ezxml_child(doc,"threaded_fetching")) != NULL) { if(!strcasecmp(node->txt,"true")) { config->threaded_fetching = 1; } else if(strcasecmp(node->txt,"false")) { ctx->set_error(ctx, 400, "failed to parse threaded_fetching \"%s\". Expecting true or false",node->txt); return; } } if((node = ezxml_child(doc,"log_level")) != NULL) { if(!strcasecmp(node->txt,"debug")) { config->loglevel = MAPCACHE_DEBUG; } else if(!strcasecmp(node->txt,"info")) { config->loglevel = MAPCACHE_INFO; } else if(!strcasecmp(node->txt,"notice")) { config->loglevel = MAPCACHE_NOTICE; } else if(!strcasecmp(node->txt,"warn")) { config->loglevel = MAPCACHE_WARN; } else if(!strcasecmp(node->txt,"error")) { config->loglevel = MAPCACHE_ERROR; } else if(!strcasecmp(node->txt,"crit")) { config->loglevel = MAPCACHE_CRIT; } else if(!strcasecmp(node->txt,"alert")) { config->loglevel = MAPCACHE_ALERT; } else if(!strcasecmp(node->txt,"emerg")) { config->loglevel = MAPCACHE_EMERG; } else { ctx->set_error(ctx,500,"failed to parse <log_level> \"%s\". Expecting debug, info, notice, warn, error, crit, alert or emerg",node->txt); return; } } if((node = ezxml_child(doc,"auto_reload")) != NULL) { if(!strcasecmp(node->txt,"true")) { config->autoreload = 1; } else if(!strcasecmp(node->txt,"false")) { config->autoreload = 0; } else { ctx->set_error(ctx,500,"failed to parse <auto_reload> \"%s\". Expecting true or false",node->txt); return; } } cleanup: ezxml_free(doc); return; }