libpniio
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
pni::io::nx::nxpath Class Reference

Nexus path class. More...

#include <nxpath.hpp>

Collaboration diagram for pni::io::nx::nxpath:
Collaboration graph
[legend]

Public Types

typedef std::pair
< pni::core::string,
pni::core::string > 
element_type
 object element (groupname:class) More...
 
typedef std::list< element_typeelements_type
 a list of subsequent objects More...
 
typedef elements_type::iterator iterator
 iterator over elements More...
 
typedef
elements_type::const_iterator 
const_iterator
 const iterator over elements More...
 

Public Member Functions

 nxpath ()
 default constructor More...
 
 nxpath (const pni::core::string &file, const elements_type &groups, const pni::core::string &attr)
 constructor More...
 
bool has_filename () const noexcept
 true if has filename More...
 
bool has_attribute () const noexcept
 true if has attribute More...
 
pni::core::string filename () const noexcept
 return the filename More...
 
void filename (const pni::core::string &f)
 set the filename More...
 
pni::core::string attribute () const noexcept
 return the attribute name More...
 
void attribute (const pni::core::string &a)
 set the attribute name More...
 
void push_back (const element_type &o)
 append element More...
 
void push_front (const element_type &o)
 prepend element More...
 
void pop_front ()
 last element from path More...
 
void pop_back ()
 remove first element from path More...
 
element_type front () const
 get last element More...
 
element_type back () const
 get first element More...
 
size_t size () const
 return number of group entries More...
 
iterator begin ()
 get iterator to first element More...
 
iterator end ()
 get iterator to last+1 element More...
 
const_iterator begin () const
 get const iterator to first element More...
 
const_iterator end () const
 get const iterator to last+1 element More...
 

Static Public Member Functions

static nxpath from_string (const pni::core::string &input)
 create path from string More...
 
static pni::core::string to_string (const nxpath &p)
 create string from path More...
 

Private Attributes

pni::core::string _file_name
 name of the file More...
 
pni::core::string _attribute_name
 name of an attribute More...
 
elements_type _elements
 list of groups More...
 

Detailed Description

This class represents a full Nexus path. Such a path describes the position of an object within a Nexus file. In general the path has a form like this

filename://entry:NXentry/instrument:NXinstrument/detector/data@attrname

More specific this can be written as

[filename://]path

Usage

string path_str = .....;
nxpath path = nxpath::from_string(path_str);

A path can either be absolute or relative to a particular object. However, a path with a filename part is always absolute (for obvious reasons).

Member Typedef Documentation

typedef elements_type::const_iterator pni::io::nx::nxpath::const_iterator
typedef std::pair<pni::core::string,pni::core::string> pni::io::nx::nxpath::element_type
typedef elements_type::iterator pni::io::nx::nxpath::iterator

Constructor & Destructor Documentation

pni::io::nx::nxpath::nxpath ( )
pni::io::nx::nxpath::nxpath ( const pni::core::string &  file,
const elements_type groups,
const pni::core::string &  attr 
)
explicit
Parameters
filename of the file
groupsa list of elements for the object path
attrthe optional name of an attribute

Member Function Documentation

pni::core::string pni::io::nx::nxpath::attribute ( ) const
noexcept
void pni::io::nx::nxpath::attribute ( const pni::core::string &  a)
nxpath::element_type pni::io::nx::nxpath::back ( ) const

Return the first element of the Nexus path

Returns
first element
nxpath::iterator pni::io::nx::nxpath::begin ( )
nxpath::const_iterator pni::io::nx::nxpath::begin ( ) const
nxpath::iterator pni::io::nx::nxpath::end ( )
nxpath::const_iterator pni::io::nx::nxpath::end ( ) const
pni::core::string pni::io::nx::nxpath::filename ( ) const
noexcept
void pni::io::nx::nxpath::filename ( const pni::core::string &  f)
nxpath pni::io::nx::nxpath::from_string ( const pni::core::string &  input)
static

This method creates a path from a string passed to it.

Exceptions
parser_errorin case of parsing problems
Parameters
inputstring with path representation
Returns
path instance
element_type pni::io::nx::nxpath::front ( ) const
inline

Return the last element of the Nexus path.

Returns
last element
bool pni::io::nx::nxpath::has_attribute ( ) const
noexcept

Returns true if the path contains an attribute name.

Returns
true if path has attribute
bool pni::io::nx::nxpath::has_filename ( ) const
noexcept

Returns true if the path contains a file name.

Returns
true if filename exists
void pni::io::nx::nxpath::pop_back ( )
void pni::io::nx::nxpath::pop_front ( )
void pni::io::nx::nxpath::push_back ( const element_type o)

Append a new element to the end of the Nexus path.

Exceptions
value_errorif one tries to push_back a root group to a non-empty path
Parameters
oelement to append
void pni::io::nx::nxpath::push_front ( const element_type o)

Append an element to the beginning of the Nexus path.

Parameters
oelement to append
size_t pni::io::nx::nxpath::size ( ) const
pni::core::string pni::io::nx::nxpath::to_string ( const nxpath p)
static

Returns the string representation of a path.

Parameters
preference to path instance
Returns
string representation of the path

Field Documentation

pni::core::string pni::io::nx::nxpath::_attribute_name
private
elements_type pni::io::nx::nxpath::_elements
private
pni::core::string pni::io::nx::nxpath::_file_name
private

The documentation for this class was generated from the following files: