NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
xml::xpath_expression Class Reference

Search Toolkit Book for xml::xpath_expression

The xml::xpath_expression class is used to store xpath query string and optional XML namespaces. More...

#include <misc/xmlwrapp/xpath_expression.hpp>

+ Collaboration diagram for xml::xpath_expression:

Public Types

enum  compile_type { type_no_compile , type_compile }
 xpath expression compilation flag More...
 

Public Member Functions

 xpath_expression (const char *xpath, compile_type do_compile=type_no_compile)
 Create a new xml::xpath_expression object with the given xpath expression. More...
 
 xpath_expression (const char *xpath, const ns &nspace, compile_type do_compile=type_no_compile)
 Create a new xml::xpath_expression object with the given xpath expression and a registered namespace. More...
 
 xpath_expression (const char *xpath, const ns_list_type &nspace_list, compile_type do_compile=type_no_compile)
 Create a new xml::xpath_expression object with the given xpath expression and a list of registered namespaces. More...
 
 xpath_expression (const xpath_expression &other)
 Create a new xml::xpath_expression object using another one as a template. More...
 
xpath_expressionoperator= (const xpath_expression &other)
 Create a copy of the xml::xpath_expression object. More...
 
virtual ~xpath_expression ()
 Destroy the object and clean up the memory. More...
 
void compile ()
 Precompile the expression. More...
 
const char * get_xpath () const
 Provide the xpath expression as a string. More...
 
const ns_list_typeget_namespaces () const
 Provide the list of the registered XML namespaces. More...
 
compile_type get_compile_type () const
 Provide the expression pre-compilation flag. More...
 
 xpath_expression (xpath_expression &&other)
 Moving constructor. More...
 
xpath_expressionoperator= (xpath_expression &&other)
 Moving assignment. More...
 

Private Member Functions

void compile_expression ()
 
void * get_compiled_expression () const
 

Private Attributes

compile_type compile_
 
std::string expression_
 
ns_list_type nspace_list_
 
void * compiled_expression_
 

Friends

class node
 

Detailed Description

The xml::xpath_expression class is used to store xpath query string and optional XML namespaces.

Definition at line 57 of file xpath_expression.hpp.

Member Enumeration Documentation

◆ compile_type

xpath expression compilation flag

Enumerator
type_no_compile 
type_compile 

Definition at line 61 of file xpath_expression.hpp.

Constructor & Destructor Documentation

◆ xpath_expression() [1/5]

xml::xpath_expression::xpath_expression ( const char *  xpath,
compile_type  do_compile = type_no_compile 
)

Create a new xml::xpath_expression object with the given xpath expression.

Parameters
xpathThe xpath expression.
do_compileWhether to compile or not the xpath expression. Default: do not.
Exceptions
Throwsexceptions in case of problems
Author
Sergey Satskiy, NCBI

Definition at line 57 of file xpath_expression.cpp.

References compile_expression(), expression_, and xml::kEmptyExpression.

◆ xpath_expression() [2/5]

xml::xpath_expression::xpath_expression ( const char *  xpath,
const ns nspace,
compile_type  do_compile = type_no_compile 
)

Create a new xml::xpath_expression object with the given xpath expression and a registered namespace.

The namespace cannot be a default one.

Parameters
xpathThe xpath expression.
nspaceRegistered namespace.
do_compileWhether to compile or not the xpath expression. Default: do not.
Exceptions
Throwsexceptions in case of problems
Author
Sergey Satskiy, NCBI

Definition at line 69 of file xpath_expression.cpp.

References compile_expression(), expression_, xml::ns::get_prefix(), xml::kDefaultNamespace, xml::kEmptyExpression, and nspace_list_.

◆ xpath_expression() [3/5]

xml::xpath_expression::xpath_expression ( const char *  xpath,
const ns_list_type nspace_list,
compile_type  do_compile = type_no_compile 
)

Create a new xml::xpath_expression object with the given xpath expression and a list of registered namespaces.

The list of namespaces cannot have a default namespace.

Parameters
xpathThe xpath expression.
nspace_listRegistered namespaces.
do_compileWhether to compile or not the xpath expression. Default: do not.
Exceptions
Throwsexceptions in case of problems
Author
Sergey Satskiy, NCBI

Definition at line 88 of file xpath_expression.cpp.

References compile_expression(), expression_, xml::kDefaultNamespace, xml::kEmptyExpression, and nspace_list_.

