|
lipsum-cpp 0.5.4
A basic library written in C++ for generating placeholder Lorem Ipsum text.
|
Class for multi-source generation. More...
#include <source.hpp>
Public Member Functions | |
| Source ()=default | |
| Default constructor. | |
| Source (const std::string &path) | |
| Constructor with a path. | |
| void | load (const std::string &path) |
| Load a source and fill the vector. | |
| std::string | random_word (std::mt19937 &gen, bool lazy=false) |
| Select a random word. | |
Private Attributes | |
| int | idx = -1 |
| std::string | currentLoaded |
| std::vector< std::string > | m_Words |
| The internal list of words stored. | |
Class for multi-source generation.
This class is for multi-source generation which exposes a function to generate a random word.
|
default |
Default constructor.
Default constructor which leaves the m_Words object empty, using the standard lorem-ipsum from sample.inl instead.
| lipsum::Source::Source | ( | const std::string & | path | ) |
Constructor with a path.
Constructor which reads from the file specified or enables the specified built-in source, and filling object m_Words with unique words if applicable.
| path | A path to the source file. |
| void lipsum::Source::load | ( | const std::string & | path | ) |
Load a source and fill the vector.
Read from the file specified and fill object m_Words with the unique words from it. Formerly known as lpsm::Source::Load(). If path is "default"/"lorem", use default lorem-ipsum source. If path is "cat", use cat-ipsum. If path is "dog"/"doggo", use dog-ipsum. If path is "corpo"/"corporate", use corporate-ipsum.
| path | A path to the source file. |
|
nodiscard |
Select a random word.
Select a random word from m_Words unless m_Words is empty, in which it uses a built-in source from sample.inl as a fallback. Formerly known as lpsm::Source::RandomWord().
| gen | The generator to use. |
| lazy | Whether to use "lazy" mode. i.e. use a non-random index of the source list. |
|
private |
If not using a custom list, which built-in source to use.