17#define LPSM_SOURCE_IPSUM(ipsum) \
21 idx %= ipsum.size(); \
22 return {ipsum.at(idx)}; \
24 std::uniform_int_distribution<size_t> dist(0, ipsum.size() - 1); \
25 return {ipsum.at(dist(gen))};
27#define LPSM_SOURCE_CUSTOM_IPSUM(ipsum, name) \
28 if (currentLoaded == name) \
30 LPSM_SOURCE_IPSUM(ipsum) \
42#ifndef LIPSUM_MIN_BUILD
45 LPSM_SOURCE_CUSTOM_IPSUM(CAT_IPSUM,
"cat")
46 LPSM_SOURCE_CUSTOM_IPSUM(DOG_IPSUM,
"dog")
47 LPSM_SOURCE_CUSTOM_IPSUM(CORPO_IPSUM,
"corpo")
48 LPSM_SOURCE_IPSUM(LIPSUM_VEC)
52 std::uniform_int_distribution<size_t> dist(0, LIPSUM_VEC.size() - 1);
53 return {LIPSUM_VEC.at(dist(gen))};
61#ifndef LIPSUM_MIN_BUILD
62 if (path ==
"default" || path ==
"lorem")
72 if (path ==
"dog" || path ==
"doggo")
77 if (path ==
"corpo" || path ==
"corporate")
82 std::ifstream file(path);
83 std::unordered_set<std::string> unique;
89 "lpsm::Source::load(): Could not open file ",
91 "; falling back to standard lorem-ipsum source");
94 while (file.get(letter))
97 letter ==
'-' || letter ==
'\'')
101 else if (!word.empty())
111 std::copy(unique.begin(), unique.end(), std::back_inserter(
m_Words));
Source()=default
Default constructor.
std::string currentLoaded
Definition source.hpp:87
std::string random_word(std::mt19937 &gen, bool lazy=false)
Select a random word.
Definition source.inl:40
std::vector< std::string > m_Words
The internal list of words stored.
Definition source.hpp:90
void load(const std::string &path)
Load a source and fill the vector.
Definition source.inl:57
#define LPSM_SAFE_CCTYPE(type, func, arg)
Simplify safe cctype usage.
Definition core.hpp:36
#define LPSM_VERBOSE_LOG(type,...)
Verbose log messages.
Definition core.hpp:49
Declaration of lipsum::internal.
void LogWarn(LogType type, const Args &... args)
Log a warning.
Definition internal.hpp:126
This is the main namespace of lipsum-cpp.
File containing all of the words used by lipsum::Source.