libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_PARSER_XML_NODE_H 00013 #define ZYPP_PARSER_XML_NODE_H 00014 00015 #include <iosfwd> 00016 00017 #include "zypp/base/SafeBool.h" 00018 00019 #include "zypp/parser/xml/XmlString.h" 00020 00022 namespace zypp 00023 { 00024 00025 namespace xml 00026 { 00027 00029 // 00030 // CLASS NAME : Node 00031 // 00037 class Node : private base::SafeBool<Node> 00038 { 00039 public: 00041 Node(); 00042 00044 Node( xmlTextReaderPtr const & reader_r ); 00045 00047 using base::SafeBool<Node>::operator bool_type; 00048 00049 public: 00051 int attributeCount() const 00052 { return xmlTextReaderAttributeCount( _reader ); } 00053 00055 XmlString baseUri() const 00056 { return xmlTextReaderConstBaseUri( _reader ); } 00057 00059 int columnNumber() const 00060 { return xmlTextReaderGetParserColumnNumber( _reader ); } 00061 00063 int depth() const 00064 { return xmlTextReaderDepth( _reader ); } 00065 00067 XmlString encoding() const 00068 { return xmlTextReaderConstEncoding( _reader ); } 00069 00072 XmlString getAttribute( const char * name_r ) const 00073 { return XmlString( xmlTextReaderGetAttribute( _reader, reinterpret_cast<const xmlChar *>(name_r) ), 00074 XmlString::FREE ); } 00075 00078 XmlString getAttributeNo( int no_r ) const 00079 { return XmlString( xmlTextReaderGetAttributeNo( _reader, no_r ), XmlString::FREE ); } 00080 00082 int hasAttributes() const 00083 { return xmlTextReaderHasAttributes( _reader ); } 00084 00086 int hasValue() const 00087 { return xmlTextReaderHasValue( _reader ); } 00088 00090 bool isAttribute() const 00091 { return( nodeType() == XML_READER_TYPE_ATTRIBUTE ); } 00092 00095 int isDefault() const 00096 { return xmlTextReaderIsDefault( _reader ); } 00097 00099 int isEmptyElement() const 00100 { return xmlTextReaderIsEmptyElement( _reader ); } 00101 00104 int isNamespaceDecl() const 00105 { return xmlTextReaderIsNamespaceDecl( _reader ); } 00106 00108 int lineNumber() const 00109 { return xmlTextReaderGetParserLineNumber( _reader ); } 00110 00112 XmlString localName() const 00113 { return xmlTextReaderConstLocalName( _reader ); } 00114 00116 XmlString name() const 00117 { return xmlTextReaderConstName( _reader ); } 00118 00120 XmlString namespaceUri() const 00121 { return xmlTextReaderConstNamespaceUri( _reader ); } 00122 00124 NodeType nodeType() const 00125 { return (NodeType)xmlTextReaderNodeType( _reader ); } 00126 00128 XmlString prefix() const 00129 { return xmlTextReaderConstPrefix( _reader ); } 00130 00133 int quoteChar() const 00134 { return xmlTextReaderQuoteChar( _reader ); } 00135 00137 ReadState readState() const 00138 { return (ReadState)xmlTextReaderReadState( _reader ); } 00139 00141 XmlString value() const 00142 { return xmlTextReaderConstValue( _reader ); } 00143 00145 XmlString getValue() const 00146 { return XmlString( xmlTextReaderValue( _reader ), XmlString::FREE ); } 00147 00149 XmlString xmlLang() const 00150 { return xmlTextReaderConstXmlLang( _reader ); } 00151 00153 XmlString xmlVersion() const 00154 { return xmlTextReaderConstXmlVersion( _reader ); } 00155 00156 private: 00158 static xmlTextReaderPtr const _no_reader; 00160 xmlTextReaderPtr const & _reader; 00161 00162 private: 00163 friend base::SafeBool<Node>::operator bool_type() const; 00165 bool boolTest() const { return _reader; } 00166 }; 00168 00170 std::ostream & operator<<( std::ostream & str, const Node & obj ); 00171 00173 } // namespace xml 00176 } // namespace zypp 00178 #endif // ZYPP_PARSER_XML_NODE_H