OmexMetaUtils
-
class omexmeta::OmexMetaUtils
Public Functions
-
OmexMetaUtils() = default
Public Static Functions
-
static bool exists(const std::string &filename)
return true when filename is a file that exists on system
- Parameters
filename –
-
static int removeFile(const std::string &filename)
remove file called
- Parameters
filename –
filename – to remove
- Returns
int 0 when successful.
-
static void removeIfExists(const std::string &filename)
remove a file, checking for its existance first
- Parameters
filename – to remove
-
static void download(const std::string &url, std::string filename)
download a file from
- Parameters
url – to
filename –
class seems like a good place for the download features.wrapper around the CurlGet function, as the utils
-
static std::vector<std::string> splitStringBy(const std::string &str, char delimiter)
split a string into a vector of strings by
- Parameters
delimiter –
-
static std::string generateUniqueMetaid(LibrdfModel &model, const std::string &metaid_base, const std::vector<std::string> &exclusions)
utility for generating unique metaids given an xml document
model a librdf_model* pointer
a string that will be used for the ID. There will be 4 digits, though this can be changed.
exclusions. Mostly needed internally for dealing with metaids that already exist.
-
static std::string prepareBaseUri(std::string str, bool absolute_path = false)
process a string intended to be a base uri.
Base uri’s are important in redland libraries. If they do not begin with
http
orhttps
, sparql querying will break down. This is a helper function to ensure the base uri is properly formatted.- Parameters
str – The string that will become a base uri
absolute_path – automatically make str an absolute path to the current working directory.
-
static std::string getNamespaceFromUri(const std::string &uri)
takes a uri as std::string and returns the string with the last section removed;
Example: www.uri.com/identifer/PD12345 will turn into www.uri.com/identifier/
-
static bool isFormattedUri(std::string uri)
helper function that returns true when uri starts with either
or
- Parameters
uri – the uri to test.
-
static bool endsWith(std::string const &full_string, std::string const &ending)
test to see whether a string ends with another string
- Parameters
fullString – the string to test
ending – the ending to test for
-
static bool assertRegexMatchSplitByNewLine(const std::string &expected_string, const std::string &actual_string)
test that expected_string matches actual_string when split by new lines and matched as a regex
-
static bool assertMatchByNewLine(const std::string &expected_string, const std::string &actual_string)
-
static std::vector<std::string> configurePrefixStrings(std::string repository_name, std::string omex_name, std::string model_name)
configures the “OMEXlib”, “myOMEX” and “local” prefixes @ param omex_name the name of the omex container your model is in
- Parameters
model_name – the name of the model your are annotating. Extension should be included or it will be given the “.xml” suffix.
-
static std::string concatMetaIdAndUri(std::string metaid, std::string uri)
concatonate metaid and uri strings
Sometimes a uri has a trailing “#” and somtimes a metaid has a leading “#”. This method concatonates whilst accounting for permutations of “#”
- Parameters
metaid – string. Like “#metaid” or “metaid”
uri – string. Like “https://omex-library/jeff2019.omex/mymodel.xml” or “https://omex-library/jeff2019.omex/mymodel.rdf”
-
static std::string stringReplace(std::string str, const std::string &string_to_replace, const std::string &replacement)
replace a part of a string
- Parameters
string_to_replace – from a main
string – with a replacement string
replacement –
-
static bool startsWith(const std::string &full_string, const std::string &start)
returns true when
- Parameters
full_string – starts with the substring
start –
-
static bool stringInVector(std::vector<std::string> vec, const std::string &string)
returns true when
return true if
- Parameters
string – is in
vec –
-
static xmlDoc *parseXmlDocument(const std::string &xml_string)
read an xml document using libxml2.
- Returns
xmlDoc*. Caller is responsible for calling xmlFreeDoc(doc).
-
static std::string getXmlNodeProperty(xmlNode *node, const std::string &property)
-
static xmlNode *getChildElementCalled(xmlNode *node, const std::string &name)
-
static std::vector<xmlNode*> getAllChildElements(xmlNode *node)
-
static bool isSubString(const std::string &full_string, const std::string &substring)
-
static std::string readFromFile(const std::string &file)
read
- Parameters
file – into std::string
-
OmexMetaUtils() = default