当前位置: 首页>>代码示例>>C++>>正文


C++ xmlTextReaderDepth函数代码示例

本文整理汇总了C++中xmlTextReaderDepth函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlTextReaderDepth函数的具体用法?C++ xmlTextReaderDepth怎么用?C++ xmlTextReaderDepth使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xmlTextReaderDepth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cxHashRootReadArray

cxTypes cxHashRootReadArray(cxHashRoot root,xmlTextReaderPtr reader)
{
    cxTypes types = cxArrayTypesCreate();
    int depth = xmlTextReaderDepth(reader);
    while(xmlTextReaderRead(reader) && depth != xmlTextReaderDepth(reader)){
        if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
            continue;
        }
        cxAny value = NULL;
        cxConstChars temp = cxXMLReadElementName(reader);
        if(ELEMENT_IS_TYPE(cxString)){
            cxTypes types = cxHashRootReadString(root, reader);
            value = types != NULL ? types->any : NULL;
        } else if(ELEMENT_IS_TYPE(cxHash)){
            cxTypes types = cxHashRootReadHash(root, reader);
            value = types != NULL ? types->any : NULL;
        } else if(ELEMENT_IS_TYPE(cxArray)){
            cxTypes types = cxHashRootReadArray(root, reader);
            value = types != NULL ? types->any : NULL;
        } else {
            value = cxReadValues(root, temp, reader);
        }
        if(value != NULL){
            cxArrayAppend(types->any, value);
        }
    }
    return types;
}
开发者ID:iloveican,项目名称:cxEngine,代码行数:28,代码来源:cxHashRoot.c

示例2: calloc

/**
 * Reads a SubnetConfigs from XML. The reader is assumed to be at the start element.
 *
 * @return the SubnetConfigs, or NULL in case of error.
 */
static struct full_ns0_subnetConfigs *xmlTextReaderReadNs0SubnetConfigsType(xmlTextReaderPtr reader) {
  int status, depth;
  void *_child_accessor;
  struct full_ns0_subnetConfigs *_subnetConfigs = calloc(1, sizeof(struct full_ns0_subnetConfigs));



  if (xmlTextReaderIsEmptyElement(reader) == 0) {
    depth = xmlTextReaderDepth(reader);//track the depth.
    status = xmlTextReaderAdvanceToNextStartOrEndElement(reader);

    while (xmlTextReaderDepth(reader) > depth) {
      if (status < 1) {
        //panic: XML read error.
#if DEBUG_ENUNCIATE
        printf("Failure to advance to next child element.\n");
#endif
        freeNs0SubnetConfigsType(_subnetConfigs);
        free(_subnetConfigs);
        return NULL;
      }
      else if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
        && xmlStrcmp(BAD_CAST "subnetConfig", xmlTextReaderConstLocalName(reader)) == 0
        && xmlTextReaderConstNamespaceUri(reader) == NULL) {

#if DEBUG_ENUNCIATE > 1
        printf("Attempting to read choice {}subnetConfig of type {}subnetConfig.\n");
#endif
        _child_accessor = xmlTextReaderReadNs0SubnetConfigType(reader);
        if (_child_accessor == NULL) {
#if DEBUG_ENUNCIATE
          printf("Failed to read choice {}subnetConfig of type {}subnetConfig.\n");
#endif
          //panic: unable to read the child element for some reason.
          freeNs0SubnetConfigsType(_subnetConfigs);
          free(_subnetConfigs);
          return NULL;
        }

        _subnetConfigs->subnetConfig = realloc(_subnetConfigs->subnetConfig, (_subnetConfigs->_sizeof_subnetConfig + 1) * sizeof(struct full_ns0_subnetConfig));
        memcpy(&(_subnetConfigs->subnetConfig[_subnetConfigs->_sizeof_subnetConfig++]), _child_accessor, sizeof(struct full_ns0_subnetConfig));
        free(_child_accessor);
        status = xmlTextReaderAdvanceToNextStartOrEndElement(reader);
      }
      else {
#if DEBUG_ENUNCIATE > 1
        if (xmlTextReaderConstNamespaceUri(reader) == NULL) {
          printf("unknown child element {}%s for type {}subnetConfigs.  Skipping...\n",  xmlTextReaderConstLocalName(reader));
        }
        else {
          printf("unknown child element {%s}%s for type {}subnetConfigs. Skipping...\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader));
        }
#endif
        status = xmlTextReaderSkipElement(reader);
      }
    }
  }

