μHAL (v2.7.9)
Part of the IPbus software repository
Functions
uhal::utilities Namespace Reference

Functions

unsigned int TrailingRightBits (uint32_t aValue)
 Helper function to calculate the number of zero-bits at the righthand end of a 32-bit number. More...
 
void ParseSemicolonDelimitedUriList (const std::string &aSemicolonDelimitedUriList, std::vector< std::pair< std::string, std::string > > &aUriList)
 Parse a semicolon delimited list of URIs into a vector of protocol/address pairs. More...
 
void ShellExpandFilenameExpr (const std::string &aFilenameExpr, const boost::filesystem::path &aParentPath, std::vector< boost::filesystem::path > &aFiles)
 Perform shell expansion of a linux shell expression ( e.g. More...
 
template<bool DebugInfo>
bool HttpGet (const std::string &aURL, HttpResponseType &aResponse)
 Retrieve a file by HTTP. More...
 
template<typename R , typename F , typename L >
void OpenFileLocal (const std::string &aFilenameExpr, const boost::filesystem::path &aParentPath, boost::_bi::bind_t< R, F, L > aBinder)
 Given a linux shell expression, open all files which match it and call the callback function on each of them. More...
 
template<typename R , typename F , typename L >
void OpenFileHttp (const std::string &aURL, boost::_bi::bind_t< R, F, L > aBinder)
 Given a URL, retrieve the file and call the callback function on each of them. More...
 
template<typename R , typename F , typename L >
void OpenFile (const std::string &aProtocol, const std::string &aFilenameExpr, const boost::filesystem::path &aParentPath, boost::_bi::bind_t< R, F, L > aBinder)
 Given a protocol and either a URL or a linux shell expression, open the file and call the callback function on each of them. More...
 
void PugiXMLParseResultPrettifier (const pugi::xml_parse_result &aLoadResult, const boost::filesystem::path &aPath, const std::vector< uint8_t > &aFile)
 Helper function to make debugging failures when parsing XML files easier. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, std::string &aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, const char *aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, int32_t &aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, uint32_t &aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, double &aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, float &aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template<bool DebugInfo>
bool GetXMLattribute (const pugi::xml_node &aNode, const std::string &aAttrName, bool &aTarget)
 Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type. More...
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, std::string &aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, std::string &aTarget)
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, const char *aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, const char *aTarget)
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, int32_t &aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, int32_t &aTarget)
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, uint32_t &aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, uint32_t &aTarget)
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, double &aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, double &aTarget)
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, float &aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, float &aTarget)
 
template bool GetXMLattribute< true > (const pugi::xml_node &aNode, const std::string &aAttrName, bool &aTarget)
 
template bool GetXMLattribute< false > (const pugi::xml_node &aNode, const std::string &aAttrName, bool &aTarget)
 

Function Documentation

