ome-common  5.5.0
Namespaces | Classes | Typedefs | Functions
ome::common Namespace Reference

OME compatibility functions and classes. More...

Namespaces

 units
 Units of measurement.
 
 xml
 Xerces-C modern C++ wrapper.
 
 xsl
 Xalan-C modern C++ wrapper.
 

Classes

class  boolean
 Boolean type with guaranteed size, alignment and storage values. More...
 
struct  Module
 A run-time path for a given module. More...
 
struct  RegisterModule
 Register a module to make it available to module_runtime_path(). More...
 

Typedefs

typedef logging::sources::severity_logger_mt< logging::trivial::severity_level > Logger
 Message logger.
 
typedef boost::iostreams::basic_array_source< char > mstream_source
 Character array stream source.
 
typedef boost::iostreams::stream< mstream_sourceimstream
 Input memory stream.
 

Functions

template<typename Iterator >
std::string base64_encode (Iterator begin, Iterator end, uint8_t linebreak=76)
 Base64-encode a range of bytes. More...
 
template<typename InsertIterator >
void base64_decode (std::string base64, InsertIterator dest)
 Decode a Base64-encoded string. More...
 
template<typename Container >
Container base64_decode (const std::string &base64)
 Decode a Base64-encoded string into a container. More...
 
bool operator== (const boolean &lhs, bool rhs)
 Compare boolean with bool for equality. More...
 
bool operator== (bool lhs, const boolean &rhs)
 Compare bool with boolean for equality. More...
 
bool operator== (const boolean &lhs, const boolean &rhs)
 Compare boolean with boolean for equality. More...
 
bool operator!= (const boolean &lhs, bool rhs)
 Compare boolean with bool for inequality. More...
 
bool operator!= (bool lhs, const boolean &rhs)
 Compare bool with boolean for inequality. More...
 
bool operator!= (const boolean &lhs, const boolean &rhs)
 Compare bool with boolean for inequality. More...
 
template<class charT , class traits >
std::basic_ostream< charT, traits > & operator<< (std::basic_ostream< charT, traits > &os, const boolean &rhs)
 Output boolean to output stream. More...
 
template<class charT , class traits >
std::basic_istream< charT, traits > & operator>> (std::basic_istream< charT, traits > &is, boolean &rhs)
 Set boolean from input stream. More...
 
boost::filesystem::path absolute (const boost::filesystem::path &p, const boost::filesystem::path &base=boost::filesystem::current_path())
 Get an absolute path. More...
 
boost::filesystem::path canonical (const boost::filesystem::path &p, const boost::filesystem::path &base=boost::filesystem::current_path(), boost::system::error_code *ec=0)
 Get a canonical path. More...
 
boost::filesystem::path make_relative (boost::filesystem::path from, boost::filesystem::path to)
 Make a relative path. More...
 
void setLogLevel (logging::trivial::severity_level severity)
 Set global logging level. More...
 
logging::trivial::severity_level getLogLevel ()
 Get global logging level. More...
 
Logger createLogger (const std::string &className)
 Create a message logger for a class. More...
 
const fs::path & module_runtime_path (const std::string &dtype)
 Get the runtime installation prefix path for a module. More...
 
void register_module_paths ()
 Register OME-Common module paths. More...
 
std::string ltrim (const std::string &str)
 Trim leading whitespace from a string. More...
 
std::string rtrim (const std::string &str)
 Trim trailing whitespace from a string. More...
 
std::string trim (const std::string &str)
 Trim leading and trailing whitespace from a string. More...
 

Detailed Description

OME compatibility functions and classes.

Function Documentation

◆ absolute()

boost::filesystem::path ome::common::absolute ( const boost::filesystem::path &  p,
const boost::filesystem::path &  base = boost::filesystem::current_path() 
)
inline

Get an absolute path.

Deprecated:
Use boost::filesystem::absolute.
Parameters
pthe path to make absolute.
basethe base directory, defaulting to the current path.
Returns
the absolute path.

References canonical().

Referenced by canonical(), and make_relative().

+ Here is the caller graph for this function:

◆ base64_decode() [1/2]

template<typename InsertIterator >
void ome::common::base64_decode ( std::string  base64,
InsertIterator  dest 
)

Decode a Base64-encoded string.

Newlines and other whitespace breaking up the input are permitted.

Parameters
base64the Base64-encoded string.
destthe insert iterator for the destination
Exceptions
std::runtime_erroron invalid input.

Referenced by base64_decode().

+ Here is the caller graph for this function:

◆ base64_decode() [2/2]

template<typename Container >
Container ome::common::base64_decode ( const std::string &  base64)

Decode a Base64-encoded string into a container.

Newlines and other whitespace breaking up the input are permitted.

Parameters
base64the Base64-encoded string.
Returns
a container filled with the decoded bytes.
Exceptions
std::runtime_erroron invalid input.

References base64_decode().

◆ base64_encode()

template<typename Iterator >
std::string ome::common::base64_encode ( Iterator  begin,
Iterator  end,
uint8_t  linebreak = 76 
)

Base64-encode a range of bytes.

The iterators may be of any uint8_t iterator type, for example a range in a container, raw pointers or any other compatible type.

Parameters
beginthe start of the byte range.
endthe end of the byte range.
linebreakthe position at which to break a line; zero to disable line breaks.
Returns
a Base64-encoded string.

◆ canonical()

boost::filesystem::path ome::common::canonical ( const boost::filesystem::path &  p,
const boost::filesystem::path &  base = boost::filesystem::current_path(),
boost::system::error_code *  ec = 0 
)
inline

Get a canonical path.

