QuestWeaver
A procedural quest generator
Internal

Classes

struct  weave::EnumClassHash
 Operator to enable the use of enums as keys in maps. More...
 

Functions

std::string weave::htmlEncloseWithTag (const std::string &str, const std::string &tag, const std::vector< std::string > &classes) noexcept
 Encloses a given string with an HTML tag and adds the given classes as "class" attribute. More...
 
std::string weave::htmlEncloseWithTag (const std::string &str, const std::string &tag) noexcept
 Encloses a given string with an HTML tag. More...
 
std::string weave::htmlEncloseWithTag (const std::string &str, const std::string &tag, const std::string &cssClass) noexcept
 Encloses a given string with an HTML tag and adds the given CSS class. More...
 
Json::Value weave::readJsonFromFile (const char *fileName, const Directories &dirs)
 Reads and parses the given file as JSON. More...
 
bool weave::replace (std::string *str, const std::string &from, const std::string &to) noexcept
 Replaces the first occurrence of a given string with another string. More...
 
void weave::replaceAll (std::string *str, const std::string &from, const std::string &to) noexcept
 Replaces all occurrences of a given string with another string. More...
 

Detailed Description

Function Documentation

std::string weave::htmlEncloseWithTag ( const std::string &  str,
const std::string &  tag,
const std::vector< std::string > &  classes 
)
noexcept

Encloses a given string with an HTML tag and adds the given classes as "class" attribute.

Example

htmlEncloseWithTag("foo", "bar", ["myClass", "yourClass"])
// Result: <bar class="myClass yourClass">foo</bar>
Parameters
strThe string to enclose with the tag
tagThe HTML tag to use
classesA list of CSS classes for the new tag
std::string weave::htmlEncloseWithTag ( const std::string &  str,
const std::string &  tag 
)
noexcept

Encloses a given string with an HTML tag.

Example

htmlEncloseWithTag("foo", "bar")
// Result: <bar>foo</bar>
Parameters
strThe string to enclose with the tag
tagThe HTML tag to use
std::string weave::htmlEncloseWithTag ( const std::string &  str,
const std::string &  tag,
const std::string &  cssClass 
)
noexcept

Encloses a given string with an HTML tag and adds the given CSS class.

Example

htmlEncloseWithTag("foo", "bar", "myClass")
// Result: <bar class="myClass">foo</bar>
Parameters
strThe string to enclose with the tag
tagThe HTML tag to use
classThe CSS class for the new tag
Json::Value weave::readJsonFromFile ( const char *  fileName,
const Directories dirs 
)

Reads and parses the given file as JSON.

The file is searched for (in this order) in the following directories: mod directory, template directory, current working directory. If the file is not found then a ContractFailedException is thrown. Other exceptions can be thrown when a parsing error or file handling error occurs.

Parameters
fileNamethe fileName of the file to open.
dirsthe directories to search the file in.
bool weave::replace ( std::string *  str,
const std::string &  from,
const std::string &  to 
)
noexcept

Replaces the first occurrence of a given string with another string.

Parameters
strThe string that will be modified.
fromThis string will be searched in the "str" parameter.
toThis string will be used to replace the "from" parameter.
Returns
true if the string was found, false otherwise
void weave::replaceAll ( std::string *  str,
const std::string &  from,
const std::string &  to 
)
noexcept

Replaces all occurrences of a given string with another string.

Parameters
strThe string that will be modified.
fromThis string will be searched in the "str" parameter.
toThis string will be used to replace the "from" parameter.