  return _subnetConfigs;
}
开发者ID:saurabh29july,项目名称:OpenDaylightNBIDocumentation,代码行数:65,代码来源:full.c

示例3: parse_properties

static int parse_properties(xmlTextReaderPtr reader, tmx_property **prop_headadr) {
	tmx_property *res;
	int curr_depth;
	const char *name;

	curr_depth = xmlTextReaderDepth(reader);

	/* Parse each child */
	do {
		if (xmlTextReaderRead(reader) != 1) return 0; /* error_handler has been called */

		if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
			name = (char*)xmlTextReaderConstName(reader);
			if (!strcmp(name, "property")) {
				if (!(res = alloc_prop())) return 0;
				res->next = *prop_headadr;
				*prop_headadr = res;

				if (!parse_property(reader, res)) return 0;

			} else { /* Unknow element, skip its tree */
				if (xmlTextReaderNext(reader) != 1) return 0;
			}
		}
	} while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT ||
	         xmlTextReaderDepth(reader) != curr_depth);
	return 1;
}
开发者ID:V0idExp,项目名称:tmx,代码行数:28,代码来源:tmx_xml.c

示例4: getTitle

/**
 * Gets the title from the parser. Returns true if success, false if EOF
 */
bool getTitle (xmlTextReaderPtr xmlReader, int *moreWiki, GString* articleTitle) {
	
	
	// loops until it finds the title tag or EOF
	// one tree at a time, skips sub trees
    while (1 == *moreWiki) {
		
		// loops until xmlReader is back down to level 2
		// one node at a time
		while (1 == *moreWiki && 2 > xmlTextReaderDepth (xmlReader)) {
			*moreWiki = xmlTextReaderRead (xmlReader);
		}
		// loops until it finds the title tag, end of subtree or EOF
		// one tree at a time, skips sub trees
		while (1 == *moreWiki && 2 <= xmlTextReaderDepth (xmlReader)) {
			if (xmlStrEqual(xmlTextReaderConstName(xmlReader), (const unsigned char *) "title")) {
				*moreWiki = xmlTextReaderRead(xmlReader);
				articleTitle = g_string_assign(articleTitle, (gchar *) xmlTextReaderConstValue(xmlReader));
				return (1 == *moreWiki);
			}
			*moreWiki = xmlTextReaderNext(xmlReader);
		}
	}
	// this should only happen at the end of the document
	return (1 == *moreWiki);
}
开发者ID:ahabeger,项目名称:indexWiki,代码行数:29,代码来源:indexWiki_old_v2.c

示例5: oscap_parser_text_value

/* -1 error; 0 OK */
int oscap_parser_text_value(xmlTextReaderPtr reader, oscap_xml_value_consumer consumer, void *user)
{
	int depth = xmlTextReaderDepth(reader);
	bool has_value = false;
	int ret = 0;

	if (xmlTextReaderIsEmptyElement(reader)) {
		return ret;
	}

	xmlTextReaderRead(reader);
	while (xmlTextReaderDepth(reader) > depth) {
		int nodetype = xmlTextReaderNodeType(reader);
		if (nodetype == XML_READER_TYPE_CDATA || nodetype == XML_READER_TYPE_TEXT) {
			char *value = (char *)xmlTextReaderValue(reader);
			(*consumer) (value, user);
			oscap_free(value);
			has_value = true;
		}
		if (xmlTextReaderRead(reader) != 1) {
			ret = -1;
			break;
		}
	}

	if (!has_value)
		(*consumer) ("", user);

	return ret;
}
开发者ID:galaris,项目名称:openscap,代码行数:31,代码来源:elements.c

示例6: myProcessNode

