Utilities¶
TIDAS has several small helper functions / classes. They are documented here for lack of a better place.
Dictionaries¶
The TIDAS dictionary class exists mainly to provide a strongly typed implementation that can be read / written by a backend implementation. In the Python API, all classes / functions just use normal python dictionaries and these are converted under the hood to a C++ TIDAS dictionary.
-
class
tidas::
dict
¶ This dictionary class stores values of multiple fixed types.
The type of each value is recorded and the value is stored as a string. The stored values are converted back on retrieval.
Public Functions
-
dict
()¶ Default constructor.
-
~dict
()¶ Destructor.
-
dict &
operator=
(dict const &other)¶ Assignment operator.
-
dict
(backend_path const &loc)¶ (Internal) Load the dictionary from an existing location.
All meta data operations will apply to this location.
-
dict
(dict const &other, std::string const &filter, backend_path const &loc)¶ (Internal) Copy from an existing dictionary.
Apply an optional filter to elements and relocate to a new location. If a filter is given, a new location must be specified.
-
void
relocate
(backend_path const &loc)¶ (Internal) Change the location of the dictionary.
-
void
sync
()¶ (Internal) Reload metadata from the current location, overwriting the current state in memory.
-
void
flush
() const¶ (Internal) Write metadata to the current location, overwriting the information at that location.
-
void
copy
(dict const &other, std::string const &filter, backend_path const &loc)¶ (Internal) Copy with optional selection and relocation.
-
backend_path
location
() const¶ (Internal) The current location.
- template <class T>
-
void
put
(std::string const &key, T const &val)¶ Insert a value into the dictionary with the specified key.
- template <class T>
-
T
get
(std::string const &key) const¶ Return a value from the dictionary with the specified key.
-
void
clear
()¶ Clear all elements of the dictionary.
-
std::vector<std::string>
keys
() const¶ Return a list of keys in the dictionary.
-
std::map<std::string, std::string> const &
data
() const¶ Return a const reference to the underlying data map.
-
std::map<std::string, data_type> const &
types
() const¶ Return a const reference to the underlying data type map.
-
Filesystem Utilities¶
In Python, there are already extensive tools for easy manipulation of the filesystem. These C++ tools are used internally but might also be useful for application developers, which is why they are documented here.
-
int64_t
tidas::
fs_stat
(char const *path)¶ Return the size of the specified file.
-
void
tidas::
fs_rm
(char const *path)¶ Remove the specified file.
-
void
tidas::
fs_mkdir
(char const *path)¶ Make the specified directory.