lipsum-cpp 0.5.4
A basic library written in C++ for generating placeholder Lorem Ipsum text.
Loading...
Searching...
No Matches
lipsum::Source Class Reference

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.

Detailed Description

Class for multi-source generation.

Since
0.4.0

This class is for multi-source generation which exposes a function to generate a random word.

Constructor & Destructor Documentation

◆ Source() [1/2]

lipsum::Source::Source ( )
default

Default constructor.

Since
0.4.0

Default constructor which leaves the m_Words object empty, using the standard lorem-ipsum from sample.inl instead.

◆ Source() [2/2]

lipsum::Source::Source ( const std::string & path)

Constructor with a path.

Since
0.4.0

Constructor which reads from the file specified or enables the specified built-in source, and filling object m_Words with unique words if applicable.

Parameters
pathA path to the source file.

Member Function Documentation

◆ load()

void lipsum::Source::load ( const std::string & path)

Load a source and fill the vector.

Since
0.4.1

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.

Parameters
pathA path to the source file.

◆ random_word()

std::string lipsum::Source::random_word ( std::mt19937 & gen,
bool lazy = false )
nodiscard

Select a random word.

Since
0.4.0

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().

Parameters
genThe generator to use.
lazyWhether to use "lazy" mode. i.e. use a non-random index of the source list.
Returns
std::string The random word.

Member Data Documentation

◆ currentLoaded

std::string lipsum::Source::currentLoaded
private

If not using a custom list, which built-in source to use.


The documentation for this class was generated from the following files: