Fix Silly Mistakes

This commit is contained in:
gingerBill 2015-09-27 17:40:52 +01:00
parent 3eb2038e8e
commit b3bfc19108
2 changed files with 151 additions and 150 deletions

View File

@ -255,6 +255,51 @@ gb_ini_error_string(const struct gb_Ini_Error err)
}
#endif
#ifdef GB_INI_CPP
#if !defined(__cplusplus)
#error You need to compile as C++ for the C++ version of gb_ini.h to work
#endif
namespace gb
{
typedef gb_Ini_Error Ini_Error;
typedef gb_Ini_Handler Ini_Handler;
// Just a copy but with the GB_ prefix stripped
enum
{
INI_ERROR_NONE = 0,
INI_ERROR_FILE_ERROR,
INI_ERROR_MISSING_SECTION_BRACKET,
INI_ERROR_ASSIGNMENT_MISSING,
INI_ERROR_HANDLER_ERROR,
// No need for enum count
};
Ini_Error
ini_parse(const char* filename, Ini_Handler* handler_func, void* data)
{
return gb_ini_parse(filename, handler_func, data);
}
Ini_Error
ini_parse(FILE* file, Ini_Handler* handler_func, void* data)
{
return gb_ini_parse_file(file, handler_func, data);
}
const char*
ini_error_string(const Ini_Error err)
{
return GB_ERROR_STRINGS[err.type];
}
} // namespace gb
#endif // GB_INI_CPP
#endif // GB_INI_INCLUDE_GB_INI_H
#ifdef GB_INI_IMPLEMENTATION
#include <ctype.h>
#include <string.h>
@ -413,48 +458,3 @@ gb_ini_parse_file(FILE* file, gb_Ini_Handler* handler_func, void* data)
}
#endif // GB_INI_IMPLEMENTATION
#ifdef GB_INI_CPP
#if !defined(__cplusplus)
#error You need to compile as C++ for the C++ version of gb_ini.h to work
#endif
namespace gb
{
typedef gb_Ini_Error Ini_Error;
typedef gb_Ini_Handler Ini_Handler;
// Just a copy but with the GB_ prefix stripped
enum
{
INI_ERROR_NONE = 0,
INI_ERROR_FILE_ERROR,
INI_ERROR_MISSING_SECTION_BRACKET,
INI_ERROR_ASSIGNMENT_MISSING,
INI_ERROR_HANDLER_ERROR,
// No need for enum count
};
Ini_Error
ini_parse(const char* filename, Ini_Handler* handler_func, void* data)
{
return gb_ini_parse(filename, handler_func, data);
}
Ini_Error
ini_parse(FILE* file, Ini_Handler* handler_func, void* data)
{
return gb_ini_parse_file(file, handler_func, data);
}
const char*
ini_error_string(const Ini_Error err)
{
return GB_ERROR_STRINGS[err.type];
}
} // namespace gb
#endif // GB_INI_CPP
#endif // GB_INI_INCLUDE_GB_INI_H

View File

