|
xorp
|
Some generic utility functions used by different policy components. More...
Classes | |
| class | PolicyUtilsErr |
| Generic exception for errors. More... | |
Functions | |
| void | str_to_list (const string &in, list< string > &out) |
| Converts a string in the form "1,2,...,n" to a list of strings. | |
| void | str_to_set (const string &in, set< string > &out) |
| Converts a string in the form "1,2,...,n" to a set of strings. | |
| void | read_file (const string &fname, string &out) |
| Reads a file into a string. | |
| unsigned | count_nl (const char *x) |
| Count the occurences of newlines in the c-style string. | |
| bool | regex (const string &str, const string ®) |
| Match a regex. | |
| template<class T > | |
| void | delete_vector (vector< T * > *v) |
| Deletes a vector by deleting objects and deleting the vector itself. | |
| template<class T > | |
| void | clear_container (T &l) |
| Deletes objects in container. | |
| template<class A , class T > | |
| void | clear_map (map< A, T * > &m) |
| Delets objects of a map and clears the map at the end. | |
| template<class T > | |
| void | clear_map_container (T &m) |
| Delets objects of a map-like container and clears the map at the end. | |
| template<class T > | |
| string | to_str (T x) |
| Converts an object to a string via an ostringstream. | |
Some generic utility functions used by different policy components.
| void policy_utils::clear_container | ( | T & | l | ) |
Deletes objects in container.
Checks if objects are null and skips them if so.
The container is cleared at the end.
| l | container to be deleted and cleared. |
| void policy_utils::clear_map | ( | map< A, T * > & | m | ) |
| void policy_utils::clear_map_container | ( | T & | m | ) |
| unsigned policy_utils::count_nl | ( | const char * | x | ) |
| void policy_utils::delete_vector | ( | vector< T * > * | v | ) |
Deletes a vector by deleting objects and deleting the vector itself.
It checks if objects are null and skips them if so. Also checks if vector itself is null.
| v | vector to delete |
| void policy_utils::read_file | ( | const string & | fname, |
| string & | out | ||
| ) |
Reads a file into a string.
An exception is thrown on error.
| fname | filename to read. |
| out | output string which will be filled with file content. |
| bool policy_utils::regex | ( | const string & | str, |
| const string & | reg | ||
| ) |
Match a regex.
| str | input string to check. |
| reg | regular expression used for matching. |
| void policy_utils::str_to_list | ( | const string & | in, |
| list< string > & | out | ||
| ) |
Converts a string in the form "1,2,...,n" to a list of strings.
| in | input string. |
| out | output list. |
| void policy_utils::str_to_set | ( | const string & | in, |
| set< string > & | out | ||
| ) |
Converts a string in the form "1,2,...,n" to a set of strings.
| in | input string. |
| out | output set. |
| string policy_utils::to_str | ( | T | x | ) |
Converts an object to a string via an ostringstream.
| x | object to convert to string. |