Deprecated:
Use boost::filesystem::canonical.
Parameters
pthe path to make canonical.
basethe base directory, defaulting to the current path.
ecpointer to storage for an error code (optional).
Returns
the canonical path.

References absolute().

Referenced by absolute(), module_runtime_path(), ome::common::xml::EntityResolver::registerCatalog(), and ome::common::xml::EntityResolver::registerEntity().

+ Here is the caller graph for this function:

◆ createLogger()

Logger ome::common::createLogger ( const std::string &  className)
inline

Create a message logger for a class.

Parameters
classNamethe class name owning the logger.
Returns
a message logger.

References getLogLevel(), and setLogLevel().

◆ getLogLevel()

logging::trivial::severity_level ome::common::getLogLevel ( )

Get global logging level.

Returns
the log severity.

Referenced by createLogger().

+ Here is the caller graph for this function:

◆ ltrim()

std::string ome::common::ltrim ( const std::string &  str)
inline

Trim leading whitespace from a string.

Space, newline, carriage return and horizontal and vertical tabs are removed from the left-hand side of the string.

Parameters
strthe string to trim.
Returns
the left-trimmed string.

◆ make_relative()

boost::filesystem::path ome::common::make_relative ( boost::filesystem::path  from,
boost::filesystem::path  to 
)
inline

Make a relative path.

Parameters
fromthe start (reference) path.
tothe end path (to make relative to the start path).
Returns
the relative path.

References absolute().

◆ module_runtime_path()

const boost::filesystem::path & ome::common::module_runtime_path ( const std::string &  dtype)

Get the runtime installation prefix path for a module.

This is intended primarily for internal use, to allow discovery of the location of datafiles, loadable modules, etc. However, it may be freely used by additional components, both OME and third-party, to register paths.

Parameters
dtypethe directory type to query.
Returns
the installation prefix path.
Exceptions
astd::runtime_error if the path could not be determined.

References canonical(), and ome::common::Module::realpath.

◆ operator!=() [1/3]

bool ome::common::operator!= ( const boolean lhs,
bool  rhs 
)
inline

Compare boolean with bool for inequality.

Parameters
lhsthe first value to compare.
rhsthe second value to compare.
Returns
true if not equal, false if equal.

◆ operator!=() [2/3]

bool ome::common::operator!= ( bool  lhs,
const boolean rhs 
)
inline

Compare bool with boolean for inequality.

Parameters
lhsthe first value to compare.
rhsthe second value to compare.
Returns
true if not equal, false if equal.

◆ operator!=() [3/3]

bool ome::common::operator!= ( const boolean lhs,
const boolean rhs 
)
inline

Compare bool with boolean for inequality.

Parameters
lhsthe first value to compare.
rhsthe second value to compare.
Returns
true if not equal, false if equal.

◆ operator<<()

template<class charT , class traits >
std::basic_ostream<charT,traits>& ome::common::operator<< ( std::basic_ostream< charT, traits > &  os,
const boolean rhs 
)
inline

Output boolean to output stream.

Parameters
osthe output stream.
rhsthe boolean to output.
Returns
the output stream.

◆ operator==() [1/3]

bool ome::common::operator== ( const boolean lhs,
bool  rhs 
)
inline

Compare boolean with bool for equality.

Parameters
lhsthe first value to compare.
rhsthe second value to compare.
Returns
true if equal, false if not equal.

◆ operator==() [2/3]

bool ome::common::operator== ( bool  lhs,
const boolean rhs 
)
inline

Compare bool with boolean for equality.

Parameters
lhsthe first value to compare.
rhsthe second value to compare.
Returns
true if equal, false if not equal.

◆ operator==() [3/3]

bool ome::common::operator== ( const boolean lhs,
const boolean rhs 
)
inline

Compare boolean with boolean for equality.

Parameters
lhsthe first value to compare.
rhsthe second value to compare.
Returns
true if equal, false if not equal.

◆ operator>>()

template<class charT , class traits >
std::basic_istream<charT,traits>& ome::common::operator>> ( std::basic_istream< charT, traits > &  is,
boolean rhs 
)
inline

Set boolean from input stream.

Parameters
isthe input stream.
rhsthe boolean to set.
Returns
the input stream.

◆ register_module_paths()

void ome::common::register_module_paths ( )

Register OME-Common module paths.

This function forces path registration.

Note
This is a hack to allow static linking to work on Windows; without this, the module object is omitted and the paths aren't automatically registered. This will no longer be required once it is built as a DLL. Its only purpose is to force object inclusion when static linking, and ensure that the registration happens independently of object static construction order to allow use prior to main() entry. You should not use this.

◆ rtrim()

std::string ome::common::rtrim ( const std::string &  str)
inline

Trim trailing whitespace from a string.

Space, newline, carriage return and horizontal and vertical tabs are removed from the right-hand side of the string.

Parameters
strthe string to trim.
Returns
the right-trimmed string.

◆ setLogLevel()

void ome::common::setLogLevel ( logging::trivial::severity_level  severity)

Set global logging level.

Log messages will be filtered such that messages with a priority greater or equal to the specified severity will be logged; messages with a lower priority will be discarded.

If using Boost.Log for logging, this is used to set the logging core filter.

Parameters
severitythe log severity.

Referenced by createLogger().

+ Here is the caller graph for this function:

◆ trim()

std::string ome::common::trim ( const std::string &  str)
inline

Trim leading and trailing whitespace from a string.

Space, newline, carriage return and horizontal and vertical tabs are removed from the left- and right-hand sides of the string.

Parameters
strthe string to trim.
Returns
the trimmed string.