|
|
Some generic utility functions used by different policy components.
PolicyUtilsErr (class) | PolicyUtilsErr |
template <class T>
void
delete_vector (vector<T*>* v)
| delete_vector |
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.
Parameters:
v | vector to delete |
template <class T>
void
clear_container (T& l)
| clear_container |
Deletes objects in container. Checks if objects are null and skips them if so.
The container is cleared at the end.
Parameters:
l | container to be deleted and cleared. |
template <class A, class T>
void
clear_map (map<A,T*>& m)
| clear_map |
Delets objects of a map and clears the map at the end. Checks for null objects.
Parameters:
m | map to be deleted and cleared. |
void str_to_list (const string& in, list<string>& out)
| str_to_list |
Converts a string in the form "1,2,...,n" to a list of strings.
Parameters:
in | input string. |
out | output list. |
void str_to_set (const string& in, set<string>& out)
| str_to_set |
Converts a string in the form "1,2,...,n" to a set of strings.
Parameters:
in | input string. |
out | output set. |
template <class T>
string
to_str (T x)
| to_str |
Converts an object to a string via an ostringstream.
Parameters:
x | object to convert to string. |
Returns: string representation of object.
void read_file (const string& fname, string& out)
| read_file |
Reads a file into a string. An exception is thrown on error.
Parameters:
fname | filename to read. |
out | output string which will be filled with file content. |
unsigned count_nl (const char* x)
| count_nl |
Count the occurences of newlines in the c-style string.
Parameters:
x | the 0 terminated c-style string to count new lines in. |
Returns: the number of new lines in the string.