lipsum-cpp 0.5.4
A basic library written in C++ for generating placeholder Lorem Ipsum text.
Loading...
Searching...
No Matches
binded.inl
Go to the documentation of this file.
1
13
14#pragma once
15
16/*
17 * BINDED
18 * ----------------
19 */
20
21extern "C" lpsm_GeneratorHandle lpsm_Generator(const char* path)
22{
23 auto* gen = new lpsm::Generator(path, 0);
24 gen->load_seed(std::random_device{}());
25 return (reinterpret_cast<lpsm_GeneratorHandle>(gen));
26}
27
28extern "C" lpsm_GeneratorHandle lpsm_GeneratorSeeded(const char* path, int seed)
29{
30 auto* gen = new lpsm::Generator(path, seed);
31 return reinterpret_cast<lpsm_GeneratorHandle>(gen);
32}
33
35{
36 auto* realSource = LPSM_CPPIFY(handle, lpsm::Generator);
37 delete realSource;
38}
39
41 const char* path)
42{
43 LPSM_CPPIFY(handle, lpsm::Generator)->load_source(path);
44}
45
46extern "C" void lpsm_Generator_load_seed(lpsm_GeneratorHandle handle, int seed)
47{
48 LPSM_CPPIFY(handle, lpsm::Generator)->load_seed(seed);
49}
50
52 const char* setting,
53 int minValue,
54 int maxValue)
55{
56 LPSM_CPPIFY(handle, lpsm::Generator)
57 ->change_setting(setting, minValue, maxValue);
58}
59
61{
62 LPSM_CPPIFY(handle, lpsm::Generator)->toggle_lazy();
63}
64
65extern "C" char* lpsm_Generator_word(lpsm_GeneratorHandle handle, int num)
66{
67 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->word(num);
68 return ConvertToCstr(std::move(ret));
69}
70
72{
73 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->fragment();
74 return ConvertToCstr(std::move(ret));
75}
76
77extern "C" char*
78lpsm_Generator_sentence(lpsm_GeneratorHandle handle, int num, bool useLipsum)
79{
80 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->sentence(num, useLipsum);
81 return ConvertToCstr(std::move(ret));
82}
83
84extern "C" char*
85lpsm_Generator_paragraph(lpsm_GeneratorHandle handle, int num, bool useLipsum)
86{
87 auto&& ret =
88 LPSM_CPPIFY(handle, lpsm::Generator)->paragraph(num, useLipsum);
89 return ConvertToCstr(std::move(ret));
90}
91
93 bool useLipsum)
94{
95 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->text(useLipsum);
96 return ConvertToCstr(std::move(ret));
97}
98
100 int length,
101 char minChar,
102 char maxChar)
103{
104 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)
105 ->scramble(length, minChar, maxChar);
106 return ConvertToCstr(std::move(ret));
107}
108
110{
111 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->url();
112 return ConvertToCstr(std::move(ret));
113}
114
116{
117 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->plain_url();
118 return ConvertToCstr(std::move(ret));
119}
120
122{
123 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->email();
124 return ConvertToCstr(std::move(ret));
125}
126
128 char separator)
129{
130 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->slug(separator);
131 return ConvertToCstr(std::move(ret));
132}
133
135 lpsm_CaseSlugCase case_)
136{
137 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)
138 ->case_slug(static_cast<lpsm::CaseSlugCase>(case_));
139 return ConvertToCstr(std::move(ret));
140}
141
144{
145 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)
146 ->code(static_cast<lpsm::CodeLanguage>(lang));
147 return ConvertToCstr(std::move(ret));
148}
149
150extern "C" char*
151lpsm_Generator_ip_addr(lpsm_GeneratorHandle handle, bool useIpv6, bool usePort)
152{
153 auto&& ret =
154 LPSM_CPPIFY(handle, lpsm::Generator)->ip_addr(useIpv6, usePort);
155 return ConvertToCstr(std::move(ret));
156}
157
159{
160 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->phone_number();
161 return ConvertToCstr(std::move(ret));
162}
164 int num,
165 bool useLipsum,
166 bool useHtml)
167{
168 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)
169 ->fmt_paragraph(num, useLipsum, useHtml);
170 return ConvertToCstr(std::move(ret));
171}
172
174 int numElements,
175 bool useHtml)
176{
177 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)
178 ->fmt_text(numElements, useHtml);
179 return ConvertToCstr(std::move(ret));
180}
181
182extern "C" char*
183lpsm_Generator_fmt_header(lpsm_GeneratorHandle handle, int level, bool useHtml)
184{
185 auto&& ret =
186 LPSM_CPPIFY(handle, lpsm::Generator)->fmt_header(level, useHtml);
187 return ConvertToCstr(std::move(ret));
188}
189
191 bool isBold,
192 bool useHtml)
193{
194 auto&& ret =
195 LPSM_CPPIFY(handle, lpsm::Generator)->fmt_emphasis(isBold, useHtml);
196 return ConvertToCstr(std::move(ret));
197}
198
200 bool useHtml)
201{
202 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->fmt_link(useHtml);
203 return ConvertToCstr(std::move(ret));
204}
205
206extern "C" char*
207lpsm_Generator_fmt_list(lpsm_GeneratorHandle handle, bool ordered, bool useHtml)
208{
209 auto&& ret =
210 LPSM_CPPIFY(handle, lpsm::Generator)->fmt_list(ordered, useHtml);
211 return ConvertToCstr(std::move(ret));
212}
213
214extern "C" char* lpsm_Generator_xml(lpsm_GeneratorHandle handle, int choices)
215{
216 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->xml(choices);
217 return ConvertToCstr(std::move(ret));
218}
219
220extern "C" char*
221lpsm_Generator_json(lpsm_GeneratorHandle handle, int maxDepth, bool isObject)
222{
223 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->json(maxDepth, isObject);
224 return ConvertToCstr(std::move(ret));
225}
226
228 int maxDepth)
229{
230 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->json_value(maxDepth);
231 return ConvertToCstr(std::move(ret));
232}
233
235{
236 auto&& ret = LPSM_CPPIFY(handle, lpsm::Generator)->csv();
237 return ConvertToCstr(std::move(ret));
238}
void * lpsm_GeneratorHandle
A handle to a lipsum::Generator.
Definition binded.h:46
lpsm_CodeLanguage
Languages used by lpsm_Generator_code().
Definition binded.h:75
lpsm_CaseSlugCase
Cases used by lpsm_Generator_case_slug().
Definition binded.h:57
char * lpsm_Generator_scramble(lpsm_GeneratorHandle handle, int length, char minChar, char maxChar)
Generate a random character scramble.
Definition binded.inl:99
char * lpsm_Generator_csv(lpsm_GeneratorHandle handle)
Generate a CSV document.
Definition binded.inl:234
char * lpsm_Generator_phone_number(lpsm_GeneratorHandle handle)
Generate a phone number.
Definition binded.inl:158
char * lpsm_Generator_fmt_list(lpsm_GeneratorHandle handle, bool ordered, bool useHtml)
Generate a Markdown or HTML list.
Definition binded.inl:207
char * lpsm_Generator_sentence(lpsm_GeneratorHandle handle, int num, bool useLipsum)
Generate sentences.
Definition binded.inl:78
void lpsm_Generator_load_source(lpsm_GeneratorHandle handle, const char *path)
Reload a source.
Definition binded.inl:40
char * lpsm_Generator_slug(lpsm_GeneratorHandle handle, char separator)
Generate a slug.
Definition binded.inl:127
lpsm_GeneratorHandle lpsm_Generator(const char *path)
Create a lipsum::Generator.
Definition binded.inl:21
char * lpsm_Generator_fragment(lpsm_GeneratorHandle handle)
Generate a sentence fragment.
Definition binded.inl:71
char * lpsm_Generator_code(lpsm_GeneratorHandle handle, lpsm_CodeLanguage lang)
Generate a code block.
Definition binded.inl:142
void lpsm_Generator_load_seed(lpsm_GeneratorHandle handle, int seed)
Reload a seed.
Definition binded.inl:46
char * lpsm_Generator_plain_url(lpsm_GeneratorHandle handle)
Generate a plain URL.
Definition binded.inl:115
void lpsm_Generator_change_setting(lpsm_GeneratorHandle handle, const char *setting, int minValue, int maxValue)
Change a setting.
Definition binded.inl:51
char * lpsm_Generator_ip_addr(lpsm_GeneratorHandle handle, bool useIpv6, bool usePort)
Generate an IP address.
Definition binded.inl:151
char * lpsm_Generator_word(lpsm_GeneratorHandle handle, int num)
Generate words.
Definition binded.inl:65
char * lpsm_Generator_fmt_emphasis(lpsm_GeneratorHandle handle, bool isBold, bool useHtml)
Generate an emphasized Markdown or HTML sentence.
Definition binded.inl:190
char * lpsm_Generator_fmt_paragraph(lpsm_GeneratorHandle handle, int num, bool useLipsum, bool useHtml)
Generate Markdown or HTML paragraphs.
Definition binded.inl:163
char * lpsm_Generator_email(lpsm_GeneratorHandle handle)
Generate an email.
Definition binded.inl:121
char * lpsm_Generator_json_value(lpsm_GeneratorHandle handle, int maxDepth)
Generate a JSON value.
Definition binded.inl:227
char * lpsm_Generator_case_slug(lpsm_GeneratorHandle handle, lpsm_CaseSlugCase case_)
Generate a case slug.
Definition binded.inl:134
char * lpsm_Generator_fmt_header(lpsm_GeneratorHandle handle, int level, bool useHtml)
Generate a Markdown or HTML header.
Definition binded.inl:183
lpsm_GeneratorHandle lpsm_GeneratorSeeded(const char *path, int seed)
Create a lipsum::Generator.
Definition binded.inl:28
char * lpsm_Generator_xml(lpsm_GeneratorHandle handle, int choices)
Generate an XML document.
Definition binded.inl:214
char * lpsm_Generator_url(lpsm_GeneratorHandle handle)
Generate a URL.
Definition binded.inl:109
char * lpsm_Generator_fmt_text(lpsm_GeneratorHandle handle, int numElements, bool useHtml)
Generate a Markdown or HTML document.
Definition binded.inl:173
char * lpsm_Generator_paragraph(lpsm_GeneratorHandle handle, int num, bool useLipsum)
Generate paragraphs.
Definition binded.inl:85
void lpsm_GeneratorDestroy(lpsm_GeneratorHandle handle)
Delete a lipsum::Generator.
Definition binded.inl:34
char * lpsm_Generator_json(lpsm_GeneratorHandle handle, int maxDepth, bool isObject)
Generate a JSON object or array.
Definition binded.inl:221
char * lpsm_Generator_text(lpsm_GeneratorHandle handle, bool useLipsum)
Generate a random number of random paragraphs.
Definition binded.inl:92
char * lpsm_Generator_fmt_link(lpsm_GeneratorHandle handle, bool useHtml)
Generate a Markdown or HTML link.
Definition binded.inl:199
void lpsm_Generator_toggle_lazy(lpsm_GeneratorHandle handle)
Toggle the lazy flag.
Definition binded.inl:60
Main class of lipsum-cpp.
Definition generator.hpp:92
CodeLanguage
Languages used by lipsum::Generator::code().
Definition generator.hpp:76
CaseSlugCase
Cases used by lipsum::Generator::case_slug().
Definition generator.hpp:58