◆ GetXMLattribute() [1/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
bool &  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 367 of file xml.cpp.

References pugi::xml_attribute::as_bool(), pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::log(), and uhal::Quote().

◆ GetXMLattribute() [2/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
const char *  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 141 of file xml.cpp.

References pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::log(), uhal::Quote(), and pugi::xml_attribute::value().

◆ GetXMLattribute() [3/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
double &  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 317 of file xml.cpp.

References pugi::xml_attribute::as_double(), pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::log(), and uhal::Quote().

◆ GetXMLattribute() [4/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
float &  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 342 of file xml.cpp.

References pugi::xml_attribute::as_float(), pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::log(), and uhal::Quote().

◆ GetXMLattribute() [5/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
int32_t &  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 166 of file xml.cpp.

References pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::hex, uhal::log(), uhal::Quote(), and pugi::xml_attribute::value().

◆ GetXMLattribute() [6/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
std::string &  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 116 of file xml.cpp.

References pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::log(), uhal::Quote(), and pugi::xml_attribute::value().

◆ GetXMLattribute() [7/7]

template<bool DebugInfo>
bool uhal::utilities::GetXMLattribute ( const pugi::xml_node aNode,
const std::string &  aAttrName,
uint32_t &  aTarget 
)

Helper function to retrieve a named attribute from a PugiXML node and cast it to the correct type.

Parameters
aNodea node from which the attribute is to be extracted
aAttrNamethe name of the attribute to be extracted
aTargeta variable into which the attribute's value id to be written
Returns
success/failure status

Definition at line 242 of file xml.cpp.

References pugi::xml_node::attribute(), pugi::xml_attribute::empty(), uhal::Error, uhal::hex, uhal::log(), uhal::Quote(), and pugi::xml_attribute::value().

◆ GetXMLattribute< false >() [1/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
bool &  aTarget 
)

◆ GetXMLattribute< false >() [2/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
const char *  aTarget 
)

◆ GetXMLattribute< false >() [3/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
double &  aTarget 
)

◆ GetXMLattribute< false >() [4/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
float &  aTarget 
)

◆ GetXMLattribute< false >() [5/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
int32_t &  aTarget 
)

◆ GetXMLattribute< false >() [6/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
std::string &  aTarget 
)

◆ GetXMLattribute< false >() [7/7]

template bool uhal::utilities::GetXMLattribute< false > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
uint32_t &  aTarget 
)

◆ GetXMLattribute< true >() [1/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
bool &  aTarget 
)

◆ GetXMLattribute< true >() [2/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
const char *  aTarget 
)

◆ GetXMLattribute< true >() [3/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
double &  aTarget 
)

◆ GetXMLattribute< true >() [4/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
float &  aTarget 
)

◆ GetXMLattribute< true >() [5/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
int32_t &  aTarget 
)

◆ GetXMLattribute< true >() [6/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
std::string &  aTarget 
)

◆ GetXMLattribute< true >() [7/7]

template bool uhal::utilities::GetXMLattribute< true > ( const pugi::xml_node aNode,
const std::string &  aAttrName,
uint32_t &  aTarget 
)

◆ HttpGet()

template<bool DebugInfo>
bool uhal::utilities::HttpGet ( const std::string &  aURL,
HttpResponseType aResponse 
)

Retrieve a file by HTTP.

Parameters
aURLa URL to retrieve
aResponsea structure into which the returned HTTP packet is parsed
Returns
success/failure status

Definition at line 133 of file files.hpp.

References uhal::Error, uhal::Info, uhal::log(), uhal::HttpResponseType::method, uhal::Quote(), uhal::HttpResponseType::status, ThisLocation, and uhal::tests::write().

◆ OpenFile()

template<typename R , typename F , typename L >
void uhal::utilities::OpenFile ( const std::string &  aProtocol,
const std::string &  aFilenameExpr,
const boost::filesystem::path &  aParentPath,
boost::_bi::bind_t< R, F, L >  aBinder 
)

Given a protocol and either a URL or a linux shell expression, open the file and call the callback function on each of them.

Parameters
aProtocolthe protocol to be used to retrieve the file
aFilenameExpra linux shell expression to be expanded or a URL to be retrieved
aParentPatha path which will be prepended to relative file names for local files. No meaning for http files.
aBindera callback function to be called on the files
Returns
success/failure status

Definition at line 353 of file files.hpp.

References uhal::log(), OpenFileHttp(), OpenFileLocal(), and uhal::Quote().

Referenced by uhal::ConnectionManager::ConnectionManager(), and uhal::NodeTreeBuilder::getNodeTree().

◆ OpenFileHttp()

template<typename R , typename F , typename L >
void uhal::utilities::OpenFileHttp ( const std::string &  aURL,
boost::_bi::bind_t< R, F, L >  aBinder 
)

Given a URL, retrieve the file and call the callback function on each of them.

Parameters
aURLa URL to retrieve
aBindera callback function to be called on the retrieved URL
Returns
success/failure status

Definition at line 328 of file files.hpp.

References uhal::HttpResponseType::content, uhal::log(), and uhal::Quote().

Referenced by OpenFile().

◆ OpenFileLocal()

template<typename R , typename F , typename L >
void uhal::utilities::OpenFileLocal ( const std::string &  aFilenameExpr,
const boost::filesystem::path &  aParentPath,
boost::_bi::bind_t< R, F, L >  aBinder 
)

Given a linux shell expression, open all files which match it and call the callback function on each of them.

Parameters
aFilenameExpra linux shell expression to be expanded
aParentPatha path which will be prepended to relative file names
aBindera callback function to be called on each file matching the linux shell expression

Definition at line 292 of file files.hpp.

References uhal::log(), uhal::Quote(), and ShellExpandFilenameExpr().

Referenced by OpenFile().

◆ ParseSemicolonDelimitedUriList()

void uhal::utilities::ParseSemicolonDelimitedUriList ( const std::string &  aSemicolonDelimitedUriList,
std::vector< std::pair< std::string, std::string > > &  aUriList 
)

Parse a semicolon delimited list of URIs into a vector of protocol/address pairs.

Parameters
aSemicolonDelimitedUriLista string containing a semicolon delimited list of URIs
aUriLista vector to which the extracted protocol/address pairs are appended

Definition at line 46 of file files.cpp.

References uhal::Debug, uhal::log(), and uhal::Quote().

Referenced by uhal::ConnectionManager::ConnectionManager(), and uhal::NodeTreeBuilder::getNodeTree().

◆ PugiXMLParseResultPrettifier()

void uhal::utilities::PugiXMLParseResultPrettifier ( const pugi::xml_parse_result aLoadResult,
const boost::filesystem::path &  aPath,
const std::vector< uint8_t > &  aFile 
)

Helper function to make debugging failures when parsing XML files easier.

Parameters
aLoadResultthe result of the parsing
aPaththe full filename of file whose parsing failed
aFilea byte vector containing the contents of the file (stored like this because the file could be either local or retrieved by HTTP)

Definition at line 57 of file xml.cpp.

References pugi::xml_parse_result::description(), uhal::Error, uhal::Integer(), uhal::log(), pugi::xml_parse_result::offset, and uhal::Quote().

Referenced by uhal::NodeTreeBuilder::CallBack(), and uhal::ConnectionManager::CallBack().

◆ ShellExpandFilenameExpr()

void uhal::utilities::ShellExpandFilenameExpr ( const std::string &  aFilenameExpr,
const boost::filesystem::path &  aParentPath,
std::vector< boost::filesystem::path > &  aFiles 
)

Perform shell expansion of a linux shell expression ( e.g.

"~/c*.xml" -> "/usr/home/awr/connections.xml" ) and convert into boost::filesystem::paths

Parameters
aFilenameExpra c-style string containing a linux shell expression to be expanded
aParentPatha path which will be prepended to relative file names
aFilesa pointer to a vector of boost::filesystem::paths onto which the returned file names are appended

Definition at line 69 of file files.cpp.

References uhal::Debug, uhal::log(), and uhal::Quote().

Referenced by OpenFileLocal().

◆ TrailingRightBits()

unsigned int uhal::utilities::TrailingRightBits ( uint32_t  aValue)

Helper function to calculate the number of zero-bits at the righthand end of a 32-bit number.

Parameters
aValuea 32-bit number whose trailing zero-bits are to be counted
Returns
the number of trailing zero-bits

Definition at line 44 of file bits.cpp.

Referenced by uhal::ValWord< T >::value(), and uhal::ClientInterface::write().