namespace ov::util¶
Overview¶
namespace util {
// namespaces
namespace ov::util::dim;
// typedefs
typedef std::string FilePath;
// enums
enum LOG_TYPE;
// structs
template <>
struct AsTypePtr;
template <>
struct AsTypePtr<std::shared_ptr<In>>;
template <>
struct Cast;
template <>
struct FileTraits<char>;
template <>
struct FileTraits;
template <>
struct FileTraits<wchar_t>;
template <>
struct InTypeRange;
// classes
class ConstString;
class LogHelper;
class Logger;
// global functions
template <>
std::stringconst T&const std::string& join(, );
template <>
std::stringconst T& vector_to_string();
std::stringconst std::string& to_lower();
std::stringconst std::string& to_upper();
size_tconst std::vector<size_t>& hash_combine();
std::stringconst std::string& ltrim();
std::stringconst std::string& rtrim();
std::stringconst std::string& trim();
boolconst std::string&const char \* ends_with(, );
template <>
boolconst std::basic_string<T>&const std::basic_string<T>& ends_with(
,
);
std::vector<std::string>const std::string&charbool split(, , );
template <>
Tconst T&const T& ceil_div(, );
template <, , >
boolconst std::vector<T, A>&const V& contains(, );
constexpr const char \*ConstStringsize_tchar find_last(, , );
constexpr const char \*ConstStringchar find_last(, );
constexpr const char \*ConstString get_file_name();
std::stringconst char \* getenv_string();
int32_tconst char \*int32_t getenv_int(, );
boolconst char \*bool getenv_bool(, );
std::stringconst std::string& sanitize_path();
std::stringconst std::string& get_file_name();
std::stringconst std::string& get_absolute_file_path();
boolconst std::string& is_absolute_file_path();
voidconst std::string& create_directory_recursive();
boolconst std::string& directory_exists();
int64_tconst char \* file_size();
boolconst char \* file_exists();
int64_tconst std::string& file_size();
boolconst std::string& file_exists();
std::stringconst std::string& get_file_ext();
std::stringconst std::string& get_directory();
std::stringconst std::vector<std::string>& path_join();
voidconst std::string&const std::function<void(const std::string&file, bool is_dir)>&boolbool iterate_files(
,
,
,
);
voidstd::string& convert_path_win_style();
std::string get_ov_lib_path();
std::stringconst FilePath& from_file_path();
FilePathconst std::string& to_file_path();
std::string get_ov_library_path();
template <, >
std::basic_string<C>const std::basic_string<C>&const std::basic_string<C>& make_plugin_library_name(
,
);
FilePathconst std::string& get_plugin_path();
FilePathconst std::string& get_compiled_plugin_path();
FilePathconst std::string&const std::string&bool get_plugin_path(, , );
std::vector<uint8_t>const std::string& load_binary();
voidconst std::string&std::vector<uint8_t> save_binary(, );
voidconst std::string&const char \*size_t save_binary(, , );
const char \*const char \*const trim_file_name();
voidconst std::string& default_logger_handler_func();
std::shared_ptr<void>const char \* load_shared_object();
void \*const std::shared_ptr<void>&const char \* get_symbol(, );
ov::Tensorconst std::shared_ptr<ov::ITensor>&const std::shared_ptr<void>& make_tensor(
,
);
template <, >
constexpr boolconst T& is_max();
template <, >
constexpr boolconst T& is_min();
} // namespace util
Detailed Documentation¶
Global Functions¶
std::stringconst std::string& ltrim()
trim from start (in place)
Parameters:
s |
|
std::stringconst std::string& rtrim()
trim from end (in place)
Parameters:
s |
|
boolconst std::string&const char \* ends_with(, )
check string end with given substring
Parameters:
src |
|
with |
|
Returns:
true if string end with given substring
template <>
boolconst std::basic_string<T>&const std::basic_string<T>& ends_with(
,
)
check string/wstring end with given substring
Parameters:
src |
|
with |
|
Returns:
true if string end with given substring
std::stringconst char \* getenv_string()
Get the names environment variable as a string.
Parameters:
env_var |
The string name of the environment variable to get. |
Returns:
Returns string by value or an empty string if the environment variable is not set.
int32_tconst char \*int32_t getenv_int(, )
Get the names environment variable as an integer. If the value is not a valid integer then an exception is thrown.
Parameters:
env_var |
The string name of the environment variable to get. |
default_value |
The value to return if the environment variable is not set. |
Returns:
Returns value or default_value if the environment variable is not set.
boolconst char \*bool getenv_bool(, )
Get the names environment variable as a boolean. If the value is not a valid boolean then an exception is thrown. Valid booleans are one of 1, 0, on, off, true, false All values are case insensitive. If the environment variable is not set the default_value is returned.
Parameters:
env_var |
The string name of the environment variable to get. |
default_value |
The value to return if the environment variable is not set. |
Returns:
Returns the boolean value of the environment variable.
std::stringconst std::string& sanitize_path()
Remove path components which would allow traversing up a directory tree.
Parameters:
path |
A path to file |
Returns:
A sanitiazed path
std::stringconst std::string& get_file_name()
Returns the name with extension for a given path.
Parameters:
path |
The path to the output file |
std::stringconst std::string& get_absolute_file_path()
Interface function to get absolute path of file.
Parameters:
path |
|
runtime_error |
if absolute path can’t be resolved |
Returns:
Absolute path of file
boolconst std::string& is_absolute_file_path()
Interface function to check path to file is absolute or not.
Parameters:
path |
|
runtime_error |
if any error occurred |
Returns:
True if path is absolute and False otherwise
voidconst std::string& create_directory_recursive()
Interface function to create directorty recursively by given path.
Parameters:
path |
|
runtime_error |
if any error occurred |
boolconst std::string& directory_exists()
Interface function to check if directory exists for given path.
Parameters:
path |
|
Returns:
true if directory exists, false otherwise
int64_tconst char \* file_size()
Returns file size for file.
Parameters:
path |
The file name |
Returns:
file size
boolconst char \* file_exists()
Returns file size for file.
Parameters:
path |
The file name |
Returns:
file size
int64_tconst std::string& file_size()
Returns file size for file.
Parameters:
path |
The file name |
Returns:
file size
boolconst std::string& file_exists()
Returns true if file exists.
Parameters:
path |
The file name |
Returns:
true if file exists
FilePathconst std::string& get_plugin_path()
Format plugin path (canonicalize, complete to absolute or complete to file name) for further dynamic loading by OS.
Parameters:
plugin |
|
Returns:
absolute path or file name with extension (to be found in ENV)
FilePathconst std::string& get_compiled_plugin_path()
Find the plugins which are located together with OV library.
Parameters:
plugin |
|
Returns:
absolute path or file name with extension (to be found in ENV)
FilePathconst std::string&const std::string&bool get_plugin_path(, , )
Format plugin path (canonicalize, complete to absolute or complete to file name) for further dynamic loading by OS.
Parameters:
plugin |
|
xml_path |
|
as_abs_only |
|
Returns:
absolute path or file name with extension (to be found in ENV)
std::vector<uint8_t>const std::string& load_binary()
load binary data from file
Parameters:
path |
|
Returns:
binary vector
voidconst std::string&std::vector<uint8_t> save_binary(, )
save binary data to file
Parameters:
path |
|
const char \*const char \*const trim_file_name()
Trim OpenVINO project file name path if OpenVINO project directory found.
Function use OV_NATIVE_PARENT_PROJECT_ROOT_DIR
definition with project directory name defines ‘openvino_dir_name’. The input file name is scanned for OV_NATIVE_PARENT_PROJECT_ROOT_DIR, if found returns pointer to trimmed name otherwise returns input pointer.
e.g: OV_NATIVE_PARENT_PROJECT_ROOT_DIR = openvino
/home/user/openvino/src/example.cpp -> src/example.cpp
../../../../openvino/src/example.cpp -> src/example.cpp
Parameters:
fname |
Pointer to OpenVINO file name path. |
Returns:
Pointer to trimmed file name path.
std::shared_ptr<void>const char \* load_shared_object()
Loads a library with the name specified.
Parameters:
path |
Full or relative path to the plugin library |
Returns:
Reference to shared object
void \*const std::shared_ptr<void>&const char \* get_symbol(, )
Searches for a function symbol in the loaded module.
Parameters:
shared_object |
shared object reference |
symbolName |
Name of the function to find |
if the function is not found |
Returns:
A pointer to the function if found
template <, >
constexpr boolconst T& is_max()
Check if value of type T has got maximum value of type U.
Parameters:
T |
Input value type |
U |
Type to get its minimum for comparision. Default same as T. |
value |
Input value. |
Returns:
True if input value has got maximum value of type U otherwise false.
template <, >
constexpr boolconst T& is_min()
Check if value of type T has got minimum value of type U.
Parameters:
T |
Input value type. |
U |
Type to get its minimum for comparision. Default same as T. |
value |
Input value. |
Returns:
True if input value has got minimum value of type U otherwise false.