Skip to content

Commit 9f20451

Browse files
committed
Update C++ headerdoc and add to_integer and to_double
1 parent 89a7f22 commit 9f20451

59 files changed

Lines changed: 1708 additions & 1394 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

coresdk/src/coresdk/basics.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,21 @@ namespace splashkit_lib
148148
return std::stoi(text);
149149
}
150150

151+
int to_integer(const string &text)
152+
{
153+
return std::stoi(text);
154+
}
155+
151156
double convert_to_double(const string &text)
152157
{
153158
return std::stod(text);
154159
}
155160

161+
double to_double(const string &text)
162+
{
163+
return std::stod(text);
164+
}
165+
156166
bool is_binary(const string &bin_str)
157167
{
158168
for (char c : bin_str)

coresdk/src/coresdk/basics.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,27 @@ namespace splashkit_lib
9191
*/
9292
double convert_to_double(const string &text);
9393

94-
/**
94+
/**
95+
* Convert the passed in string into an integer. This can fail in an error if
96+
* the value is not an integer, consider using `is_integer` to check before
97+
* converting a string.
98+
*
99+
* @param text The text to convert.
100+
* @return The integer value read from the text.
101+
*/
102+
int to_integer(const string &text);
103+
104+
/**
105+
* Convert the passed in string into a double. This can fail in an error if
106+
* the value is not a number, consider using `is_number` to check before
107+
* converting a string.
108+
*
109+
* @param text The text to convert.
110+
* @return The double value read from the text.
111+
*/
112+
double to_double(const string &text);
113+
114+
/**
95115
* Returns the length of a string in characters.
96116
*
97117
* @param text The text to get the length of

generated/clib/sk_clib.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,16 @@ double __sklib__square_root__int(int number) {
374374
double __skreturn = square_root(__skparam__number);
375375
return __sklib__to_double(__skreturn);
376376
}
377+
double __sklib__to_double__string_ref(const __sklib_string text) {
378+
string __skparam__text = __sklib__to_string(text);
379+
double __skreturn = to_double(__skparam__text);
380+
return __sklib__to_double(__skreturn);
381+
}
382+
int __sklib__to_integer__string_ref(const __sklib_string text) {
383+
string __skparam__text = __sklib__to_string(text);
384+
int __skreturn = to_integer(__skparam__text);
385+
return __sklib__to_int(__skreturn);
386+
}
377387
__sklib_string __sklib__to_lowercase__string_ref(const __sklib_string text) {
378388
string __skparam__text = __sklib__to_string(text);
379389
string __skreturn = to_lowercase(__skparam__text);

generated/clib/sk_clib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ __sklib_string __sklib__oct_to_hex__string_ref(const __sklib_string oct_str);
246246
__sklib_string __sklib__replace_all__string_ref__string_ref__string_ref(const __sklib_string text, const __sklib_string substr, const __sklib_string new_text);
247247
__sklib_vector_string __sklib__split__string_ref__char(const __sklib_string text, char delimiter);
248248
double __sklib__square_root__int(int number);
249+
double __sklib__to_double__string_ref(const __sklib_string text);
250+
int __sklib__to_integer__string_ref(const __sklib_string text);
249251
__sklib_string __sklib__to_lowercase__string_ref(const __sklib_string text);
250252
__sklib_string __sklib__to_uppercase__string_ref(const __sklib_string text);
251253
__sklib_string __sklib__trim__string_ref(const __sklib_string text);

generated/cpp/animations.h

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,60 +19,60 @@ using std::to_string;
1919
* Returns the number of `animation`s within an `animation_script`.
2020
* @param script The `animation_script` to count the animations in.
2121
* @return Returns an `int` equal to the total number of animations in the script.
22-
*/;
22+
*/
2323
int animation_count(animation_script script);
2424
/**
2525
* Returns the current cell (the part of the image or sprite) of this
2626
* animation. This can be used to animate an image or sprite.
2727
* @param anim The `animation` to return the cell of.
2828
* @return Returns the current cell of the animation passed to the method.
29-
*/;
29+
*/
3030
int animation_current_cell(animation anim);
3131
/**
3232
* Returns the `vector_2d` assigned to the current frame in the animation.
3333
* @param anim The animation to check the vector of.
3434
* @return Returns the `vector_2d` assigned to the current frame in the animation.
35-
*/;
35+
*/
3636
vector_2d animation_current_vector(animation anim);
3737
/**
3838
* Checks if an `animation` has ended.
3939
* @param anim The animation to check.
4040
* @return Returns a `bool` denoting whether the `animation` has ended.
41-
*/;
41+
*/
4242
bool animation_ended(animation anim);
4343
/**
4444
* Returns true if the `animation` entered a new frame on its last update.
4545
* This can be used to trigger actions on frames within an animation.
4646
* @param anim The animation to check.
4747
* @return Returns a `bool` denoting whether the `animation` has ended.
48-
*/;
48+
*/
4949
bool animation_entered_frame(animation anim);
5050
/**
5151
* Returns the amount of time spent in the current frame. When this
5252
* exceeds the frames duration the animation moves to the next frame.
5353
* @param anim The animation to check.
5454
* @return Returns the amount of time spent in the current frame as a `float`.
55-
*/;
55+
*/
5656
float animation_frame_time(animation anim);
5757
/**
5858
* Searches an `animation_script` for an `animation` and returns its
5959
* index.
6060
* @param script The `animation_script` to look for the `animation` in.
6161
* @param name The name of the `animation` to look for.
6262
* @return Returns the index of the `animation` in the `animation_script`
63-
*/;
63+
*/
6464
int animation_index(animation_script script, const string &name);
6565
/**
6666
* Searches an `animation_script` for an animation and returns its name.
6767
* @param temp The `animation` to search for.
6868
* @return Returns the name of the `animation` in the `animation_script`.
69-
*/;
69+
*/
7070
string animation_name(animation temp);
7171
/**
7272
* Retuns the name of an `animation_script`.
7373
* @param script The `animation_script` to return the name of.
7474
* @return Returns a `string` that is the name of the animation script passed to the method.
75-
*/;
75+
*/
7676
string animation_script_name(animation_script script);
7777
/**
7878
* Loads and returns a `animation_script`. The supplied filename is
@@ -82,7 +82,7 @@ string animation_script_name(animation_script script);
8282
* the animation_script_named method.
8383
* @param name Indicates the name used to locate the animation_script to load
8484
* @return Returns the newly loaded `animation_script`.
85-
*/;
85+
*/
8686
animation_script animation_script_named(const string &name);
8787
/**
8888
* Setup an `animation` to follow the script from an indicated name.
@@ -93,7 +93,7 @@ animation_script animation_script_named(const string &name);
9393
* @param script The `animation_script` to assign the `animation` to.
9494
* @param name The name of the `animation` to be assigned.
9595
*
96-
*/;
96+
*/
9797
void assign_animation(animation anim, animation_script script, const string &name);
9898
/**
9999
* Assigns an `animation` to an `animation_script`. This may play a
@@ -104,15 +104,15 @@ void assign_animation(animation anim, animation_script script, const string &nam
104104
* @param name The name of the `animation` to be assigned.
105105
* @param with_sound Denotes whether the `animation` should play audio.
106106
*
107-
*/;
107+
*/
108108
void assign_animation(animation anim, animation_script script, const string &name, bool with_sound);
109109
/**
110110
* Assigns an `animation` to an `animation_script`.
111111
* @param anim The `animation` to be assigned.
112112
* @param script The `animation_script` to assign the `animation` to.
113113
* @param idx The index of the `animation` to create.
114114
*
115-
*/;
115+
*/
116116
void assign_animation(animation anim, animation_script script, int idx);
117117
/**
118118
* Assigns an `animation` to an `animation_script`. This may play a
@@ -123,15 +123,15 @@ void assign_animation(animation anim, animation_script script, int idx);
123123
* @param idx The index of the `animation` to create.
124124
* @param with_sound Denotes whether the `animation` should play audio.
125125
*
126-
*/;
126+
*/
127127
void assign_animation(animation anim, animation_script script, int idx, bool with_sound);
128128
/**
129129
* Assigns an `animation` to an `animation_script`.
130130
* @param anim The `animation` to be assigned.
131131
* @param script_name The name of the `animation_script` to assign the `animation` to.
132132
* @param name The name of the `animation` to be assigned.
133133
*
134-
*/;
134+
*/
135135
void assign_animation(animation anim, const string &script_name, const string &name);
136136
/**
137137
* Assigns an `animation` to an `animation_script`. This may play a
@@ -142,7 +142,7 @@ void assign_animation(animation anim, const string &script_name, const string &n
142142
* @param name The name of the `animation` to be assigned
143143
* @param with_sound Denotes whether the `animation` should play audio.
144144
*
145-
*/;
145+
*/
146146
void assign_animation(animation anim, const string &script_name, const string &name, bool with_sound);
147147
/**
148148
* Setup an `animation` to follow the script from an indicated index.
@@ -151,7 +151,7 @@ void assign_animation(animation anim, const string &script_name, const string &n
151151
* @param anim The `animation` to be assigned.
152152
* @param idx The index of the animation to use from its current script.
153153
*
154-
*/;
154+
*/
155155
void assign_animation(animation anim, int idx);
156156
/**
157157
* Setup an `animation` to follow the script from an indicated index.
@@ -161,7 +161,7 @@ void assign_animation(animation anim, int idx);
161161
* @param idx The index of the animation to use from its current script.
162162
* @param with_sound Denotes whether the `animation` should play audio.
163163
*
164-
*/;
164+
*/
165165
void assign_animation(animation anim, int idx, bool with_sound);
166166
/**
167167
* Setup an `animation` to follow the script from an indicated name.
@@ -170,7 +170,7 @@ void assign_animation(animation anim, int idx, bool with_sound);
170170
* @param anim The `animation` to be assigned.
171171
* @param name The name of the animation to use from its current script.
172172
*
173-
*/;
173+
*/
174174
void assign_animation(animation anim, string name);
175175
/**
176176
* Setup an `animation` to follow the script from an indicated name.
@@ -180,7 +180,7 @@ void assign_animation(animation anim, string name);
180180
* @param name The name of the animation to use from its current script.
181181
* @param with_sound Denotes whether the `animation` should play audio.
182182
*
183-
*/;
183+
*/
184184
void assign_animation(animation anim, string name, bool with_sound);
185185
/**
186186
* Creates an animation from an `animation_script`. This may play a
@@ -190,14 +190,14 @@ void assign_animation(animation anim, string name, bool with_sound);
190190
* @param idx The index of the `animation` to create.
191191
* @param with_sound Denotes whether the `animation` should play audio.
192192
* @return Returns the newly created `animation_script`.
193-
*/;
193+
*/
194194
animation create_animation(animation_script script, int idx, bool with_sound);
195195
/**
196196
* Creates an animation from an `animation_script`.
197197
* @param script The `animation_script` to create the `animation` from
198198
* @param name The name for the new `animation`
199199
* @return Returns the newly created `animation`
200-
*/;
200+
*/
201201
animation create_animation(animation_script script, const string &name);
202202
/**
203203
* Creates an animation from a `animation_script`. This may play a
@@ -207,7 +207,7 @@ animation create_animation(animation_script script, const string &name);
207207
* @param name The name for the new `animation`
208208
* @param with_sound Denotes whether the `animation` should play audio.
209209
* @return Returns the newly created `animation`.
210-
*/;
210+
*/
211211
animation create_animation(animation_script script, const string &name, bool with_sound);
212212
/**
213213
* Creates an animation from an `animation_script`'s name. This may
@@ -216,7 +216,7 @@ animation create_animation(animation_script script, const string &name, bool wit
216216
* @param script_name The name of the `animation_script` to create the `animation` from
217217
* @param name The name for the new `animation`
218218
* @return Returns the newly created `animation`
219-
*/;
219+
*/
220220
animation create_animation(const string &script_name, const string &name);
221221
/**
222222
* Creates an animation from an `animation_script`'s name. This may
@@ -226,72 +226,72 @@ animation create_animation(const string &script_name, const string &name);
226226
* @param name The name for the new `animation`
227227
* @param with_sound Denotes whether the `animation` should play audio.
228228
* @return Returns the newly created `animation`
229-
*/;
229+
*/
230230
animation create_animation(const string &script_name, const string &name, bool with_sound);
231231
/**
232232
* Frees all loaded `animation_script`s.
233233
234234
*
235-
*/;
235+
*/
236236
void free_all_animation_scripts();
237237
/**
238238
* Disposes of the resources used in the animation.
239239
* @param ani The `animation` to be disposed of.
240240
*
241-
*/;
241+
*/
242242
void free_animation(animation ani);
243243
/**
244244
* Frees loaded animation frames data. Use this when you will no
245245
* longer be using the animation for any purpose, including within
246246
* sprite.
247247
* @param script_to_free The `animation_script` to be freed.
248248
*
249-
*/;
249+
*/
250250
void free_animation_script(animation_script script_to_free);
251251
/**
252252
* Frees loaded `animation_script` data. Use this when you will no
253253
* longer be using the animation for any purpose, including within
254254
* sprite.
255255
* @param name The name of the `animation_script` to be freed.
256256
*
257-
*/;
257+
*/
258258
void free_animation_script(const string &name);
259259
/**
260260
* Returns whether an `animation_script` has been loaded with the
261261
* given name.
262262
* @param script The `animation_script` to check.
263263
* @param name The name of the `animation_script` to look for.
264264
* @return Returns a `bool` that denotes whether the `animation_script` has been loaded.
265-
*/;
265+
*/
266266
bool has_animation_named(animation_script script, const string &name);
267267
/**
268268
* Determines if SplashKit has animation frames loaded for the
269269
* supplied name. This checks against all loaded animation frames,
270270
* those loaded without a name are assigned the filename as a default.
271271
* @param name The name of the animation script to look for.
272272
* @return Returns the `bool` that denotes if the animation has the `animation_script`
273-
*/;
273+
*/
274274
bool has_animation_script(const string &name);
275275
/**
276276
* Load animation details from an animation frames file.
277277
* @param name The name of the `animation_script`.
278278
* @param filename The file to load the `animation_script` from.
279279
* @return Returns the newly loaded `animation_script`.
280-
*/;
280+
*/
281281
animation_script load_animation_script(const string &name, const string &filename);
282282
/**
283283
* Restarts an `animation`.
284284
* @param anim The `animation` to restart.
285285
*
286-
*/;
286+
*/
287287
void restart_animation(animation anim);
288288
/**
289289
* Restarts an `animation`. This may play a sound effect if the first
290290
* frame triggers a sound.
291291
* @param anim The `animation` to restart.
292292
* @param with_sound Denotes whether the `animation` should play audio.
293293
*
294-
*/;
294+
*/
295295
void restart_animation(animation anim, bool with_sound);
296296
/**
297297
* Updates the animation, updating the time spent and possibly moving to
@@ -301,15 +301,15 @@ void restart_animation(animation anim, bool with_sound);
301301
* @param pct The amount that the frame time will be incremented
302302
* @param with_sound Denotes whether the `animation` should play audio.
303303
*
304-
*/;
304+
*/
305305
void update_animation(animation anim, float pct, bool with_sound);
306306
/**
307307
* Updates the animation, updating the time spent and possibly moving to
308308
* a new frame in the animation. This may play a sound effect if the new
309309
* frame triggers a sound.
310310
* @param anim The `animation` to update.
311311
*
312-
*/;
312+
*/
313313
void update_animation(animation anim);
314314
/**
315315
* Updates the animation, updating the time spent and possibly moving to
@@ -318,7 +318,7 @@ void update_animation(animation anim);
318318
* @param anim The `animation` to update.
319319
* @param pct The amount that the frame time will be incremented
320320
*
321-
*/;
321+
*/
322322
void update_animation(animation anim, float pct);
323323

324324
#endif /* __animations_h */

0 commit comments

Comments
 (0)