|
Dumb-ways-to-memorize
2D game
|
#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <stdio.h>#include <math.h>#include "globals.h"#include "mystrings.h"#include "parseobject.h"
Include dependency graph for mystrings.c:Go to the source code of this file.
Enumerations | |
| enum | FreeVar { PARSER = 0x1, STRING = 0x2, TOKEN = 0x4 } |
Functions | |
| jsmntok_t * | FindKey (jsmntok_t *token, char *key, char *g_str) |
| char * | JsmnToString (jsmntok_t *token, char *g_str) |
| char * | FindValue (struct object_s *obj, char *key, char *g_str) |
| void | JsmnToInt (jsmntok_t *token, char *str, int *dst) |
| int | StrToInt (char *str) |
| int | CharToInt (char c) |
| char * | TypeFromJSON (jsmntype_t Type) |
| char * | FileToString (char *fileName) |
| int | ConvertFileToUseable (char *fileName, jsmn_parser *parser, char **stringStorage, jsmntok_t **jsmnStorage) |
| GameState | StrToGameState (char *str) |
| int | StrToHazard (char *str) |
| collision_type_t | StrToCollisionType (char *str) |
| entity_state_t | StrToEntityState (char *str) |
| vec2_t * | ParseToVec2 (object_t *object, char *str) |
| char ** | ParseToStringArray (object_t *object, char *str) |
| enum FreeVar |
| Enumerator | |
|---|---|
| PARSER | |
| STRING | |
| TOKEN | |
Definition at line 185 of file mystrings.c.
| int CharToInt | ( | char | c | ) |
Character to int. A cheap switch statement.
| c | The character. |
Definition at line 121 of file mystrings.c.
Referenced by StrToInt().
| int ConvertFileToUseable | ( | char * | fileName, |
| jsmn_parser * | parser, | ||
| char ** | stringStorage, | ||
| jsmntok_t ** | jsmnStorage | ||
| ) |
Convert file to useable, by setting the storage for string and jsmntokens, give a filename.
| [in,out] | fileName | If non-null, filename of the file. |
| [in,out] | parser | If non-null, the parser. |
| [in,out] | stringStorage | If non-null, the string storage. |
| [in,out] | jsmnStorage | If non-null, the jsmn storage. |
Definition at line 192 of file mystrings.c.
References FileToString(), jsmn_init(), jsmn_parse(), PARSER, STRING, and TOKEN.
Referenced by LoadEntityData(), LoadGameData(), LoadLevel(), LoadMenuData(), LoadPowerUpData(), LoadSelectedLevel(), SetAI_Check(), and UpdatePowerUpMenu().
| char* FileToString | ( | char * | file | ) |
Loads string data from a file.
| [in,out] | file | If non-null, filename of the file. |
Definition at line 159 of file mystrings.c.
References ALLOC_STR.
Referenced by ConvertFileToUseable().
Searches for the first key that matches given gPlayerName, through through tokens & g_str.
| [in,out] | token | The token. |
| [in,out] | key | The key. |
| [in,out] | g_str | The string to get from. |
Definition at line 10 of file mystrings.c.
References CountMem(), JsmnToString(), and jsmntok_t::size.
Referenced by LoadEntityData(), LoadLevel(), LoadLevelData(), ParseAI(), ParsePresetAI(), and ParseToEntity().
| char* FindValue | ( | struct object_s * | obj, |
| char * | key, | ||
| char * | g_str | ||
| ) |
Searches for the a value in the object that matches the key string given. Recursive.
| [in,out] | obj | If non-null, the object. |
| [in,out] | key | If non-null, the key. |
| [in,out] | g_str | If non-null, the string. |
Definition at line 53 of file mystrings.c.
References object_t::children, CountMem(), FindValue(), JsmnToString(), object_t::keys, and object_t::values.
Referenced by FindValue(), LoadLevel(), LoadMenu(), LoadMenuData(), ParseAI(), ParsePresetAI(), ParseToPowerUp(), and Update().
| void JsmnToInt | ( | jsmntok_t * | token, |
| char * | str, | ||
| int * | dst | ||
| ) |
Jsmn to int.
| [in,out] | token | If non-null, the token. |
| [in,out] | str | If non-null, the string. |
| [in,out] | dst | If non-null, destination for the value. |
Definition at line 84 of file mystrings.c.
References JsmnToString(), and StrToInt().
Referenced by LoadLevelData(), and ParseToEntity().
| char* JsmnToString | ( | jsmntok_t * | token, |
| char * | g_str | ||
| ) |
Jsmn to string.
| [in,out] | token | If non-null, the token. |
| [in,out] | g_str | If non-null, the global string. |
Definition at line 34 of file mystrings.c.
References ALLOC_STR, jsmntok_t::end, and jsmntok_t::start.
Referenced by FindKey(), FindValue(), JsmnToInt(), LoadGameData(), LoadLevel(), LoadLevelData(), LoadMenuData(), LoadPowerUpData(), ParseAI(), ParseComplexMember(), ParsePresetAI(), ParseToEntity(), ParseToObject(), ParseToStringArray(), ParseToVec2(), PrintObject(), SetAI_Action(), and UpdatePowerUpMenu().
| char** ParseToStringArray | ( | object_t * | object, |
| char * | str | ||
| ) |
| vec2_t* ParseToVec2 | ( | object_t * | object, |
| char * | str | ||
| ) |
Definition at line 385 of file mystrings.c.
References JsmnToString(), StrToInt(), vec2_t::x, and vec2_t::y.
| collision_type_t StrToCollisionType | ( | char * | str | ) |
Converts a str to a collision type.
| [in,out] | str | If non-null, the string. |
Definition at line 344 of file mystrings.c.
References COLLISION_TYPE_CLIP, and Collisions_str.
Referenced by ParseComplexMember().
| entity_state_t StrToEntityState | ( | char * | str | ) |
Converts a str to an entity state.
| [in,out] | str | If non-null, the string. |
Definition at line 370 of file mystrings.c.
References COLLISION_TYPE_CLIP, and EntityStates_str.
Referenced by ParseComplexMember().
| GameState StrToGameState | ( | char * | str | ) |
Converts a str to a game state.
| [in,out] | str | If non-null, the string. |
Definition at line 274 of file mystrings.c.
References CHOOSE, END, GAME_STATE_CHOOSE_STR, GAME_STATE_END_STR, GAME_STATE_GUESS_STR, GAME_STATE_PLAYING_STR, GAME_STATE_SPLASH_STR, GAME_STATE_START_STR, GUESS, PLAYING, SPLASH, and START.
Referenced by LoadMenu(), and LoadMenuData().
| int StrToHazard | ( | char * | str | ) |
Converts a str to a hazard.
| [in,out] | str | If non-null, the string. |
Definition at line 317 of file mystrings.c.
References CountMem(), and Hazards_str.
Referenced by ParseComplexMember().
| int StrToInt | ( | char * | str | ) |
String to int.
| [in,out] | str | If non-null, the string. |
Definition at line 92 of file mystrings.c.
References CharToInt().
Referenced by JsmnToInt(), LoadLevel(), ParseAI(), ParseToVec2(), SetAI_Check(), and SetAI_Var().
| char* TypeFromJSON | ( | jsmntype_t | Type | ) |
Type string from JSON string.
| Type | The type. |
Definition at line 140 of file mystrings.c.
References JSMN_ARRAY, JSMN_OBJECT, JSMN_PRIMITIVE, JSMN_STRING, and JSMN_UNDEFINED.
1.8.11