本文整理汇总了C++中xmlTextReaderConstLocalName函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlTextReaderConstLocalName函数的具体用法?C++ xmlTextReaderConstLocalName怎么用?C++ xmlTextReaderConstLocalName使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlTextReaderConstLocalName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __attribute__nonnull__
static struct cpe_ext_deprecatedby *cpe_ext_deprecatedby_parse(xmlTextReaderPtr reader)
{
__attribute__nonnull__(reader);
if (xmlStrcmp(xmlTextReaderConstLocalName(reader), BAD_CAST TAG_CPE_EXT_DEPRECATEDBY_STR) != 0 ||
xmlTextReaderNodeType(reader) != 1) {
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Found '%s' node when expecting: '%s'!",
xmlTextReaderConstLocalName(reader), TAG_CPE_EXT_DEPRECATEDBY_STR);
}
const xmlChar* nsuri = xmlTextReaderConstNamespaceUri(reader);
if (nsuri && xmlStrcmp(nsuri, BAD_CAST XMLNS_CPE2D3_EXTENSION) != 0) {
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Found '%s' namespace when expecting: '%s'!",
nsuri, XMLNS_CPE2D3_EXTENSION);
return NULL;
}
struct cpe_ext_deprecatedby *deprecatedby = cpe_ext_deprecatedby_new();
deprecatedby->name = (char *) xmlTextReaderGetAttribute(reader, BAD_CAST ATTR_NAME_STR);
const char *type = (const char *) xmlTextReaderGetAttribute(reader, BAD_CAST ATTR_TYPE_STR);
if (type == NULL) {
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Compulsory attribute '%s' missing at '%s' element.",
ATTR_TYPE_STR, TAG_CPE_EXT_DEPRECATEDBY_STR);
cpe_ext_deprecatedby_free(deprecatedby);
return NULL;
}
deprecatedby->type = oscap_string_to_enum(CPE_EXT_DEPRECATION_MAP, type);
return deprecatedby;
}
示例2: assert
struct cvss_metrics *cvss_metrics_new_from_xml(xmlTextReaderPtr reader)
{
assert(reader != NULL);
int depth = oscap_element_depth(reader);
enum cvss_category cat = CVSS_NONE;
const char *elname = (const char *) xmlTextReaderConstLocalName(reader);
if (oscap_streq(elname, "base_metrics")) cat = CVSS_BASE;
if (oscap_streq(elname, "temporal_metrics")) cat = CVSS_TEMPORAL;
if (oscap_streq(elname, "environmental_metrics")) cat = CVSS_ENVIRONMENTAL;
if (cat == CVSS_NONE) return NULL;
struct cvss_metrics *ret = cvss_metrics_new(cat);
ret->upgraded_from_version = (char*) xmlTextReaderGetAttribute(reader, BAD_CAST "upgraded-from-version");
xmlTextReaderRead(reader);
while (oscap_to_start_element(reader, depth + 1)) {
elname = (const char *) xmlTextReaderConstLocalName(reader);
if (oscap_streq(elname, "score")) ret->score = atof(oscap_element_string_get(reader));
else if (oscap_streq(elname, "source")) cvss_metrics_set_source(ret, oscap_element_string_get(reader));
else if (oscap_streq(elname, "generated-on-datetime")) cvss_metrics_set_generated_on_datetime(ret, oscap_element_string_get(reader));
else {
const struct cvss_valtab_entry *val = cvss_valtab(cvss_keytab(0, elname)->key, 0, NULL, oscap_element_string_get(reader));
if (CVSS_CATEGORY(val->key) == cat) ret->metrics.ANY[CVSS_KEY_IDX(val->key)] = val->value;
}
xmlTextReaderRead(reader);
}
return ret;
}
示例3: __attribute__nonnull__
struct cpe_lang_model *cpe_lang_model_parse(xmlTextReaderPtr reader)
{
struct cpe_lang_model *ret = NULL;
struct cpe_platform *platform = NULL;
__attribute__nonnull__(reader);
if (!xmlStrcmp(xmlTextReaderConstLocalName(reader), TAG_PLATFORM_SPEC_STR) &&
xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) {
ret = cpe_lang_model_new();
if (ret == NULL)
return NULL;
// skip nodes until new element
xmlTextReaderNextElementWE(reader, TAG_PLATFORM_SPEC_STR);
while (xmlStrcmp(xmlTextReaderConstLocalName(reader), TAG_PLATFORM_STR) == 0) {
platform = cpe_platform_parse(reader);
if (platform)
cpe_lang_model_add_platform(ret, platform);
xmlTextReaderNextElementWE(reader, TAG_PLATFORM_SPEC_STR);
}
}
return ret;
}
示例4: calloc
/**
* Reads a Nodes from XML. The reader is assumed to be at the start element.
*
* @return the Nodes, or NULL in case of error.
*/
static struct full_ns0_nodes *xmlTextReaderReadNs0NodesType(xmlTextReaderPtr reader) {
int status, depth;
void *_child_accessor;
struct full_ns0_nodes *_nodes = calloc(1, sizeof(struct full_ns0_nodes));
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
freeNs0NodesType(_nodes);
free(_nodes);
return NULL;
}
else if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT
&& xmlStrcmp(BAD_CAST "node", xmlTextReaderConstLocalName(reader)) == 0
&& xmlTextReaderConstNamespaceUri(reader) == NULL) {
#if DEBUG_ENUNCIATE > 1
printf("Attempting to read choice {}node of type {}node.\n");
#endif
_child_accessor = xmlTextReaderReadNs0NodeType(reader);
if (_child_accessor == NULL) {
#if DEBUG_ENUNCIATE
printf("Failed to read choice {}node of type {}node.\n");
#endif
//panic: unable to read the child element for some reason.
freeNs0NodesType(_nodes);
free(_nodes);
return NULL;
}
_nodes->node = realloc(_nodes->node, (_nodes->_sizeof_node + 1) * sizeof(struct full_ns0_node));
memcpy(&(_nodes->node[_nodes->_sizeof_node++]), _child_accessor, sizeof(struct full_ns0_node));
free(_child_accessor);
status = xmlTextReaderAdvanceToNextStartOrEndElement(reader);
}
else {
#if DEBUG_ENUNCIATE > 1
if (xmlTextReaderConstNamespaceUri(reader) == NULL) {
printf("unknown child element {}%s for type {}nodes. Skipping...\n", xmlTextReaderConstLocalName(reader));
}
else {
printf("unknown child element {%s}%s for type {}nodes. Skipping...\n", xmlTextReaderConstNamespaceUri(reader), xmlTextReaderConstLocalName(reader));
}
#endif
status = xmlTextReaderSkipElement(reader);
}
}
}
return _nodes;
}
示例5: parse_propfind_response
static response_element_t *
parse_propfind_response (xmlTextReaderPtr reader)
{
parser_strings_t strings;
response_element_t *elements;
/* get internalized versions of some strings to avoid strcmp while
* parsing */
strings.multistatus
= xmlTextReaderConstString (reader, BAD_CAST "multistatus");
strings.dav = xmlTextReaderConstString (reader, BAD_CAST "DAV:");
strings.href = xmlTextReaderConstString (reader, BAD_CAST "href");
strings.response = xmlTextReaderConstString (reader, BAD_CAST "response");
strings.propstat = xmlTextReaderConstString (reader, BAD_CAST "propstat");
strings.prop = xmlTextReaderConstString (reader, BAD_CAST "prop");
strings.getetag = xmlTextReaderConstString (reader, BAD_CAST "getetag");
while (xmlTextReaderRead (reader) == 1 && xmlTextReaderNodeType (reader) != XML_READER_TYPE_ELEMENT) {
}
if (xmlTextReaderConstLocalName (reader) != strings.multistatus
|| xmlTextReaderConstNamespaceUri (reader) != strings.dav) {
g_warning ("webdav PROPFIND result is not <DAV:multistatus>");
return NULL;
}
elements = NULL;
/* parse all DAV:response tags */
while (xmlTextReaderRead (reader) == 1 && xmlTextReaderDepth (reader) > 0) {
response_element_t *element;
if (xmlTextReaderNodeType (reader) != XML_READER_TYPE_ELEMENT)
continue;
if (xmlTextReaderConstLocalName (reader) != strings.response
|| xmlTextReaderConstNamespaceUri (reader) != strings.dav)
continue;
element = parse_response_tag (&strings, reader);
if (element == NULL)
continue;
element->next = elements;
elements = element;
}
return elements;
}
示例6: xml_reader_get_local_name
G_CONST_RETURN gchar *
xml_reader_get_local_name (XmlReader *reader)
{
g_return_val_if_fail(XML_IS_READER (reader), NULL);
return XML_TO_CHAR (xmlTextReaderConstLocalName (reader->xml));
}
示例7: HHVM_METHOD
bool HHVM_METHOD(XMLReader, next,
const Variant& localname /*= null_variant*/) {
auto* data = Native::data<XMLReader>(this_);
const String& str_localname = localname.isNull()
? null_string
: localname.toString();
SYNC_VM_REGS_SCOPED();
if (data->m_ptr) {
int ret = xmlTextReaderNext(data->m_ptr);
while (!str_localname.empty() && ret == 1) {
if (xmlStrEqual(xmlTextReaderConstLocalName(data->m_ptr),
(xmlChar *)str_localname.data())) {
return true;
}
ret = xmlTextReaderNext(data->m_ptr);
}
if (ret == -1) {
raise_warning("An Error Occurred while reading");
return false;
} else {
return ret;
}
}
raise_warning("Load Data before trying to read");
return false;
}
示例8: PHP_METHOD
/* {{{ proto bool XMLReader::next([string localname])
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, next)
{
zval *id;
int retval;
size_t name_len=0;
xmlreader_object *intern;
char *name = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &name, &name_len) == FAILURE) {
return;
}
id = ZEND_THIS;
intern = Z_XMLREADER_P(id);
if (intern != NULL && intern->ptr != NULL) {
retval = xmlTextReaderNext(intern->ptr);
while (name != NULL && retval == 1) {
if (xmlStrEqual(xmlTextReaderConstLocalName(intern->ptr), (xmlChar *)name)) {
RETURN_TRUE;
}
retval = xmlTextReaderNext(intern->ptr);
}
if (retval == -1) {
RETURN_FALSE;
} else {
RETURN_BOOL(retval);
}
}
php_error_docref(NULL, E_WARNING, "Load Data before trying to read");
RETURN_FALSE;
}
示例9: xmlTextReaderAttributeCount
bool XMLReader::processNode()
{
if (m_reader == NULL)
{
std::cout << "error" << std::endl ;
}
if (xmlTextReaderRead(m_reader) != 1)
{
return false ;
}
m_attributes.clear() ;
if (xmlTextReaderHasAttributes(m_reader) == 1)
{
int count = xmlTextReaderAttributeCount(m_reader) ;
for (int i = 0 ; i < count ; i++)
{
xmlTextReaderMoveToAttributeNo(m_reader, i) ;
m_attributes.insert(
std::pair<std::string, std::string>(
(char*) xmlTextReaderConstLocalName(
m_reader),
(char*) xmlTextReaderConstValue(
m_reader))) ;
}
xmlTextReaderMoveToElement(m_reader) ;
}
// std::cout << print() << std::endl ;
return true ;
}
示例10: rxml_reader_local_name
/*
* call-seq:
* reader.local_name -> name
*
* Return the local name of the node.
*/
static VALUE rxml_reader_local_name(VALUE self)
{
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
const xmlChar *result = xmlTextReaderConstLocalName(xReader);
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
}
示例11: strcmp
struct rds_asset_index *rds_asset_index_parse(xmlTextReaderPtr reader)
{
// sanity check
if (xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT ||
strcmp((const char*)xmlTextReaderConstLocalName(reader), "asset") != 0) {
oscap_seterr(OSCAP_EFAMILY_XML,
"Expected to have xmlTextReader at start of <arf:report>, "
"the current event is '%i' at '%s' instead. I refuse to parse!",
xmlTextReaderNodeType(reader), (const char*)xmlTextReaderConstLocalName(reader));
return NULL;
}
struct rds_asset_index *ret = rds_asset_index_new();
ret->id = (char*)xmlTextReaderGetAttribute(reader, BAD_CAST "id");
return ret;
}
示例12: EPUB3ProcessXMLReaderNodeForManifestInOPF
EPUB3Error EPUB3ProcessXMLReaderNodeForManifestInOPF(EPUB3Ref epub, xmlTextReaderPtr reader, EPUB3XMLParseContextPtr *context)
{
assert(epub != NULL);
assert(reader != NULL);
EPUB3Error error = kEPUB3Success;
const xmlChar *name = xmlTextReaderConstLocalName(reader);
xmlReaderTypes nodeType = xmlTextReaderNodeType(reader);
switch(nodeType)
{
case XML_READER_TYPE_ELEMENT:
{
if(!xmlTextReaderIsEmptyElement(reader)) {
(void)EPUB3SaveParseContext(context, kEPUB3OPFStateManifest, name, 0, NULL, kEPUB3_YES, NULL);
} else {
if(xmlStrcmp(name, BAD_CAST "item") == 0) {
EPUB3ManifestItemRef newItem = EPUB3ManifestItemCreate();
newItem->itemId = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "id");
newItem->href = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "href");
newItem->mediaType = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "media-type");
newItem->properties = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "properties");
if(newItem->properties != NULL) {
// Look for the cover-image property
char *prop, *props, *tofree;
tofree = props = strdup(newItem->properties);
while((prop = strsep(&props, " ")) != NULL) {
if(strcmp(prop, "cover-image") == 0) {
EPUB3MetadataSetCoverImageId(epub->metadata, newItem->itemId);
}
}
EPUB3_FREE_AND_NULL(tofree);
}
if(newItem->mediaType != NULL && strcmp(newItem->mediaType, "application/x-dtbncx+xml") == 0) {
//This is the ref for the ncx document. Set it for v2 epubs
//if(epub->metadata->version == kEPUB3Version_2) {
EPUB3MetadataSetNCXItem(epub->metadata, newItem);
//}
}
EPUB3ManifestInsertItem(epub->manifest, newItem);
}
}
break;
}
case XML_READER_TYPE_TEXT:
{
break;
}
case XML_READER_TYPE_END_ELEMENT:
{
(void)EPUB3PopAndFreeParseContext(context);
break;
}
default: break;
}
return error;
}
示例13: xmlTextReaderRead
xmlNodePtr ProtoXml::IterParser::GetNext()
{
//TRACE("enter ProtoXml::IterParser::GetNext() prev_node:%s\n", prev_node ? (const char*)prev_node->name : "(null)");
int result;
// If we didn't just return a "prev_node", then read the
// very next sequential node w/ xmlTextReaderRead(), else
// skip entire "prev_node" sub-tree w/ xmlTextReaderNext()
if (NULL == prev_node)
result = xmlTextReaderRead(reader_ptr);
else
result = xmlTextReaderNext(reader_ptr);
prev_node = NULL;
switch (result)
{
case 0:
return NULL;
case -1:
PLOG(PL_ERROR, "ProtoXml::IterParser::GetNext() xmlTextReaderRead error!\n");
return NULL;
default:
break;
}
do
{
int nodeType = xmlTextReaderNodeType(reader_ptr);
if (XML_READER_TYPE_ELEMENT != nodeType)
continue;
const char* nodeName = (const char*)xmlTextReaderConstLocalName(reader_ptr);
if (NULL == nodeName)
{
PLOG(PL_ERROR, "ProtoXml::IterParser::GetNext() xmlTextReaderConstLocalName() error\n");
return NULL;
}
int nodeDepth = xmlTextReaderDepth(reader_ptr);
if (nodeDepth < 0)
{
PLOG(PL_ERROR, "ProtoXml::IterParser::GetNext() xmlTextReaderDepth() error\n");
return NULL;
}
if (!IterFilterBase::UpdateCurrentPath(nodeDepth, nodeName))
{
PLOG(PL_WARN, "ProtoXml::IterParser::GetNext() error: unable to update current path\n");
continue;
}
if (!IterFilterBase::IsMatch())
continue; // no match, so continue
prev_node = xmlTextReaderExpand(reader_ptr);
if (NULL == prev_node)
PLOG(PL_ERROR, "ProtoXml::IterParser::GetNext() xmlTextReaderExpand() error!\n");
return prev_node;
} while ((result = xmlTextReaderRead(reader_ptr)) > 0);
if (result < 0)
PLOG(PL_ERROR, "ProtoXml::IterParser::GetNext() xmlTextReaderRead() error!\n");
return NULL;
} // end ProtoXml::IterParser::GetNext()
示例14: EPUB3CopyRootFilePathFromContainer
EXPORT EPUB3Error EPUB3CopyRootFilePathFromContainer(EPUB3Ref epub, char ** rootPath)
{
assert(epub != NULL);
if(epub->archive == NULL) return kEPUB3ArchiveUnavailableError;
static const char *containerFilename = "META-INF/container.xml";
void *buffer = NULL;
uint32_t bufferSize = 0;
uint32_t bytesCopied;
xmlTextReaderPtr reader = NULL;
EPUB3Bool foundPath = kEPUB3_NO;
EPUB3Error error = kEPUB3Success;
error = EPUB3CopyFileIntoBuffer(epub, &buffer, &bufferSize, &bytesCopied, containerFilename);
if(error == kEPUB3Success) {
reader = xmlReaderForMemory(buffer, bufferSize, "", NULL, XML_PARSE_RECOVER);
if(reader != NULL) {
int retVal;
while((retVal = xmlTextReaderRead(reader)) == 1)
{
const char *rootFileName = "rootfile";
const xmlChar *name = xmlTextReaderConstLocalName(reader);
if(xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT && xmlStrcmp(name, BAD_CAST rootFileName) == 0) {
xmlChar *fullPath = xmlTextReaderGetAttribute(reader, BAD_CAST "full-path");
if(fullPath != NULL) {
// TODD: validate that the full-path attribute is of the form path-rootless
// see http://idpf.org/epub/30/spec/epub30-ocf.html#sec-container-metainf-container.xml
foundPath = kEPUB3_YES;
*rootPath = strdup((char *)fullPath);
} else {
// The spec requires the full-path attribute
error = kEPUB3XMLXDocumentInvalidError;
}
break;
}
}
if(retVal < 0) {
error = kEPUB3XMLParseError;
}
if(!foundPath) {
error = kEPUB3XMLXElementNotFoundError;
}
} else {
error = kEPUB3XMLReadFromBufferError;
}
EPUB3_FREE_AND_NULL(buffer);
}
xmlFreeTextReader(reader);
return error;
}
示例15: local_name
/*
* call-seq:
* local_name
*
* Get the local name of the node
*/
static VALUE local_name(VALUE self)
{
xmlTextReaderPtr reader;
Data_Get_Struct(self, xmlTextReader, reader);
const char * name = (const char *)xmlTextReaderConstLocalName(reader);
if(name == NULL) return Qnil;
VALUE MAYBE_UNUSED(enc) = rb_iv_get(self, "@encoding");
return NOKOGIRI_STR_NEW2(name,
RTEST(enc) ? StringValuePtr(enc) : NULL);
}