int myProcessNode(xmlTextReaderPtr reader,int *lastdepth, int *readnext ,int *mode,char** savehere,int *i)
{
    const xmlChar *name, *value;

    name = xmlTextReaderConstName(reader);
    if (name == NULL)
        name = BAD_CAST "--";

    value = xmlTextReaderConstValue(reader);

    if(*readnext == 1 && *lastdepth == xmlTextReaderDepth(reader)-1)
    {
        if(*i <6)
        {
            sprintf(savehere[*i],"%s",value);
            *i=*i + 1;
        }
        else
            return 1;
    }
    else if(0==strncmp(name,"title",5) && *mode>0)
    {
        *readnext = 1;
        *lastdepth = xmlTextReaderDepth(reader);
        if(*mode==1)
            *mode=0;//now look for items
    }
    else if(0==strncmp(name,"item",4)||0==strncmp(name,"entry",5))
    {   //find some news feeds
        *mode=2;
    }
    else
        *readnext = 0;
    return 0;
}
开发者ID:dean36963,项目名称:g15rss,代码行数:35,代码来源:parse.c

示例7: xmlTextReaderDepth

ExtractionWay XMLParser::_ReadXMLWay() {
	ExtractionWay way;
	if ( xmlTextReaderIsEmptyElement( inputReader ) != 1 ) {
		const int depth = xmlTextReaderDepth( inputReader );
		while ( xmlTextReaderRead( inputReader ) == 1 ) {
			const int childType = xmlTextReaderNodeType( inputReader );
			if ( childType != 1 && childType != 15 ) {
				continue;
			}
			const int childDepth = xmlTextReaderDepth( inputReader );
			xmlChar* childName = xmlTextReaderName( inputReader );
			if ( childName == NULL ) {
				continue;
			}

			if ( depth == childDepth && childType == 15 && xmlStrEqual( childName, ( const xmlChar* ) "way" ) == 1 ) {
				xmlChar* id = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "id" );
				way.id = stringToUint((char*)id);
				xmlFree(id);
				xmlFree( childName );
				break;
			}
			if ( childType != 1 ) {
				xmlFree( childName );
				continue;
			}

			if ( xmlStrEqual( childName, ( const xmlChar* ) "tag" ) == 1 ) {
				xmlChar* k = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "k" );
				xmlChar* value = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "v" );
				//				cout << "->k=" << k << ", v=" << value << endl;
				if ( k != NULL && value != NULL ) {
					way.keyVals.Add(std::string( (char *) k ), std::string( (char *) value));
				}
				if ( k != NULL ) {
					xmlFree( k );
				}
				if ( value != NULL ) {
					xmlFree( value );
				}
			} else if ( xmlStrEqual( childName, ( const xmlChar* ) "nd" ) == 1 ) {
				xmlChar* ref = xmlTextReaderGetAttribute( inputReader, ( const xmlChar* ) "ref" );
				if ( ref != NULL ) {
					way.path.push_back( stringToUint(( const char* ) ref ) );
					xmlFree( ref );
				}
			}
			xmlFree( childName );
		}
	}
	return way;
}
开发者ID:DanielTripp,项目名称:Project-OSRM,代码行数:52,代码来源:XMLParser.cpp

示例8: processNode

/**
 * processNode:
 * @reader: the xmlReader
 *
 * Dump information about the current node
 */
static void
processNode(xmlTextReaderPtr reader) {
    const xmlChar *name, *value;
    int nodetype;
 
    static char spaces[33]="                                ";

    name = xmlTextReaderConstName(reader);
    if (name == NULL)
	name = BAD_CAST "--";
 
    value = xmlTextReaderConstValue(reader);
 
    nodetype = xmlTextReaderNodeType(reader);
    if (nodetype!=14 && nodetype!=15)	// Skip all text bodies and "/" entities.
    {
#ifdef DETAILS
    printf("%s%d %d %s %d %d", 
    	    (spaces + (32-2*xmlTextReaderDepth(reader))),
	    xmlTextReaderDepth(reader),
	    nodetype,
	    name,
	    xmlTextReaderIsEmptyElement(reader),
	    xmlTextReaderHasValue(reader));
#else
    printf("%s%s", (spaces + (32-2*xmlTextReaderDepth(reader))), name);
#endif

    if (value == NULL)
	printf("\n");
    else {
        if (xmlStrlen(value) > 40)
            printf(" %.40s...\n", value);
        else
	    printf(" %s\n", value);
    }
    }

    if (nodetype==1)	// Element - possibly has attributes
    {
	while (xmlTextReaderMoveToNextAttribute(reader))
	    printf("%s    Attrib: %s=\"%s\"\n", 
		(spaces + (32-2*xmlTextReaderDepth(reader))),
		xmlTextReaderConstName(reader), 
		xmlTextReaderConstValue(reader));
    }

}
开发者ID:bobwolff68,项目名称:neuron,代码行数:54,代码来源:test1.c