◆ xpath_expression() [4/5]

xml::xpath_expression::xpath_expression ( const xpath_expression other)

Create a new xml::xpath_expression object using another one as a template.

Parameters
otherAnother xml::xpath_expression object.
Exceptions
Throwsexceptions in case of problems
Author
Sergey Satskiy, NCBI

Definition at line 108 of file xpath_expression.cpp.

References compile_expression().

◆ ~xpath_expression()

xml::xpath_expression::~xpath_expression ( )
virtual

Destroy the object and clean up the memory.

Author
Sergey Satskiy, NCBI

Definition at line 134 of file xpath_expression.cpp.

References compiled_expression_, and NULL.

◆ xpath_expression() [5/5]

xml::xpath_expression::xpath_expression ( xpath_expression &&  other)

Moving constructor.

Parameters
otherThe other xpath expression.

Definition at line 143 of file xpath_expression.cpp.

References NULL.

Member Function Documentation

◆ compile()

void xml::xpath_expression::compile ( )

Precompile the expression.

Author
Sergey Satskiy, NCBI

Definition at line 170 of file xpath_expression.cpp.

References compile_, compile_expression(), and type_compile.

◆ compile_expression()

void xml::xpath_expression::compile_expression ( )
private

Definition at line 203 of file xpath_expression.cpp.

References compile_, compiled_expression_, expression_, string, and type_compile.

Referenced by compile(), operator=(), and xpath_expression().

◆ get_compile_type()

xpath_expression::compile_type xml::xpath_expression::get_compile_type ( ) const

Provide the expression pre-compilation flag.

Returns
The expression pre-compilation flag
Author
Sergey Satskiy, NCBI

Definition at line 191 of file xpath_expression.cpp.

References compile_.

Referenced by xml::node::evaluate_xpath_expression().

◆ get_compiled_expression()

void * xml::xpath_expression::get_compiled_expression ( ) const
private

Definition at line 197 of file xpath_expression.cpp.

References compiled_expression_.

Referenced by xml::node::evaluate_xpath_expression().

◆ get_namespaces()

const ns_list_type & xml::xpath_expression::get_namespaces ( ) const

Provide the list of the registered XML namespaces.

Returns
The stored list of the registered XML namespaces
Author
Sergey Satskiy, NCBI

Definition at line 185 of file xpath_expression.cpp.

References nspace_list_.

Referenced by xml::node::create_xpath_context().

◆ get_xpath()

const char * xml::xpath_expression::get_xpath ( ) const

Provide the xpath expression as a string.

Returns
The stored xpath expression
Author
Sergey Satskiy, NCBI

Definition at line 179 of file xpath_expression.cpp.

References expression_.

Referenced by xml::node::evaluate_xpath_expression().

◆ operator=() [1/2]

xpath_expression & xml::xpath_expression::operator= ( const xpath_expression other)

Create a copy of the xml::xpath_expression object.

Parameters
otherAnother xml::xpath_expression object.
Exceptions
Throwsexceptions in case of problems
Author
Sergey Satskiy, NCBI

Definition at line 116 of file xpath_expression.cpp.

References compile_, compile_expression(), compiled_expression_, expression_, nspace_list_, and NULL.

◆ operator=() [2/2]

xpath_expression & xml::xpath_expression::operator= ( xpath_expression &&  other)

Moving assignment.

Parameters
otherThe other xpath expression.

Definition at line 153 of file xpath_expression.cpp.

References compile_, compiled_expression_, expression_, nspace_list_, and NULL.

Friends And Related Function Documentation

◆ node

friend class node
friend

Definition at line 203 of file xpath_expression.hpp.

Member Data Documentation

◆ compile_

compile_type xml::xpath_expression::compile_
private

Definition at line 195 of file xpath_expression.hpp.

Referenced by compile(), compile_expression(), get_compile_type(), and operator=().

◆ compiled_expression_

void* xml::xpath_expression::compiled_expression_
private

◆ expression_

std::string xml::xpath_expression::expression_
private

Definition at line 196 of file xpath_expression.hpp.

Referenced by compile_expression(), get_xpath(), operator=(), and xpath_expression().

◆ nspace_list_

ns_list_type xml::xpath_expression::nspace_list_
private

Definition at line 197 of file xpath_expression.hpp.

Referenced by get_namespaces(), operator=(), and xpath_expression().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:58:01 2024 by modify_doxy.py rev. 669887