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


C++ xml::NamedNodeMap类代码示例

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


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

示例1: removeAttributes

bool ofXml::removeAttributes(const string& path) 
{
    Poco::XML::Element *e;
    if(element) {
        if(path.find("[@") == string::npos) {
            // we need to create a proper path
            string attributePath = "[@" + path + "]";
            e = (Poco::XML::Element*) element->getNodeByPath(attributePath);
        } else {
            e = (Poco::XML::Element*) element->getNodeByPath(path);
        }

    } else {
        ofLogWarning("ofXml") << "clearAttributes(): no element set yet";
        return false;
    }
    
    if(e) {
        Poco::XML::NamedNodeMap *map = e->attributes();
        
        for(unsigned long i = 0; i < map->length(); i++) {
            e->removeAttribute(map->item(i)->nodeName());
        }
        
        map->release();
        return true;
    }
    return false;
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:29,代码来源:ofXml.cpp

示例2: svgtiny_parse_line

svgtiny_code svgtiny_parse_line(Poco::XML::Element *line,
		struct svgtiny_parse_state state)
{
	float x1 = 0, y1 = 0, x2 = 0, y2 = 0;
	float *p;
	//xmlAttr *attr;
    Poco::XML::Attr *attr;

	//for (attr = line->properties; attr; attr = attr->next) {
    //for( attr = line->FirstAttribute(); attr; attr = attr->Next() ) {
    
    Poco::XML::NamedNodeMap *map = line->attributes();
    for( int i = 0; i < map->length(); i++ ) {
    
		//const char *name = (const char *) attr->name;
		//const char *content = (const char *) attr->children->content;
        
        //const char *name = (const char *) attr->Name();
		//const char *content = (const char *) attr->Value();
        
        const char *name = (const char *) map->item(i)->localName().c_str();
		const char *content = (const char *) map->item(i)->getNodeValue().c_str();
        
		if (strcmp(name, "x1") == 0)
			x1 = svgtiny_parse_length(content,
					state.viewport_width, state);
		else if (strcmp(name, "y1") == 0)
			y1 = svgtiny_parse_length(content,
					state.viewport_height, state);
		else if (strcmp(name, "x2") == 0)
			x2 = svgtiny_parse_length(content,
					state.viewport_width, state);
		else if (strcmp(name, "y2") == 0)
			y2 = svgtiny_parse_length(content,
					state.viewport_height, state);
        }
	svgtiny_parse_paint_attributes(line, &state);
	svgtiny_parse_transform_attributes(line, &state);

//    p = (float*) malloc(7 * sizeof p[0]);
    p = (float*) malloc(6 * sizeof p[0]);
	if (!p)
		return svgtiny_OUT_OF_MEMORY;

	p[0] = svgtiny_PATH_MOVE;
	p[1] = x1;
	p[2] = y1;
	p[3] = svgtiny_PATH_LINE;
	p[4] = x2;
	p[5] = y2;
//	p[6] = svgtiny_PATH_CLOSE;

//    return svgtiny_add_path(p, 7, &state);
    return svgtiny_add_path(p, 6, &state);    
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:55,代码来源:svgtiny.cpp

示例3: removeAttribute

bool ofXml::removeAttribute(const string& path) 
{

    string attributeName, pathToAttribute;

    Poco::XML::Element *e;
    if(element) {
        
        bool hasPath = false;

        // you can pass either /node[@attr] or just attr
        if(path.find("[@") != string::npos)
        {
            int attrBegin = path.find("[@");
            int start = attrBegin + 2;
            int end = path.find("]", start);
            attributeName = path.substr( start, end - start );
            pathToAttribute = path.substr(0, attrBegin);
            hasPath = true;
        }
        else
        {
            attributeName = path;
        }
        
        if(hasPath) {
            e = (Poco::XML::Element*) element->getNodeByPath(pathToAttribute);
        } else {
            e = element;
        }

    } else {
        ofLogWarning("ofXml") << "clearAttributes(): no element set yet";
        return false;
    }
    
    if(e) {
        Poco::XML::NamedNodeMap *map = e->attributes();
        
		for(unsigned long i = 0; i < map->length(); i++) {
            if(map->item(i)->nodeName() == attributeName) {
                e->removeAttribute(map->item(i)->nodeName());
            }
        }
        
        map->release();
        return true;
    }
    return false;
}
开发者ID:8morikazuto,项目名称:openFrameworks,代码行数:50,代码来源:ofXml.cpp

示例4: it

std::map<std::string, std::string>
XmlHandler::get_attributes_from_tag(const std::string &xpath) {
  std::map<std::string, std::string> attributes_map;
  Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT);
  Poco::XML::Node *pNode = it.nextNode();
  Poco::XML::Node *detectorNode = pNode->getNodeByPath(xpath);
  if (detectorNode) {
    Poco::XML::NamedNodeMap *attributes = detectorNode->attributes();
    for (unsigned int i = 0; i < attributes->length(); i++) {
      Poco::XML::Node *attribute = attributes->item(i);
      attributes_map.emplace(attribute->nodeName(), attribute->nodeValue());
    }
  }
  return attributes_map;
}
开发者ID:DanNixon,项目名称:mantid,代码行数:15,代码来源:XmlHandler.cpp

示例5: svgtiny_parse_position_attributes

void svgtiny_parse_position_attributes(const Poco::XML::Element *node,
		const struct svgtiny_parse_state state,
		float *x, float *y, float *width, float *height)
{
	//xmlAttr *attr;
    const Poco::XML::Attr *attr;

	*x = 0;
	*y = 0;
	*width = state.viewport_width;
	*height = state.viewport_height;

	//for (attr = node->properties; attr; attr = attr->next) {
    //for( attr = node->FirstAttribute(); attr; attr = attr->Next() ) {
    Poco::XML::NamedNodeMap *map = node->attributes();
    //for( attr = node->FirstAttribute(); attr; attr = attr->Next() ) {
    for( int i = 0; i < map->length(); i++ ) {
    
    
		//const char *name = (const char *) attr->name;
		//const char *content = (const char *) attr->children->content;
        
        // good god this is ugly
        const char *name = (const char *) map->item(i)->localName().c_str();
		const char *content = (const char *) map->item(i)->getNodeValue().c_str();
        const string content_str = map->item(i)->getNodeValue();
        
		if (strcmp(name, "x") == 0)
			*x = svgtiny_parse_length(content,
					state.viewport_width, state);
		else if (strcmp(name, "y") == 0)
			*y = svgtiny_parse_length(content,
					state.viewport_height, state);
		else if (strcmp(name, "width") == 0)
			*width = svgtiny_parse_length(content,
					state.viewport_width, state);
		else if (strcmp(name, "height") == 0)
			*height = svgtiny_parse_length(content,
					state.viewport_height, state);
	}
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:41,代码来源:svgtiny.cpp

示例6: svgtiny_parse_ellipse

svgtiny_code svgtiny_parse_ellipse(Poco::XML::Element *ellipse,
		struct svgtiny_parse_state state)
{
	float x = 0, y = 0, rx = -1, ry = -1;
	float *p;
	Poco::XML::Attr *attr;

	//for (attr = ellipse->properties; attr; attr = attr->next) {
    //for( attr = ellipse->FirstAttribute(); attr; attr = attr->Next() ) {
    
    Poco::XML::NamedNodeMap *map = ellipse->attributes();
    for( int i = 0; i < map->length(); i++ ) {
    
		//const char *name = (const char *) attr->name;
		//const char *content = (const char *) attr->children->content;
        
        //const char *name = (const char *) attr->Name();
		//const char *content = (const char *) attr->Value();
        
        const char *name = (const char *) map->item(i)->localName().c_str();
		const char *content = (const char *) map->item(i)->getNodeValue().c_str();
        
		if (strcmp(name, "cx") == 0)
			x = svgtiny_parse_length(content,
					state.viewport_width, state);
		else if (strcmp(name, "cy") == 0)
			y = svgtiny_parse_length(content,
					state.viewport_height, state);
		else if (strcmp(name, "rx") == 0)
			rx = svgtiny_parse_length(content,
					state.viewport_width, state);
		else if (strcmp(name, "ry") == 0)
			ry = svgtiny_parse_length(content,
					state.viewport_width, state);
        }
	svgtiny_parse_paint_attributes(ellipse, &state);
	svgtiny_parse_transform_attributes(ellipse, &state);

	if (rx < 0 || ry < 0) {
		//state.diagram->error_line = ellipse->line;
		state.diagram->error_message = "ellipse: rx or ry missing "
				"or negative";
		return svgtiny_SVG_ERROR;
	}
	if (rx == 0 || ry == 0)
		return svgtiny_OK;

	p = (float*) malloc(32 * sizeof p[0]);
	if (!p)
		return svgtiny_OUT_OF_MEMORY;

	p[0] = svgtiny_PATH_MOVE;
	p[1] = x + rx;
	p[2] = y;
	p[3] = svgtiny_PATH_BEZIER;
	p[4] = x + rx;
	p[5] = y + ry * KAPPA;
	p[6] = x + rx * KAPPA;
	p[7] = y + ry;
	p[8] = x;
	p[9] = y + ry;
	p[10] = svgtiny_PATH_BEZIER;
	p[11] = x - rx * KAPPA;
	p[12] = y + ry;
	p[13] = x - rx;
	p[14] = y + ry * KAPPA;
	p[15] = x - rx;
	p[16] = y;
	p[17] = svgtiny_PATH_BEZIER;
	p[18] = x - rx;
	p[19] = y - ry * KAPPA;
	p[20] = x - rx * KAPPA;
	p[21] = y - ry;
	p[22] = x;
	p[23] = y - ry;
	p[24] = svgtiny_PATH_BEZIER;
	p[25] = x + rx * KAPPA;
	p[26] = y - ry;
	p[27] = x + rx;
	p[28] = y - ry * KAPPA;
	p[29] = x + rx;
	p[30] = y;
	p[31] = svgtiny_PATH_CLOSE;
	
	return svgtiny_add_path(p, 32, &state);
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:86,代码来源:svgtiny.cpp

示例7: svgtiny_parse_paint_attributes

void svgtiny_parse_paint_attributes(const Poco::XML::Element *node,
		struct svgtiny_parse_state *state)
{
	//const xmlAttr *attr;
    const Poco::XML::Attr *attr;

	//for (attr = node->properties; attr; attr = attr->next) {
    
    //for( attr = node->FirstAttribute(); attr; attr = attr->Next() ) {
    Poco::XML::NamedNodeMap *map = node->attributes();
    for( int i = 0; i < map->length(); i++ ) {
    
		//const char *name = (const char *) attr->name;
		//const char *content = (const char *) attr->children->content;
        
        //const char *name = (const char *) attr->Name();
		//const char *content = (const char *) attr->Value();
        attr = (Poco::XML::Attr*) map->item(i);
        const char *name = (const char *) attr->localName().c_str();
		const char *content = (const char *) attr->getNodeValue().c_str();
        
		if (strcmp(name, "fill") == 0)
			svgtiny_parse_color(content, &state->fill, state);
		else if (strcmp(name, "stroke") == 0)
			svgtiny_parse_color(content, &state->stroke, state);
		else if (strcmp(name, "stroke-width") == 0)
			state->stroke_width = svgtiny_parse_length(content,
					state->viewport_width, *state);
		else if (strcmp(name, "style") == 0) {
			//const char *style = (const char *) attr->children->content;
            
            const char *style = attr->getValue().c_str();
            
			const char *s;
			char *value;
			if ((s = strstr(style, "fill:"))) {
				s += 5;
				while (*s == ' ')
					s++;
				value = strndup(s, strcspn(s, "; "));
				svgtiny_parse_color(value, &state->fill, state);
				free(value);
			}
			if ((s = strstr(style, "stroke:"))) {
				s += 7;
				while (*s == ' ')
					s++;
				value = strndup(s, strcspn(s, "; "));
				svgtiny_parse_color(value, &state->stroke, state);
				free(value);
			}
			if ((s = strstr(style, "stroke-width:"))) {
				s += 13;
				while (*s == ' ')
					s++;
				value = strndup(s, strcspn(s, "; "));
				state->stroke_width = svgtiny_parse_length(value,
						state->viewport_width, *state);
				free(value);
			}
        } else if (strcmp(name, "stroke-linecap") == 0) {
            if (strcmp(content, "butt") == 0) {
                state->stroke_linecap = svgtiny_STROKE_LINECAP_BUTT;
            } else if (strcmp(content, "round") == 0) {
                state->stroke_linecap = svgtiny_STROKE_LINECAP_ROUND;
            } else if (strcmp(content, "square") == 0) {
                state->stroke_linecap = svgtiny_STROKE_LINECAP_SQUARE;
            }
        } else if (strcmp(name, "stroke-linejoin") == 0) {
            if (strcmp(content, "miter") == 0) {
                state->stroke_linejoin = svgtiny_STROKE_LINEJOIN_MITER;
            } else if (strcmp(content, "bevel") == 0) {
                state->stroke_linejoin = svgtiny_STROKE_LINEJOIN_BEVEL;
            } else if (strcmp(content, "round") == 0) {
                state->stroke_linejoin = svgtiny_STROKE_LINEJOIN_ROUND;
            }
        }
	}
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:79,代码来源:svgtiny.cpp


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