示例9: xml_reader_get_depth

gint
xml_reader_get_depth (XmlReader *reader)
{
  g_return_val_if_fail (XML_IS_READER(reader), -1);

  return xmlTextReaderDepth (reader->xml);
}
开发者ID:GNOME,项目名称:gnome-builder,代码行数:7,代码来源:xml-reader.c

示例10: xmlTextReaderRead

    // Return value: -1 if "state end found", otherwise depth of node
    int XMLReader::gobbleUntilStartElement(xmlTextReaderPtr &reader, const string &name)
    {
        bool state_begin_found = false;
        bool state_end_found   = false;
        int depth              = -1;

        int r = xmlTextReaderRead(reader);
        while ( (r==1) && (!state_begin_found) && (!state_end_found) ) {
            const int type = xmlTextReaderNodeType( reader );
            depth = xmlTextReaderDepth(reader);
            xmlChar *localName = xmlTextReaderLocalName(reader);
            if (type==1) {
                state_begin_found = (xmlStrEqual(localName, BAD_CAST name.c_str()) != 0);
                if (state_begin_found)
                    state_end_found = (xmlTextReaderIsEmptyElement(reader) != 0);
            } else
                if (type==15) {
                    state_end_found = (xmlStrEqual(localName, BAD_CAST name.c_str()) != 0);
                }
            xmlFree(localName);
            r=xmlTextReaderRead(reader);
        }

        if ( r==0)
            state_end_found = true; // It makes no sense to have gotten to the beginning with r==0 at the same time

        return state_begin_found && (!state_end_found) ? depth : -1;
    }
开发者ID:KjeFre,项目名称:tinia,代码行数:29,代码来源:XMLReader.cpp

示例11: processNode

/**
 * processNode:
 * @reader: the xmlReader
 *
 * Dump information about the current node
 */
static void
processNode(xmlTextReaderPtr reader) {
    const xmlChar *name, *value;

    name = xmlTextReaderConstName(reader);
    if (name == NULL)
	name = BAD_CAST "--";

    value = xmlTextReaderConstValue(reader);

    printf("Depth: %d; Type: %d; Name: %s; %d|%d", 
	    xmlTextReaderDepth(reader),
	    xmlTextReaderNodeType(reader),
	    name,
	    xmlTextReaderIsEmptyElement(reader),
	    xmlTextReaderHasValue(reader));
    if (value == NULL)
	printf("\n");
    else {
        if (xmlStrlen(value) > 40)
            printf("|-> %.40s...\n", value);
        else
	    printf(" %s\n", value);
    }
}
开发者ID:GamerSource,项目名称:EpicSource,代码行数:31,代码来源:xml.reader.basics.c

示例12: oscap_to_start_element

bool oscap_to_start_element(xmlTextReaderPtr reader, int depth)
{
	//int olddepth = xmlTextReaderDepth(reader);
	while (xmlTextReaderDepth(reader) >= depth) {
		switch (xmlTextReaderNodeType(reader)) {
		case XML_READER_TYPE_ELEMENT:
			if (xmlTextReaderDepth(reader) == depth)
				return true;
		default:
			break;
		}
		if (xmlTextReaderRead(reader) != 1)
			break;
	}
	return false;
}
开发者ID:galaris,项目名称:openscap,代码行数:16,代码来源:elements.c

示例13: cxHashRootReadDB

