ppap4lmp  0.7.2
utils Namespace Reference

Namespace for utility functions. More...

Functions

Str join (const Vec< Str > &strs, const Str &jointer)
 Mimicking Python's join. More...
 
Map< Json, int > map_to_index (const Json &data, const Str &key)
 Create a Map object from values of selected property in an array Json object to corresponding index in the Json object. More...
 
void _message (const Str &msg)
 Print to standard output. More...
 
void log (const Str &msg)
 Logging a message. More...
 
void warning (const Str &msg)
 Waning with a message. More...
 
void log_switch (bool input)
 Switch on/off logging. More...
 
template<typename T >
void pyargs_to_vec (const py::args &args, Vec< T > &vec)
 Convert a py::args (a variable number arguments) object to a Vec object. More...
 
void runtime_error (const Str &msg)
 Raise (for Python) and throw (for C++) a runtime error. More...
 
Vec< Strsplit (const Str &str, char delim=' ')
 Mimicking Python's split. More...
 

Detailed Description

Namespace for utility functions.

Function Documentation

◆ _message()

void utils::_message ( const Str msg)

Print to standard output.

Parameters
msgA string to be printed.
Returns
None.

Definition at line 18 of file message.cpp.

Here is the caller graph for this function:

◆ join()

Str utils::join ( const Vec< Str > &  strs,
const Str jointer 
)

Mimicking Python's join.

Parameters
strsVector (list) of strings to be joined.
jointerA string used for jointing elements of the strs.
Returns
A string.

Definition at line 14 of file join.cpp.

Here is the caller graph for this function:

◆ log()

void utils::log ( const Str msg)

Logging a message.

Parameters
msgA string to be printed.
Returns
None.

Definition at line 29 of file message.cpp.

Here is the caller graph for this function:

◆ log_switch()

void utils::log_switch ( bool  input)

Switch on/off logging.

Parameters
inputA boolean, whether take log or not.
Returns
None.

Note that logging is disabled by default.

Definition at line 48 of file message.cpp.

Here is the caller graph for this function:

◆ map_to_index()

Map< Json, int > utils::map_to_index ( const Json data,
const Str key 
)

Create a Map object from values of selected property in an array Json object to corresponding index in the Json object.

Parameters
dataAn array Json object.
keyA string key specifying a property used as domain of the mapping.
Returns
A Map object from elements of the data to corresponding index in the data.

Note that the mapping must be bijection.

Definition at line 15 of file map_to_index.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pyargs_to_vec()

template<typename T >
void utils::pyargs_to_vec ( const py::args &  args,
Vec< T > &  vec 
)

Convert a py::args (a variable number arguments) object to a Vec object.

Parameters
argsPython's variable number arguments.
vecMutable reference to a Vec object where elements of the args are appended to.
Returns
None.

Definition at line 15 of file pyargs_to_vec.cpp.

Here is the caller graph for this function:

◆ runtime_error()

void utils::runtime_error ( const Str msg)

Raise (for Python) and throw (for C++) a runtime error.

Parameters
msgA string message for the runtime error.
Returns
None.

Definition at line 16 of file runtime_error.cpp.

Here is the caller graph for this function:

◆ split()

Vec< Str > utils::split ( const Str str,
char  delim = ' ' 
)

Mimicking Python's split.

Parameters
strA string to be splitted.
delimA character by which the str is splitted. Default delimiter is a whitespace.
Returns
A Vec object containing each part of splitted strings.

Definition at line 16 of file split.cpp.

Here is the caller graph for this function:

◆ warning()

void utils::warning ( const Str msg)

Waning with a message.

Parameters
msgA string to be printed.
Returns
None.

Definition at line 40 of file message.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: