18#define LPSM_ASSIGN_CHECK(name) \
19 isChecked = !isChecked ? assignSetting(#name, name) : true
26 auto assignSetting = [&](
const char* name,
ArgVec2& target) ->
bool
35 bool isChecked =
false;
45 LPSM_ASSIGN_CHECK(
word);
46 LPSM_ASSIGN_CHECK(
frag);
47 LPSM_ASSIGN_CHECK(
sent);
48 LPSM_ASSIGN_CHECK(
para);
49#ifndef LIPSUM_MIN_BUILD
50 LPSM_ASSIGN_CHECK(
point);
54 LPSM_ASSIGN_CHECK(
level);
62 "lpsm::GeneratorSettings::change_setting(): "
82 m_Gen.seed(std::random_device{}());
108 "Creating a lpsm::Generator with seed ",
150 return static_cast<char>(
151 random_number(
static_cast<int>(min),
static_cast<int>(max)));
157 return choice == 0 ? min : max;
162 std::discrete_distribution<> dist(weights.begin(), weights.end());
166#ifndef LIPSUM_MIN_BUILD
169 std::vector<std::string> tlds = {{
".com"},
176 static const std::vector<int> weights = {70, 10, 7, 5, 5, 2, 1};
184 static const std::vector<int> weights = {88, 7, 3, 2};
185 static const std::vector<int> weightsEndMark = {80, 15, 5};
186 static const std::vector<std::string> mapped = {
", ",
190 static const std::vector<std::string> mappedEndMark = {
".",
"?",
"!"};
194 for (
int i = 0; i < frags; ++i)
197 result +=
word(words);
202 result += mapped.at(check);
217 constexpr int FMT_PARA_CHANCE_FMT = 14;
220 static const std::vector<int> weights = {FMT_PARA_CHANCE_FMT, 1};
226 for (
int i = 0; i < sents; ++i)
234 if (i == 0 && useLipsum)
238 else if ((fmtRoll == 1) && addLink)
242 else if ((fmtRoll == 1) && !addLink)
262 return std::string(
"\"") +
268 constexpr int JSON_NUMBER_MIN = -1000;
269 constexpr int JSON_NUMBER_MAX = 1000;
285 for (
int i = 0; i < frags; ++i)
288 result +=
word(words);
319 std::string result =
"\t";
321 for (
int i = 0; i < sents; ++i)
323 if (i == 0 && useLipsum)
void change_setting(const std::string &setting, const ArgVec2 &value)
Change a setting.
Definition generatorcore.inl:131
std::string fmt_emphasis(bool isBold=true, bool useHtml=false)
Generate an emphasized Markdown or HTML sentence.
Definition generatorformats.inl:145
GeneratorSettings m_Settings
Settings for generation.
Definition generator.hpp:832
void load_seed(int seed)
Reload a seed.
Definition generatorcore.inl:125
void toggle_lazy()
Toggle the lazy flag.
Definition generatorcore.inl:114
std::string word(int num=1)
Generate words.
Definition generator.inl:67
std::string single_sentence(const ArgVec2 &wordArg, const ArgVec2 &frag)
Generate a single sentence.
Definition generatorcore.inl:181
std::string single_fmt_paragraph(bool useLipsum, bool useHtml)
Generate a single Markdown or HTML paragraph.
Definition generatorcore.inl:210
void load_source(const std::string &path)
Reload a source.
Definition generatorcore.inl:119
std::string json_string()
Generate a random JSON string.
Definition generatorcore.inl:260
Source m_Source
Source used for generation.
Definition generator.hpp:844
int weighted_random_idx(const std::vector< int > &weights)
Choose a random index based off weights.
Definition generatorcore.inl:160
Generator()
Default constructor for Generator.
Definition generatorcore.inl:80
T random_number(T min, T max)
Generate a random number.
Definition generator.hpp:755
std::string fmt_link(bool useHtml=false)
Generate a Markdown or HTML link.
Definition generatorformats.inl:173
std::string tld()
Pick a random TLD.
Definition generatorcore.inl:167
std::string single_paragraph(bool useLipsum)
Generate a single paragraph.
Definition generatorcore.inl:317
std::string json_number()
Generate a random JSON number.
Definition generatorcore.inl:266
std::mt19937 m_Gen
Random number generator.
Definition generator.hpp:834
~Generator()
Definition generatorcore.inl:86
#define LPSM_SAFE_CCTYPE(type, func, arg)
Simplify safe cctype usage.
Definition core.hpp:36
#define LPSM_FLIP_COIN
Choose between true or false.
Definition core.hpp:31
#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
std::string ToString(const T ¶m)
Convert an object to a string.
Definition internal.hpp:242
This is the main namespace of lipsum-cpp.
LIPSUM_API std::string GenerateDefaultLipsumSentence()
Generate the beginning Lorem Ipsum sentence.
Definition misc.inl:38
Store data for inputting into functions.
Definition argvec2.hpp:29
int max
The maximum value.
Definition argvec2.hpp:56
int min
The minimum value.
Definition argvec2.hpp:55
int roll(std::mt19937 &gen, bool lazy=false) const
Return a number between min and max.
Definition argvec2.inl:39
bool lazy
Whether generation will be "lazy".
Definition generatorsettings.hpp:33
ArgVec2 csvCols
The minimum and maximum possible number of columns in CSV data.
Definition generatorsettings.hpp:130
void change_setting(const std::string &setting, const ArgVec2 &value)
Change a setting.
Definition generatorcore.inl:23
ArgVec2 fragFmt
The minimum and maximum possible number of sentence fragments in a formatted sentence.
Definition generatorsettings.hpp:99
ArgVec2 point
The minimum and maximum possible number of points in lists or statements in code blocks.
Definition generatorsettings.hpp:74
ArgVec2 sent
The minimum and maximum possible number of sentences in a paragraph.
Definition generatorsettings.hpp:57
ArgVec2 para
The minimum and maximum possible number of paragraphs in a text.
Definition generatorsettings.hpp:65
ArgVec2 frag
The minimum and maximum possible number of sentence fragments in a sentence.
Definition generatorsettings.hpp:49
ArgVec2 word
The minimum and maximum possible number of words in a sentence fragment.
Definition generatorsettings.hpp:41
ArgVec2 wordURL
The minimum and maximum possible number of words at the end of a URL, in a heading,...
Definition generatorsettings.hpp:83
ArgVec2 wordFmt
The minimum and maximum possible number of words in a sentence fragment in formatted sentences.
Definition generatorsettings.hpp:91
ArgVec2 jsonLength
The minimum and maximum possible number of items in JSON objects and arrays.
Definition generatorsettings.hpp:115
ArgVec2 level
The minimum and maximum possible heading levels, excluding the main heading.
Definition generatorsettings.hpp:107
ArgVec2 csvRows
The minimum and maximum possible number of rows in CSV data.
Definition generatorsettings.hpp:122
void toggle_lazy()
Toggle the lazy flag.
Definition generatorcore.inl:70