static void cxHashRootReadDB(cxDBEnv env,cxHashRoot root,xmlTextReaderPtr reader)
{
    cxReaderAttrInfo *info = cxReaderAttrInfoMake(reader, root, env);
    int depth = xmlTextReaderDepth(reader);
    while(xmlTextReaderRead(reader) && depth != xmlTextReaderDepth(reader)){
        if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
            continue;
        }
        cxConstChars temp = cxXMLReadElementName(reader);
        if(!ELEMENT_IS_TYPE(cxDB)){
            continue;
        }
        cxConstChars file = cxXMLAttr(reader,"file");
        cxConstChars table = cxXMLAttr(reader,"table");
        cxConstChars type = cxXMLAttr(reader,"type");
        cxConstChars sid = cxXMLAttr(reader,"id");
        cxConstChars path = cxXMLAttr(reader,"path");
        //assert file copy ->to document
        cxBool copy = cxXMLReadBoolAttr(info, "copy", false);
        if(copy && file != NULL){
            cxCopyFile(file, NULL, NULL);
        }
        cxBool rdonly = cxXMLReadBoolAttr(info,  "rdonly", false);
        if(sid == NULL){
            CX_WARN("db id not set,will can't add dataset");
        }
        cxString sfile = NULL;
        if(cxConstCharsEqu(path, "assert")){
            sfile = cxAssetsPath(file);
            //assert must set true
            rdonly = true;
        }else if(cxConstCharsEqu(path, "document")){
            sfile = cxDocumentPath(file);
        }else{
            CX_ERROR("must set path assert or document");
        }
        cxAny db = NULL;
        if(file != NULL && table != NULL && type != NULL){
            db = cxDBCreate(env, cxStringBody(sfile), table, type, rdonly);
        }
        if(db != NULL && sid != NULL){
            cxHashSet(root->items, cxHashStrKey(sid), cxDBTypesCreate(db));
        }else{
            CX_ERROR("open dbenv type %s,db %s:%s failed",cxStringBody(env->type),file,table);
        }
    }
}
开发者ID:iloveican,项目名称:cxEngine,代码行数:47,代码来源:cxHashRoot.c

示例14: xmlTextReaderDepth

int BEXMLTextReader::depth()
{
	int depth = xmlTextReaderDepth ( reader );
	if ( depth == kBE_XMLReaderError ) {
		throw BEXMLReaderInterface_Exception ( last_error() );
	}
	return depth;
}
开发者ID:SeAlgoAsoma,项目名称:BaseElements-Plugin,代码行数:8,代码来源:BEXMLTextReader.cpp

示例15: parse_tile

static int parse_tile(xmlTextReaderPtr reader, tmx_tile **tile_headadr, const char *filename) {
	tmx_tile *res = NULL;
	int curr_depth;
	const char *name;
	char *value;

	curr_depth = xmlTextReaderDepth(reader);

	if (!(res = alloc_tile())) return 0;

	while (*tile_headadr) {
		tile_headadr = &((*tile_headadr)->next);
	}
	*tile_headadr = res;

	if ((value = (char*)xmlTextReaderGetAttribute(reader, (xmlChar*)"id"))) { /* id */
		res->id = atoi(value);
		tmx_free_func(value);
	}
	else {
		tmx_err(E_MISSEL, "xml parser: missing 'id' attribute in the 'tile' element");
		return 0;
	}

	do {
		if (xmlTextReaderRead(reader) != 1) return 0; /* error_handler has been called */

		if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
			name = (char*)xmlTextReaderConstName(reader);
			if (!strcmp(name, "properties")) {
				if (!parse_properties(reader, &(res->properties))) return 0;
			}
			else if (!strcmp(name, "image")) {
				if (!parse_image(reader, &(res->image), 0, filename)) return 0;
			}
			else {
				/* Unknow element, skip its tree */
				if (xmlTextReaderNext(reader) != 1) return 0;
			}
		}
	} while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT ||
		xmlTextReaderDepth(reader) != curr_depth);

	return 1;
}
开发者ID:V0idExp,项目名称:tmx,代码行数:45,代码来源:tmx_xml.c


注:本文中的xmlTextReaderDepth函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。