|
static std::vector< std::string > | get_args (const std::string &raw_args) |
| Parse arguments. More...
|
|
static std::vector< std::string::size_type > | calc_mindiff (std::vector< std::string > &v) |
| Calculate the minimum distinguishable length for each string in v . More...
|
|
static std::string | load_file (const std::string &path) |
| Load a file into a string with path path . More...
|
|
static std::vector< std::string > | load_files (const std::string &path_root) |
| Load a files from directory path_root . More...
|
|
static std::vector< std::string > | load_file_lines (const std::string &path) |
| Load lines of a file into a vector of strings from path path . More...
|
|
static std::string | load_pcm (const std::string &mp3_data) |
| Converts a MP3 file into PCM data. More...
|
|
◆ calc_mindiff()
std::vector< std::string::size_type > ffss::SSUtility::calc_mindiff |
( |
std::vector< std::string > & |
v | ) |
|
|
static |
Calculate the minimum distinguishable length for each string in v
.
- Parameters
-
The minimum distinguishable length for a string s in some non-empty set of strings is the length that s can be abbreviated down to without being ambiguous. For example, for strings "fennec" and "fortuneteller", the length is 2 for each, since we need at least two characters to distinguish both strings.
Documented preconditions are as follows:
- All strings in
v
must be unique.
- There cannot be an empty string in
v
.
- Returns
- A vector of minimum distinguishable lengths for each corresponding string (same index).
- Exceptions
-
std::logic_error | if a string is empty, or not unique. |
◆ get_args()
std::vector< std::string > ffss::SSUtility::get_args |
( |
const std::string & |
raw_args | ) |
|
|
static |
Parse arguments.
- Parameters
-
Parses arguments, delimited by a space. If an argument is within single '\'' or double '"' quotations, spaces are ignored.
Documented preconditions are as follows:
- All quotes in
raw_args
must be closed, hence strings like hello "hello
are not accepted.
- Returns
- A vector which is of size 0 if there are no arguments.
- Exceptions
-
std::runtime_error | if a quote is not terminated. |
◆ load_file()
std::string ffss::SSUtility::load_file |
( |
const std::string & |
path | ) |
|
|
static |
Load a file into a string with path path
.
- Parameters
-
path | a reference to a valid file path. |
Documented preconditions are as follows:
path
is a valid path string on the system.
path
must be a regular file on the system.
path
must be accessible by the user that the program executes on. - Returns
- A string containing the contents of the file at
path
.
- Exceptions
-
std::runtime_error | if the file in path is not found. |
◆ load_file_lines()
std::vector< std::string > ffss::SSUtility::load_file_lines |
( |
const std::string & |
path | ) |
|
|
static |
Load lines of a file into a vector of strings from path path
.
- Parameters
-
path | a reference to a valid file path. |
Documented preconditions are as follows:
path
is a valid path string on the system.
path
must be a regular file on the system.
path
must be accessible by the user that the program executes on. - Returns
- A vector of strings string containing the contents of the file at
path
.
- Exceptions
-
std::runtime_error | if the file in path is not found. |
◆ load_files()
std::vector< std::string > ffss::SSUtility::load_files |
( |
const std::string & |
path_root | ) |
|
|
static |
Load a files from directory path_root
.
- Parameters
-
path_root | a reference to a valid directory. |
This function loads all regular files from path_root
but does not recurse into further directories. Hence the function only loads regular files at level 1 relative to path_root
. This function then uses load_file() to read the contents of each file in path_root
into a vector of strings. Documented preconditions are as follows:
path_root
is a valid path string on the system.
path_root
must be a directory on the system.
path_root
must be accessible by the user that the program executes on. - Returns
- A vector of minimum distinguishable lengths for each corresponding string (same index).
- Exceptions
-
std::runtime_error | if there are any errors processing directories. |
- See also
- load_file()
◆ load_pcm()
std::string ffss::SSUtility::load_pcm |
( |
const std::string & |
mp3_data | ) |
|
|
static |
Converts a MP3 file into PCM data.
- Parameters
-
mp3_data | binary data of the MP3 file. |
Documented preconditions are as follows:
mp3_file
is a valid MP3 file with a valid audio bitrate (48kHz only) and valid audio encoding (16-bit signed little-endian only). - Returns
- A string containing the contents of the PCM data.
- Exceptions
-
std::runtime_error | if any errors parsing the MP3 data are encountered. |
The documentation for this class was generated from the following files:
- /home/user/git/projects_2023/ffss2/src/ss/SSUtility.h
- /home/user/git/projects_2023/ffss2/src/ss/SSUtility.cpp