mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-06-28 15:38:30 +02:00
Apparently in C, if you have `void test();`, it's completely okay to do `test(2);`. The function will take in the argument, but just discard it and throw it away. It's like a trash can, and a rude one at that. If you declare it like `void test(void);`, this is prevented. This is not a problem in C++ - doing `void test();` and `test(2);` is guaranteed to result in a compile error (this also means that right now, at least in all `.cpp` files, nobody is ever calling a void parameter function with arguments and having their arguments be thrown away). However, we may not be using C++ in the future, so I just want to lay down the precedent that if a function takes in no arguments, you must explicitly declare it as such. I would've added `-Wstrict-prototypes`, but it produces an annoying warning message saying it doesn't work in C++ mode if you're compiling in C++ mode. So it can be added later.
77 lines
1.4 KiB
C++
77 lines
1.4 KiB
C++
#ifndef UTILITYCLASS_H
|
|
#define UTILITYCLASS_H
|
|
|
|
#include <SDL.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
int ss_toi(const std::string& str);
|
|
|
|
bool next_split(
|
|
size_t* start,
|
|
size_t* len,
|
|
const char* str,
|
|
const char delim
|
|
);
|
|
|
|
bool next_split_s(
|
|
char buffer[],
|
|
const size_t buffer_size,
|
|
size_t* start,
|
|
const char* str,
|
|
const char delim
|
|
);
|
|
|
|
bool is_number(const char* str);
|
|
|
|
bool is_positive_num(const char* str, const bool hex);
|
|
|
|
bool endsWith(const std::string& str, const std::string& suffix);
|
|
|
|
#define INBOUNDS_VEC(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
|
|
#define INBOUNDS_ARR(index, array) ((int) index >= 0 && (int) index < (int) SDL_arraysize(array))
|
|
|
|
#define WHINE_ONCE(message) \
|
|
static bool whine = true; \
|
|
if (whine) \
|
|
{ \
|
|
whine = false; \
|
|
puts(message); \
|
|
}
|
|
|
|
|
|
//helperClass
|
|
class UtilityClass
|
|
{
|
|
public:
|
|
UtilityClass(void);
|
|
|
|
static std::string String(int _v);
|
|
|
|
static int Int(const char* str, int fallback = 0);
|
|
|
|
static std::string GCString(const std::vector<SDL_GameControllerButton>& buttons);
|
|
|
|
std::string twodigits(int t);
|
|
|
|
std::string timestring(int t);
|
|
|
|
std::string number(int _t);
|
|
|
|
|
|
static bool intersects( SDL_Rect A, SDL_Rect B );
|
|
|
|
void updateglow(void);
|
|
|
|
int glow;
|
|
int slowsine;
|
|
int glowdir;
|
|
int splitseconds[30];
|
|
};
|
|
|
|
#ifndef HELP_DEFINITION
|
|
extern UtilityClass help;
|
|
#endif
|
|
|
|
#endif /* UTILITYCLASS_H */
|