@ -112,12 +112,13 @@
//
// C example
#if 0
#include <stdio.h>
#include <stdlib.h>
#define GB_STRING_IMPLEMENTATION
#include "gb_string.h"
#include <stdio.h>
void string_test(void)
int main(int argc, char** argv)
{
gb_String str = gb_make_string("Hello");
gb_String other_str = gb_make_string_length(", ", 2);
@ -150,13 +151,14 @@ void string_test(void)
//
// C++ example
#if 0
#include <stdio.h>
#include <stdlib.h>
#define GB_STRING_CPP
#define GB_STRING_IMPLEMENTATION
#include "gb_string.h"
#include <stdio.h>
void string_test()
int main(int argc, char** argv)
{
using namespace gb;
@ -243,7 +245,7 @@ struct gb_String_Header
gb_usize cap;
};
#define GB_STRING_HEADER(s) ((struct gb_String_Header*)((s) - sizeof(struct gb_String_Header)))
#define GB_STRING_HEADER(s) ((struct gb_String_Header*)s - 1)
gb_String gb_make_string(const char* str);
gb_String gb_make_string_length(const void* str, gb_usize len);
@ -275,6 +277,101 @@ gb_String gb_trim_string(gb_String str, const char* cut_set);
}
#endif
#if defined(GB_STRING_CPP)
#if !defined(__cplusplus)
#error You need to compile as C++ for the C++ version of gb_string.h to work
#endif
namespace gb
{
typedef gb_String String;
typedef gb_usize usize;
gb_inline String make_string(const char* str = "")
{
return gb_make_string(str);
}
gb_inline String make_string(const void* str, usize len)
{
return gb_make_string_length(str, len);
}
gb_inline void free_string(String& str)
{
gb_make_string(str);
str = GB_NULLPTR;
}
gb_inline String duplicate_string(const String str)
{
return gb_duplicate_string(str);
}
gb_inline usize string_length(const String str)
{
return gb_string_length(str);
}
gb_inline usize string_capacity(const String str)
{
return gb_string_capacity(str);
}
gb_inline usize string_available_space(const String str)
{
return gb_string_available_space(str);
}
gb_inline void clear_string(String str)
{
gb_clear_string(str);
}
gb_inline void append_string_length(String& str, const void* other, usize len)
{
str = gb_append_string_length(str, other, len);
}
gb_inline void append_string(String& str, const String other)
{
str = gb_append_string(str, other);
}
gb_inline void append_cstring(String& str, const char* other)
{
str = gb_append_cstring(str, other);
}
gb_inline void set_string(String& str, const char* cstr)
{
str = gb_set_string(str, cstr);
}
gb_inline void string_make_space_for(String& str, usize add_len)
{
str = gb_string_make_space_for(str, add_len);
}
gb_inline usize string_allocation_size(const String str)
{
return gb_string_allocation_size(str);
}
gb_inline bool strings_are_equal(const String lhs, const String rhs)
{
return gb_strings_are_equal(lhs, rhs) == GB_TRUE;
}
gb_inline void trim_string(String& str, const char* cut_set)
{
str = gb_trim_string(str, cut_set);
}
} // namespace gb
#endif // GB_STRING_CPP
#endif // GB_STRING_H
#ifdef GB_STRING_IMPLEMENTATION
static void gb_set_string_length(gb_String str, gb_usize len)
{
@ -491,99 +588,3 @@ gb_String gb_trim_string(gb_String str, const char* cut_set)
#endif // GB_STRING_IMPLEMENTATION
#if defined(GB_STRING_CPP)
#if !defined(__cplusplus)
#error You need to compile as C++ for the C++ version of gb_string.h to work
#endif
namespace gb
{
typedef gb_String String;
typedef gb_usize usize;
gb_inline String make_string(const char* str = "")
{
return gb_make_string(str);
}
gb_inline String make_string(const void* str, usize len)
{
return gb_make_string_length(str, len);
}
gb_inline void free_string(String& str)
{
gb_make_string(str);
str = GB_NULLPTR;
}
gb_inline String duplicate_string(const String str)
{
return gb_duplicate_string(str);
}
gb_inline usize string_length(const String str)
{
return gb_string_length(str);
}
gb_inline usize string_capacity(const String str)
{
return gb_string_capacity(str);
}
gb_inline usize string_available_space(const String str)
{
return gb_string_available_space(str);
}
gb_inline void clear_string(String str)
{
gb_clear_string(str);
}
gb_inline void append_string_length(String& str, const void* other, usize len)
{
str = gb_append_string_length(str, other, len);
}
gb_inline void append_string(String& str, const String other)
{
str = gb_append_string(str, other);
}
gb_inline void append_cstring(String& str, const char* other)
{
str = gb_append_cstring(str, other);
}
gb_inline void set_string(String& str, const char* cstr)
{
str = gb_set_string(str, cstr);
}
gb_inline void string_make_space_for(String& str, usize add_len)
{
str = gb_string_make_space_for(str, add_len);
}
gb_inline usize string_allocation_size(const String str)
{
return gb_string_allocation_size(str);
}
gb_inline bool strings_are_equal(const String lhs, const String rhs)
{
return gb_strings_are_equal(lhs, rhs) == GB_TRUE;
}
gb_inline void trim_string(String& str, const char* cut_set)
{
str = gb_trim_string(str, cut_set);
}
} // namespace gb
#endif // GB_STRING_CPP
#endif // GB_STRING_HP