- potentially fixed inventory drawing bug
- moved menu library to its own file
+
+4/13/2016:
+==========
+
+ - began making the world great again
+ - adopted indent style: linuxxxx kernel
+ - began converting pointers to better things
+ - parentheses
* Defines how many milliseconds each game tick will take.
*/
-#define MSEC_PER_TICK ( 1000 / TICKS_PER_SEC )
+#define MSEC_PER_TICK (1000 / TICKS_PER_SEC)
//#define SEGFAULT
* DEBUG must be defined for this macro to function.
*/
-#define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ )
+#define DEBUG_printf(message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__)
#ifdef SEGFAULT
#define C(x) std::cout << m << std::endl
namespace config {
- void read( void );
- void update( void );
- void save( void );
+ void read(void);
+ void update(void);
+ void save(void);
}
#endif //CONFIG_H
#define NPCp(n) ((NPC *)n)
#define Structurep(n) ((Structures *)n)
#define Mobp(n) ((Mob *)n)
+#define Objectp(n) ((Object *)n)
#define PLAYER_INV_SIZE 43 // The size of the player's inventory
#define NPC_INV_SIZE 3 // Size of an NPC's inventory
glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width);
glEnd();
}
- void update( float _gravity, float ground_y ) {
+ void update(float _gravity, float ground_y) {
// handle ground collision
- if ( loc.y < ground_y ) {
+ if (loc.y < ground_y) {
loc.y = ground_y;
- if ( bounce ) {
+ if (bounce) {
vel.y *= -0.2f;
vel.x /= 4;
} else {
vel.x = vel.y = 0;
canMove = false;
}
- } else if ( gravity && vel.y > -1 )
+ } else if (gravity && vel.y > -1)
vel.y -= _gravity * deltaTime;
}
bool kill(float delta){
void follow(Entity *e);
+ bool isNear(Entity e);
+ bool isInside(vec2 coord) const;
+
virtual ~Entity(){}
};
/* FT_UNUSED is a macro used to indicate that a given parameter is not */
/* used -- this is only used to get rid of unpleasant compiler warnings */
#ifndef FT_UNUSED
-#define FT_UNUSED( arg ) ( (arg) = (arg) )
+#define FT_UNUSED(arg) ((arg) = (arg))
#endif
/* This is the only necessary change, so it is defined here instead */
/* providing a new configuration file. */
/* */
-#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
+#if defined(__APPLE__) || (defined(__MWERKS__) && defined(macintosh))
/* no Carbon frameworks for 64bit 10.4.x */
/* AvailabilityMacros.h is available since Mac OS X 10.2, */
/* so guess the system version by maximum errno before inclusion */
#ifdef ECANCELED /* defined since 10.2 */
#include "AvailabilityMacros.h"
#endif
-#if defined( __LP64__ ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
+#if defined(__LP64__) && \
+ (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4)
#undef FT_MACINTOSH
#endif
-#elif defined( __SC__ ) || defined( __MRC__ )
+#elif defined(__SC__) || defined(__MRC__)
/* Classic MacOS compilers */
#include "ConditionalMacros.h"
#if TARGET_OS_MAC
/* Fix compiler warning with sgi compiler */
-#if defined( __sgi ) && !defined( __GNUC__ )
-#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
+#if defined(__sgi) && !defined(__GNUC__)
+#if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 730)
#pragma set woff 3505
#endif
#endif
#define FT_INT64 long
#define FT_UINT64 unsigned long
-#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
+#elif defined(_MSC_VER) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
/* this compiler provides the __int64 type */
#define FT_LONG64
#define FT_INT64 __int64
#define FT_UINT64 unsigned __int64
-#elif defined( __BORLANDC__ ) /* Borland C++ */
+#elif defined(__BORLANDC__) /* Borland C++ */
/* XXXX: We should probably check the value of __BORLANDC__ in order */
/* to test the compiler version. */
#define FT_INT64 __int64
#define FT_UINT64 unsigned __int64
-#elif defined( __WATCOMC__ ) /* Watcom C++ */
+#elif defined(__WATCOMC__) /* Watcom C++ */
/* Watcom doesn't provide 64-bit data types */
-#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
+#elif defined(__MWERKS__) /* Metrowerks CodeWarrior */
#define FT_LONG64
#define FT_INT64 long long int
#define FT_UINT64 unsigned long long int
-#elif defined( __GNUC__ )
+#elif defined(__GNUC__)
/* GCC provides the `long long' type */
#define FT_LONG64
/* is defined. You can however ignore this rule by defining the */
/* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
/* */
-#if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
+#if defined(FT_LONG64) && !defined(FT_CONFIG_OPTION_FORCE_INT64)
#ifdef __STDC__
#define FT_BEGIN_STMNT do {
-#define FT_END_STMNT } while ( 0 )
+#define FT_END_STMNT } while (0)
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
/* Provide assembler fragments for performance-critical functions. */
/* These must be defined `static __inline__' with GCC. */
-#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */
+#if defined(__CC_ARM) || defined(__ARMCC__) /* RVCT */
#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
/* documentation is in freetype.h */
static __inline FT_Int32
- FT_MulFix_arm( FT_Int32 a,
- FT_Int32 b )
+ FT_MulFix_arm(FT_Int32 a,
+ FT_Int32 b)
{
register FT_Int32 t, t2;
#ifdef __GNUC__
-#if defined( __arm__ ) && \
- ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \
- !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
+#if defined(__arm__) && \
+ (!defined(__thumb__) || defined(__thumb2__)) && \
+ !(defined(__CC_ARM) || defined(__ARMCC__))
#define FT_MULFIX_ASSEMBLER FT_MulFix_arm
/* documentation is in freetype.h */
static __inline__ FT_Int32
- FT_MulFix_arm( FT_Int32 a,
- FT_Int32 b )
+ FT_MulFix_arm(FT_Int32 a,
+ FT_Int32 b)
{
register FT_Int32 t, t2;
"orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
: "=r"(a), "=&r"(t2), "=&r"(t)
: "r"(a), "r"(b)
- : "cc" );
+ : "cc");
return a;
}
#endif /* __arm__ && */
- /* ( __thumb2__ || !__thumb__ ) && */
- /* !( __CC_ARM || __ARMCC__ ) */
+ /* (__thumb2__ || !__thumb__) && */
+ /* !(__CC_ARM || __ARMCC__) */
-#if defined( __i386__ )
+#if defined(__i386__)
#define FT_MULFIX_ASSEMBLER FT_MulFix_i386
/* documentation is in freetype.h */
static __inline__ FT_Int32
- FT_MulFix_i386( FT_Int32 a,
- FT_Int32 b )
+ FT_MulFix_i386(FT_Int32 a,
+ FT_Int32 b)
{
register FT_Int32 result;
"addl %%edx, %%eax\n"
: "=a"(result), "=d"(b)
: "a"(a), "d"(b)
- : "%ecx", "cc" );
+ : "%ecx", "cc");
return result;
}
/* documentation is in freetype.h */
static __inline FT_Int32
- FT_MulFix_i386( FT_Int32 a,
- FT_Int32 b )
+ FT_MulFix_i386(FT_Int32 a,
+ FT_Int32 b)
{
register FT_Int32 result;
#endif /* _MSC_VER */
-#if defined( __GNUC__ ) && defined( __x86_64__ )
+#if defined(__GNUC__) && defined(__x86_64__)
#define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64
static __inline__ FT_Int32
- FT_MulFix_x86_64( FT_Int32 a,
- FT_Int32 b )
+ FT_MulFix_x86_64(FT_Int32 a,
+ FT_Int32 b)
{
/* Temporarily disable the warning that C90 doesn't support */
/* `long long'. */
-#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) )
+#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlong-long"
#endif
tmp = ret >> 63;
ret += 0x8000 + tmp;
- return (FT_Int32)( ret >> 16 );
+ return (FT_Int32)(ret >> 16);
#else
/* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */
"sar $16, %0\n"
: "=&r"(result), "=&r"(wide_a)
: "r"(wide_b)
- : "cc" );
+ : "cc");
return (FT_Int32)result;
#endif
-#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) )
+#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
#pragma GCC diagnostic pop
#endif
}
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
-#define FT_LOCAL( x ) static x
-#define FT_LOCAL_DEF( x ) static x
+#define FT_LOCAL(x) static x
+#define FT_LOCAL_DEF(x) static x
#else
#ifdef __cplusplus
-#define FT_LOCAL( x ) extern "C" x
-#define FT_LOCAL_DEF( x ) extern "C" x
+#define FT_LOCAL(x) extern "C" x
+#define FT_LOCAL_DEF(x) extern "C" x
#else
-#define FT_LOCAL( x ) extern x
-#define FT_LOCAL_DEF( x ) x
+#define FT_LOCAL(x) extern x
+#define FT_LOCAL_DEF(x) x
#endif
#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
-#define FT_LOCAL_ARRAY( x ) extern const x
-#define FT_LOCAL_ARRAY_DEF( x ) const x
+#define FT_LOCAL_ARRAY(x) extern const x
+#define FT_LOCAL_ARRAY_DEF(x) const x
#ifndef FT_BASE
#ifdef __cplusplus
-#define FT_BASE( x ) extern "C" x
+#define FT_BASE(x) extern "C" x
#else
-#define FT_BASE( x ) extern x
+#define FT_BASE(x) extern x
#endif
#endif /* !FT_BASE */
#ifndef FT_BASE_DEF
#ifdef __cplusplus
-#define FT_BASE_DEF( x ) x
+#define FT_BASE_DEF(x) x
#else
-#define FT_BASE_DEF( x ) x
+#define FT_BASE_DEF(x) x
#endif
#endif /* !FT_BASE_DEF */
#ifndef FT_EXPORT
#ifdef __cplusplus
-#define FT_EXPORT( x ) extern "C" x
+#define FT_EXPORT(x) extern "C" x
#else
-#define FT_EXPORT( x ) extern x
+#define FT_EXPORT(x) extern x
#endif
#endif /* !FT_EXPORT */
#ifndef FT_EXPORT_DEF
#ifdef __cplusplus
-#define FT_EXPORT_DEF( x ) extern "C" x
+#define FT_EXPORT_DEF(x) extern "C" x
#else
-#define FT_EXPORT_DEF( x ) extern x
+#define FT_EXPORT_DEF(x) extern x
#endif
#endif /* !FT_EXPORT_DEF */
#ifndef FT_EXPORT_VAR
#ifdef __cplusplus
-#define FT_EXPORT_VAR( x ) extern "C" x
+#define FT_EXPORT_VAR(x) extern "C" x
#else
-#define FT_EXPORT_VAR( x ) extern x
+#define FT_EXPORT_VAR(x) extern x
#endif
#endif /* !FT_EXPORT_VAR */
/* */
#ifndef FT_CALLBACK_DEF
#ifdef __cplusplus
-#define FT_CALLBACK_DEF( x ) extern "C" x
+#define FT_CALLBACK_DEF(x) extern "C" x
#else
-#define FT_CALLBACK_DEF( x ) static x
+#define FT_CALLBACK_DEF(x) static x
#endif
#endif /* FT_CALLBACK_DEF */
/* This is a generated file. */
-FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
-FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
-FT_USE_MODULE( FT_Module_Class, autofit_module_class )
-FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class )
-FT_USE_MODULE( FT_Module_Class, gxv_module_class )
-FT_USE_MODULE( FT_Module_Class, otv_module_class )
-FT_USE_MODULE( FT_Module_Class, psaux_module_class )
-FT_USE_MODULE( FT_Module_Class, psnames_module_class )
+FT_USE_MODULE(FT_Driver_ClassRec, tt_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, t1_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, cff_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, t1cid_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, pfr_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, t42_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, winfnt_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, pcf_driver_class)
+FT_USE_MODULE(FT_Driver_ClassRec, bdf_driver_class)
+FT_USE_MODULE(FT_Module_Class, sfnt_module_class)
+FT_USE_MODULE(FT_Module_Class, autofit_module_class)
+FT_USE_MODULE(FT_Module_Class, pshinter_module_class)
+FT_USE_MODULE(FT_Renderer_Class, ft_raster1_renderer_class)
+FT_USE_MODULE(FT_Renderer_Class, ft_smooth_renderer_class)
+FT_USE_MODULE(FT_Renderer_Class, ft_smooth_lcd_renderer_class)
+FT_USE_MODULE(FT_Renderer_Class, ft_smooth_lcdv_renderer_class)
+FT_USE_MODULE(FT_Module_Class, gxv_module_class)
+FT_USE_MODULE(FT_Module_Class, otv_module_class)
+FT_USE_MODULE(FT_Module_Class, psaux_module_class)
+FT_USE_MODULE(FT_Module_Class, psnames_module_class)
/* EOF */
/* Two macros are used within the FreeType source code to define */
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
/* */
- /* FT_EXPORT( return_type ) */
+ /* FT_EXPORT(return_type) */
/* */
/* is used in a function declaration, as in */
/* */
- /* FT_EXPORT( FT_Error ) */
- /* FT_Init_FreeType( FT_Library* alibrary ); */
+ /* FT_EXPORT(FT_Error) */
+ /* FT_Init_FreeType(FT_Library* alibrary); */
/* */
/* */
- /* FT_EXPORT_DEF( return_type ) */
+ /* FT_EXPORT_DEF(return_type) */
/* */
/* is used in a function definition, as in */
/* */
- /* FT_EXPORT_DEF( FT_Error ) */
- /* FT_Init_FreeType( FT_Library* alibrary ) */
+ /* FT_EXPORT_DEF(FT_Error) */
+ /* FT_Init_FreeType(FT_Library* alibrary) */
/* { */
/* ... some code ... */
/* return FT_Err_Ok; */
/* open_args.num_params = 1; */
/* open_args.params = ¶meter; */
/* */
- /* error = FT_Open_Face( library, &open_args, index, &face ); */
+ /* error = FT_Open_Face(library, &open_args, index, &face); */
/* ... */
/* } */
/* */
/* on certain platforms */
#define ft_longjmp longjmp
-#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
+#define ft_setjmp(b) setjmp(*(ft_jmp_buf*) &(b)) /* same thing here */
/* the following is only used for debugging purposes, i.e., if */
/* this: */
/* */
/* { */
- /* #define FT_ENC_TAG( value, a, b, c, d ) value */
+ /* #define FT_ENC_TAG(value, a, b, c, d) value */
/* } */
/* */
/* to get a simple enumeration without assigning special numbers. */
/* */
#ifndef FT_ENC_TAG
-#define FT_ENC_TAG( value, a, b, c, d ) \
- value = ( ( (FT_UInt32)(a) << 24 ) | \
- ( (FT_UInt32)(b) << 16 ) | \
- ( (FT_UInt32)(c) << 8 ) | \
- (FT_UInt32)(d) )
+#define FT_ENC_TAG(value, a, b, c, d) \
+ value = (((FT_UInt32)(a) << 24) | \
+ ((FT_UInt32)(b) << 16) | \
+ ((FT_UInt32)(c) << 8) | \
+ (FT_UInt32)(d) )
#endif /* FT_ENC_TAG */
/* */
typedef enum FT_Encoding_
{
- FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
+ FT_ENC_TAG(FT_ENCODING_NONE, 0, 0, 0, 0),
- FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
- FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
+ FT_ENC_TAG(FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b'),
+ FT_ENC_TAG(FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c'),
- FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
- FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ),
- FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
- FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
- FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
+ FT_ENC_TAG(FT_ENCODING_SJIS, 's', 'j', 'i', 's'),
+ FT_ENC_TAG(FT_ENCODING_GB2312, 'g', 'b', ' ', ' '),
+ FT_ENC_TAG(FT_ENCODING_BIG5, 'b', 'i', 'g', '5'),
+ FT_ENC_TAG(FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's'),
+ FT_ENC_TAG(FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a'),
/* for backwards compatibility */
FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
- FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
- FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B'),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E'),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C'),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1'),
- FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
+ FT_ENC_TAG(FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2'),
- FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
+ FT_ENC_TAG(FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n')
} FT_Encoding;
/* Set if the font has color glyph tables. To access color glyphs */
/* use @FT_LOAD_COLOR. */
/* */
-#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
-#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
-#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
-#define FT_FACE_FLAG_SFNT ( 1L << 3 )
-#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
-#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
-#define FT_FACE_FLAG_KERNING ( 1L << 6 )
-#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
-#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
-#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
-#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
-#define FT_FACE_FLAG_HINTER ( 1L << 11 )
-#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
-#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
-#define FT_FACE_FLAG_COLOR ( 1L << 14 )
+#define FT_FACE_FLAG_SCALABLE (1L << 0)
+#define FT_FACE_FLAG_FIXED_SIZES (1L << 1)
+#define FT_FACE_FLAG_FIXED_WIDTH (1L << 2)
+#define FT_FACE_FLAG_SFNT (1L << 3)
+#define FT_FACE_FLAG_HORIZONTAL (1L << 4)
+#define FT_FACE_FLAG_VERTICAL (1L << 5)
+#define FT_FACE_FLAG_KERNING (1L << 6)
+#define FT_FACE_FLAG_FAST_GLYPHS (1L << 7)
+#define FT_FACE_FLAG_MULTIPLE_MASTERS (1L << 8)
+#define FT_FACE_FLAG_GLYPH_NAMES (1L << 9)
+#define FT_FACE_FLAG_EXTERNAL_STREAM (1L << 10)
+#define FT_FACE_FLAG_HINTER (1L << 11)
+#define FT_FACE_FLAG_CID_KEYED (1L << 12)
+#define FT_FACE_FLAG_TRICKY (1L << 13)
+#define FT_FACE_FLAG_COLOR (1L << 14)
/*************************************************************************
*
* @macro:
- * FT_HAS_HORIZONTAL( face )
+ * FT_HAS_HORIZONTAL(face)
*
* @description:
* A macro that returns true whenever a face object contains
* @FT_HAS_VERTICAL can be used to check for vertical metrics.
*
*/
-#define FT_HAS_HORIZONTAL( face ) \
- ( face->face_flags & FT_FACE_FLAG_HORIZONTAL )
+#define FT_HAS_HORIZONTAL(face) \
+ (face->face_flags & FT_FACE_FLAG_HORIZONTAL)
/*************************************************************************
*
* @macro:
- * FT_HAS_VERTICAL( face )
+ * FT_HAS_VERTICAL(face)
*
* @description:
* A macro that returns true whenever a face object contains real
* vertical metrics (and not only synthesized ones).
*
*/
-#define FT_HAS_VERTICAL( face ) \
- ( face->face_flags & FT_FACE_FLAG_VERTICAL )
+#define FT_HAS_VERTICAL(face) \
+ (face->face_flags & FT_FACE_FLAG_VERTICAL)
/*************************************************************************
*
* @macro:
- * FT_HAS_KERNING( face )
+ * FT_HAS_KERNING(face)
*
* @description:
* A macro that returns true whenever a face object contains kerning
* data that can be accessed with @FT_Get_Kerning.
*
*/
-#define FT_HAS_KERNING( face ) \
- ( face->face_flags & FT_FACE_FLAG_KERNING )
+#define FT_HAS_KERNING(face) \
+ (face->face_flags & FT_FACE_FLAG_KERNING)
/*************************************************************************
*
* @macro:
- * FT_IS_SCALABLE( face )
+ * FT_IS_SCALABLE(face)
*
* @description:
* A macro that returns true whenever a face object contains a scalable
* and PFR font formats.
*
*/
-#define FT_IS_SCALABLE( face ) \
- ( face->face_flags & FT_FACE_FLAG_SCALABLE )
+#define FT_IS_SCALABLE(face) \
+ (face->face_flags & FT_FACE_FLAG_SCALABLE)
/*************************************************************************
*
* @macro:
- * FT_IS_SFNT( face )
+ * FT_IS_SFNT(face)
*
* @description:
* A macro that returns true whenever a face object contains a font
* @FT_TRUETYPE_TABLES_H are available.
*
*/
-#define FT_IS_SFNT( face ) \
- ( face->face_flags & FT_FACE_FLAG_SFNT )
+#define FT_IS_SFNT(face) \
+ (face->face_flags & FT_FACE_FLAG_SFNT)
/*************************************************************************
*
* @macro:
- * FT_IS_FIXED_WIDTH( face )
+ * FT_IS_FIXED_WIDTH(face)
*
* @description:
* A macro that returns true whenever a face object contains a font face
* glyphs.
*
*/
-#define FT_IS_FIXED_WIDTH( face ) \
- ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
+#define FT_IS_FIXED_WIDTH(face) \
+ (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
/*************************************************************************
*
* @macro:
- * FT_HAS_FIXED_SIZES( face )
+ * FT_HAS_FIXED_SIZES(face)
*
* @description:
* A macro that returns true whenever a face object contains some
* @FT_FaceRec structure.
*
*/
-#define FT_HAS_FIXED_SIZES( face ) \
- ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
+#define FT_HAS_FIXED_SIZES(face) \
+ (face->face_flags & FT_FACE_FLAG_FIXED_SIZES)
/*************************************************************************
*
* @macro:
- * FT_HAS_FAST_GLYPHS( face )
+ * FT_HAS_FAST_GLYPHS(face)
*
* @description:
* Deprecated.
*
*/
-#define FT_HAS_FAST_GLYPHS( face ) 0
+#define FT_HAS_FAST_GLYPHS(face) 0
/*************************************************************************
*
* @macro:
- * FT_HAS_GLYPH_NAMES( face )
+ * FT_HAS_GLYPH_NAMES(face)
*
* @description:
* A macro that returns true whenever a face object contains some glyph
* names that can be accessed through @FT_Get_Glyph_Name.
*
*/
-#define FT_HAS_GLYPH_NAMES( face ) \
- ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
+#define FT_HAS_GLYPH_NAMES(face) \
+ (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES)
/*************************************************************************
*
* @macro:
- * FT_HAS_MULTIPLE_MASTERS( face )
+ * FT_HAS_MULTIPLE_MASTERS(face)
*
* @description:
* A macro that returns true whenever a face object contains some
* are then available to choose the exact design you want.
*
*/
-#define FT_HAS_MULTIPLE_MASTERS( face ) \
- ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
+#define FT_HAS_MULTIPLE_MASTERS(face) \
+ (face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS)
/*************************************************************************
*
* @macro:
- * FT_IS_CID_KEYED( face )
+ * FT_IS_CID_KEYED(face)
*
* @description:
* A macro that returns true whenever a face object contains a CID-keyed
* available.
*
*/
-#define FT_IS_CID_KEYED( face ) \
- ( face->face_flags & FT_FACE_FLAG_CID_KEYED )
+#define FT_IS_CID_KEYED(face) \
+ (face->face_flags & FT_FACE_FLAG_CID_KEYED)
/*************************************************************************
*
* @macro:
- * FT_IS_TRICKY( face )
+ * FT_IS_TRICKY(face)
*
* @description:
* A macro that returns true whenever a face represents a `tricky' font.
* See the discussion of @FT_FACE_FLAG_TRICKY for more details.
*
*/
-#define FT_IS_TRICKY( face ) \
- ( face->face_flags & FT_FACE_FLAG_TRICKY )
+#define FT_IS_TRICKY(face) \
+ (face->face_flags & FT_FACE_FLAG_TRICKY)
/*************************************************************************
*
* @macro:
- * FT_HAS_COLOR( face )
+ * FT_HAS_COLOR(face)
*
* @description:
* A macro that returns true whenever a face object contains
* tables for color glyphs.
*
*/
-#define FT_HAS_COLOR( face ) \
- ( face->face_flags & FT_FACE_FLAG_COLOR )
+#define FT_HAS_COLOR(face) \
+ (face->face_flags & FT_FACE_FLAG_COLOR)
/*************************************************************************/
/* (for example, by analyzing various fields of the `OS/2' table in */
/* SFNT based fonts). */
/* */
-#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
-#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
+#define FT_STYLE_FLAG_ITALIC (1 << 0)
+#define FT_STYLE_FLAG_BOLD (1 << 1)
/*************************************************************************/
/* */
/* <load glyph with `FT_Load_Glyph'> */
/* */
- /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */
+ /* if (prev_rsb_delta - face->glyph->lsb_delta >= 32) */
/* origin_x -= 64; */
- /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */
+ /* else if (prev_rsb_delta - face->glyph->lsb_delta < -32) */
/* origin_x += 64; */
/* */
/* prev_rsb_delta = face->glyph->rsb_delta; */
/* If you need reference-counting (cf. @FT_Reference_Library), use */
/* @FT_New_Library and @FT_Done_Library. */
/* */
- FT_EXPORT( FT_Error )
- FT_Init_FreeType( FT_Library *alibrary );
+ FT_EXPORT(FT_Error)
+ FT_Init_FreeType(FT_Library *alibrary);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Done_FreeType( FT_Library library );
+ FT_EXPORT(FT_Error)
+ FT_Done_FreeType(FT_Library library);
/*************************************************************************/
/* Use @FT_Done_Face to destroy the created @FT_Face object (along */
/* with its slot and sizes). */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Face( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_New_Face(FT_Library library,
const char* filepathname,
FT_Long face_index,
- FT_Face *aface );
+ FT_Face *aface);
/*************************************************************************/
/* <Note> */
/* You must not deallocate the memory before calling @FT_Done_Face. */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Memory_Face( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_New_Memory_Face(FT_Library library,
const FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
- FT_Face *aface );
+ FT_Face *aface);
/*************************************************************************/
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Face. */
/* */
- FT_EXPORT( FT_Error )
- FT_Open_Face( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Open_Face(FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
- FT_Face *aface );
+ FT_Face *aface);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Attach_File( FT_Face face,
- const char* filepathname );
+ FT_EXPORT(FT_Error)
+ FT_Attach_File(FT_Face face,
+ const char* filepathname);
/*************************************************************************/
/* when invoking this function. Most drivers simply do not implement */
/* file attachments. */
/* */
- FT_EXPORT( FT_Error )
- FT_Attach_Stream( FT_Face face,
- FT_Open_Args* parameters );
+ FT_EXPORT(FT_Error)
+ FT_Attach_Stream(FT_Face face,
+ FT_Open_Args* parameters);
/*************************************************************************/
/* <Since> */
/* 2.4.2 */
/* */
- FT_EXPORT( FT_Error )
- FT_Reference_Face( FT_Face face );
+ FT_EXPORT(FT_Error)
+ FT_Reference_Face(FT_Face face);
/*************************************************************************/
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Face. */
/* */
- FT_EXPORT( FT_Error )
- FT_Done_Face( FT_Face face );
+ FT_EXPORT(FT_Error)
+ FT_Done_Face(FT_Face face);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Select_Size( FT_Face face,
- FT_Int strike_index );
+ FT_EXPORT(FT_Error)
+ FT_Select_Size(FT_Face face,
+ FT_Int strike_index);
/*************************************************************************/
/* glyph relative to this size. For more information refer to */
/* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */
/* */
- FT_EXPORT( FT_Error )
- FT_Request_Size( FT_Face face,
- FT_Size_Request req );
+ FT_EXPORT(FT_Error)
+ FT_Request_Size(FT_Face face,
+ FT_Size_Request req);
/*************************************************************************/
/* */
/* Don't use this function if you are using the FreeType cache API. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_Char_Size( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Set_Char_Size(FT_Face face,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
- FT_UInt vert_resolution );
+ FT_UInt vert_resolution);
/*************************************************************************/
/* constrained, to this pixel size. Refer to @FT_Request_Size to */
/* understand how requested sizes relate to actual sizes. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_Pixel_Sizes( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Set_Pixel_Sizes(FT_Face face,
FT_UInt pixel_width,
- FT_UInt pixel_height );
+ FT_UInt pixel_height);
/*************************************************************************/
/* don't have a corresponding glyph in the font). See the discussion */
/* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
/* */
- FT_EXPORT( FT_Error )
- FT_Load_Glyph( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Load_Glyph(FT_Face face,
FT_UInt glyph_index,
- FT_Int32 load_flags );
+ FT_Int32 load_flags);
/*************************************************************************/
/* <Note> */
/* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */
/* */
- FT_EXPORT( FT_Error )
- FT_Load_Char( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Load_Char(FT_Face face,
FT_ULong char_code,
- FT_Int32 load_flags );
+ FT_Int32 load_flags);
/*************************************************************************
*
*/
#define FT_LOAD_DEFAULT 0x0
-#define FT_LOAD_NO_SCALE ( 1L << 0 )
-#define FT_LOAD_NO_HINTING ( 1L << 1 )
-#define FT_LOAD_RENDER ( 1L << 2 )
-#define FT_LOAD_NO_BITMAP ( 1L << 3 )
-#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
-#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
-#define FT_LOAD_CROP_BITMAP ( 1L << 6 )
-#define FT_LOAD_PEDANTIC ( 1L << 7 )
-#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
-#define FT_LOAD_NO_RECURSE ( 1L << 10 )
-#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
-#define FT_LOAD_MONOCHROME ( 1L << 12 )
-#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
-#define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
+#define FT_LOAD_NO_SCALE (1L << 0)
+#define FT_LOAD_NO_HINTING (1L << 1)
+#define FT_LOAD_RENDER (1L << 2)
+#define FT_LOAD_NO_BITMAP (1L << 3)
+#define FT_LOAD_VERTICAL_LAYOUT (1L << 4)
+#define FT_LOAD_FORCE_AUTOHINT (1L << 5)
+#define FT_LOAD_CROP_BITMAP (1L << 6)
+#define FT_LOAD_PEDANTIC (1L << 7)
+#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH (1L << 9)
+#define FT_LOAD_NO_RECURSE (1L << 10)
+#define FT_LOAD_IGNORE_TRANSFORM (1L << 11)
+#define FT_LOAD_MONOCHROME (1L << 12)
+#define FT_LOAD_LINEAR_DESIGN (1L << 13)
+#define FT_LOAD_NO_AUTOHINT (1L << 15)
/* Bits 16..19 are used by `FT_LOAD_TARGET_' */
-#define FT_LOAD_COLOR ( 1L << 20 )
+#define FT_LOAD_COLOR (1L << 20)
/* */
/* used internally only by certain font drivers! */
-#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
-#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
+#define FT_LOAD_ADVANCE_ONLY (1L << 8)
+#define FT_LOAD_SBITS_ONLY (1L << 14)
/**************************************************************************
* pixel mode, with code like
*
* {
- * FT_Load_Glyph( face, glyph_index,
- * load_flags | FT_LOAD_TARGET_LIGHT );
+ * FT_Load_Glyph(face, glyph_index,
+ * load_flags | FT_LOAD_TARGET_LIGHT);
*
- * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
+ * FT_Render_Glyph(face->glyph, FT_RENDER_MODE_LCD);
* }
*
*/
-#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
+#define FT_LOAD_TARGET_(x) ((FT_Int32)((x) & 15) << 16)
-#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
-#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
-#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
-#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
-#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
+#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_(FT_RENDER_MODE_NORMAL)
+#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_(FT_RENDER_MODE_LIGHT)
+#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_(FT_RENDER_MODE_MONO)
+#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_(FT_RENDER_MODE_LCD)
+#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_(FT_RENDER_MODE_LCD_V)
/**************************************************************************
* @FT_LOAD_TARGET_XXX value.
*
*/
-#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
+#define FT_LOAD_TARGET_MODE(x) ((FT_Render_Mode)(((x) >> 16) & 15))
/*************************************************************************/
/* Note that this also transforms the `face.glyph.advance' field, but */
/* *not* the values in `face.glyph.metrics'. */
/* */
- FT_EXPORT( void )
- FT_Set_Transform( FT_Face face,
+ FT_EXPORT(void)
+ FT_Set_Transform(FT_Face face,
FT_Matrix* matrix,
- FT_Vector* delta );
+ FT_Vector* delta);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Render_Glyph( FT_GlyphSlot slot,
- FT_Render_Mode render_mode );
+ FT_EXPORT(FT_Error)
+ FT_Render_Glyph(FT_GlyphSlot slot,
+ FT_Render_Mode render_mode);
/*************************************************************************/
/* kernings, are out of the scope of this API function -- they can be */
/* implemented through format-specific interfaces. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Kerning( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_Kerning(FT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_UInt kern_mode,
- FT_Vector *akerning );
+ FT_Vector *akerning);
/*************************************************************************/
/* Only very few AFM files come with track kerning data; please refer */
/* to the Adobe's AFM specification for more details. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Track_Kerning( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_Track_Kerning(FT_Face face,
FT_Fixed point_size,
FT_Int degree,
- FT_Fixed* akerning );
+ FT_Fixed* akerning);
/*************************************************************************/
/* macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in */
/* `ftoptions.h'. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Glyph_Name( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_Glyph_Name(FT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
- FT_UInt buffer_max );
+ FT_UInt buffer_max);
/*************************************************************************/
/* The returned pointer is owned by the face and is destroyed with */
/* it. */
/* */
- FT_EXPORT( const char* )
- FT_Get_Postscript_Name( FT_Face face );
+ FT_EXPORT(const char*)
+ FT_Get_Postscript_Name(FT_Face face);
/*************************************************************************/
/* preferred to a UCS-2 cmap). It is thus preferable to */
/* @FT_Set_Charmap in this case. */
/* */
- FT_EXPORT( FT_Error )
- FT_Select_Charmap( FT_Face face,
- FT_Encoding encoding );
+ FT_EXPORT(FT_Error)
+ FT_Select_Charmap(FT_Face face,
+ FT_Encoding encoding);
/*************************************************************************/
/* */
/* It also fails if a type~14 charmap is selected. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_Charmap( FT_Face face,
- FT_CharMap charmap );
+ FT_EXPORT(FT_Error)
+ FT_Set_Charmap(FT_Face face,
+ FT_CharMap charmap);
/*************************************************************************
* `charmap' belongs. If an error occurs, -1 is returned.
*
*/
- FT_EXPORT( FT_Int )
- FT_Get_Charmap_Index( FT_CharMap charmap );
+ FT_EXPORT(FT_Int)
+ FT_Get_Charmap_Index(FT_CharMap charmap);
/*************************************************************************/
/* whatever was there will be moved to the last index -- Type~42 */
/* fonts are considered invalid under this condition. */
/* */
- FT_EXPORT( FT_UInt )
- FT_Get_Char_Index( FT_Face face,
- FT_ULong charcode );
+ FT_EXPORT(FT_UInt)
+ FT_Get_Char_Index(FT_Face face,
+ FT_ULong charcode);
/*************************************************************************/
/* FT_UInt gindex; */
/* */
/* */
- /* charcode = FT_Get_First_Char( face, &gindex ); */
- /* while ( gindex != 0 ) */
+ /* charcode = FT_Get_First_Char(face, &gindex); */
+ /* while (gindex != 0) */
/* { */
/* ... do something with (charcode,gindex) pair ... */
/* */
- /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
+ /* charcode = FT_Get_Next_Char(face, charcode, &gindex); */
/* } */
/* } */
/* */
/* result itself can be~0 in two cases: if the charmap is empty or */
/* if the value~0 is the first valid character code. */
/* */
- FT_EXPORT( FT_ULong )
- FT_Get_First_Char( FT_Face face,
- FT_UInt *agindex );
+ FT_EXPORT(FT_ULong)
+ FT_Get_First_Char(FT_Face face,
+ FT_UInt *agindex);
/*************************************************************************/
/* Note that `*agindex' is set to~0 when there are no more codes in */
/* the charmap. */
/* */
- FT_EXPORT( FT_ULong )
- FT_Get_Next_Char( FT_Face face,
+ FT_EXPORT(FT_ULong)
+ FT_Get_Next_Char(FT_Face face,
FT_ULong char_code,
- FT_UInt *agindex );
+ FT_UInt *agindex);
/*************************************************************************/
/* <Return> */
/* The glyph index. 0~means `undefined character code'. */
/* */
- FT_EXPORT( FT_UInt )
- FT_Get_Name_Index( FT_Face face,
- FT_String* glyph_name );
+ FT_EXPORT(FT_UInt)
+ FT_Get_Name_Index(FT_Face face,
+ FT_String* glyph_name);
/*************************************************************************
* TrueType specification for details.
*
*/
- FT_EXPORT( FT_Error )
- FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
+ FT_EXPORT(FT_Error)
+ FT_Get_SubGlyph_Info(FT_GlyphSlot glyph,
FT_UInt sub_index,
FT_Int *p_index,
FT_UInt *p_flags,
FT_Int *p_arg1,
FT_Int *p_arg2,
- FT_Matrix *p_transform );
+ FT_Matrix *p_transform);
/*************************************************************************/
/* <Since> */
/* 2.3.8 */
/* */
- FT_EXPORT( FT_UShort )
- FT_Get_FSType_Flags( FT_Face face );
+ FT_EXPORT(FT_UShort)
+ FT_Get_FSType_Flags(FT_Face face);
/*************************************************************************/
/* <Since> */
/* 2.3.6 */
/* */
- FT_EXPORT( FT_UInt )
- FT_Face_GetCharVariantIndex( FT_Face face,
+ FT_EXPORT(FT_UInt)
+ FT_Face_GetCharVariantIndex(FT_Face face,
FT_ULong charcode,
- FT_ULong variantSelector );
+ FT_ULong variantSelector);
/*************************************************************************/
/* <Since> */
/* 2.3.6 */
/* */
- FT_EXPORT( FT_Int )
- FT_Face_GetCharVariantIsDefault( FT_Face face,
+ FT_EXPORT(FT_Int)
+ FT_Face_GetCharVariantIsDefault(FT_Face face,
FT_ULong charcode,
- FT_ULong variantSelector );
+ FT_ULong variantSelector);
/*************************************************************************/
/* <Since> */
/* 2.3.6 */
/* */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetVariantSelectors( FT_Face face );
+ FT_EXPORT(FT_UInt32*)
+ FT_Face_GetVariantSelectors(FT_Face face);
/*************************************************************************/
/* <Since> */
/* 2.3.6 */
/* */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetVariantsOfChar( FT_Face face,
- FT_ULong charcode );
+ FT_EXPORT(FT_UInt32*)
+ FT_Face_GetVariantsOfChar(FT_Face face,
+ FT_ULong charcode);
/*************************************************************************/
/* <Since> */
/* 2.3.6 */
/* */
- FT_EXPORT( FT_UInt32* )
- FT_Face_GetCharsOfVariant( FT_Face face,
- FT_ULong variantSelector );
+ FT_EXPORT(FT_UInt32*)
+ FT_Face_GetCharsOfVariant(FT_Face face,
+ FT_ULong variantSelector);
/*************************************************************************/
/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
/* on the signs of `a' and `b'. */
/* */
- FT_EXPORT( FT_Long )
- FT_MulDiv( FT_Long a,
+ FT_EXPORT(FT_Long)
+ FT_MulDiv(FT_Long a,
FT_Long b,
- FT_Long c );
+ FT_Long c);
/* */
/* _second_ argument of this function; this can make a great */
/* difference. */
/* */
- FT_EXPORT( FT_Long )
- FT_MulFix( FT_Long a,
- FT_Long b );
+ FT_EXPORT(FT_Long)
+ FT_MulFix(FT_Long a,
+ FT_Long b);
/* */
#endif
#ifdef FT_MULFIX_INLINED
-#define FT_MulFix( a, b ) FT_MULFIX_INLINED( a, b )
+#define FT_MulFix(a, b) FT_MULFIX_INLINED(a, b)
#else
- FT_EXPORT( FT_Long )
- FT_MulFix( FT_Long a,
- FT_Long b );
+ FT_EXPORT(FT_Long)
+ FT_MulFix(FT_Long a,
+ FT_Long b);
#endif
/* 32~bits, then the division is computed directly. Otherwise, we */
/* use a specialized version of @FT_MulDiv. */
/* */
- FT_EXPORT( FT_Long )
- FT_DivFix( FT_Long a,
- FT_Long b );
+ FT_EXPORT(FT_Long)
+ FT_DivFix(FT_Long a,
+ FT_Long b);
/*************************************************************************/
/* <Return> */
/* The result of `(a + 0x8000) & -0x10000'. */
/* */
- FT_EXPORT( FT_Fixed )
- FT_RoundFix( FT_Fixed a );
+ FT_EXPORT(FT_Fixed)
+ FT_RoundFix(FT_Fixed a);
/*************************************************************************/
/* <Return> */
/* The result of `(a + 0x10000 - 1) & -0x10000'. */
/* */
- FT_EXPORT( FT_Fixed )
- FT_CeilFix( FT_Fixed a );
+ FT_EXPORT(FT_Fixed)
+ FT_CeilFix(FT_Fixed a);
/*************************************************************************/
/* <Return> */
/* The result of `a & -0x10000'. */
/* */
- FT_EXPORT( FT_Fixed )
- FT_FloorFix( FT_Fixed a );
+ FT_EXPORT(FT_Fixed)
+ FT_FloorFix(FT_Fixed a);
/*************************************************************************/
/* <Note> */
/* The result is undefined if either `vector' or `matrix' is invalid. */
/* */
- FT_EXPORT( void )
- FT_Vector_Transform( FT_Vector* vec,
- const FT_Matrix* matrix );
+ FT_EXPORT(void)
+ FT_Vector_Transform(FT_Vector* vec,
+ const FT_Matrix* matrix);
/*************************************************************************/
/* In such cases, the library version might not be available before */
/* the library object has been created. */
/* */
- FT_EXPORT( void )
- FT_Library_Version( FT_Library library,
+ FT_EXPORT(void)
+ FT_Library_Version(FT_Library library,
FT_Int *amajor,
FT_Int *aminor,
- FT_Int *apatch );
+ FT_Int *apatch);
/*************************************************************************/
/* <Since> */
/* 2.3.5 */
/* */
- FT_EXPORT( FT_Bool )
- FT_Face_CheckTrueTypePatents( FT_Face face );
+ FT_EXPORT(FT_Bool)
+ FT_Face_CheckTrueTypePatents(FT_Face face);
/*************************************************************************/
/* <Since> */
/* 2.3.5 */
/* */
- FT_EXPORT( FT_Bool )
- FT_Face_SetUnpatentedHinting( FT_Face face,
- FT_Bool value );
+ FT_EXPORT(FT_Bool)
+ FT_Face_SetUnpatentedHinting(FT_Face face,
+ FT_Bool value);
/* */
/* A scaled advance is returned in 16.16 format but isn't transformed */
/* by the affine transformation specified by @FT_Set_Transform. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Advance( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_Advance(FT_Face face,
FT_UInt gindex,
FT_Int32 load_flags,
- FT_Fixed *padvance );
+ FT_Fixed *padvance);
/*************************************************************************/
/* transformed by the affine transformation specified by */
/* @FT_Set_Transform. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Advances( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_Advances(FT_Face face,
FT_UInt start,
FT_UInt count,
FT_Int32 load_flags,
- FT_Fixed *padvances );
+ FT_Fixed *padvances);
/* */
* FT_Prop_GlyphToScriptMap prop;
*
*
- * FT_Init_FreeType( &library );
- * FT_New_Face( library, "foo.ttf", 0, &face );
+ * FT_Init_FreeType(&library);
+ * FT_New_Face(library, "foo.ttf", 0, &face);
*
* prop.face = face;
*
- * FT_Property_Get( library, "autofitter",
- * "glyph-to-script-map", &prop );
+ * FT_Property_Get(library, "autofitter",
+ * "glyph-to-script-map", &prop);
*
* // adjust `prop.map' as needed right here
*
- * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
+ * FT_Load_Glyph(face, ..., FT_LOAD_FORCE_AUTOHINT);
* }
*
*/
* FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
*
*
- * FT_Init_FreeType( &library );
+ * FT_Init_FreeType(&library);
*
- * FT_Property_Set( library, "autofitter",
- * "fallback-script", &fallback_script );
+ * FT_Property_Set(library, "autofitter",
+ * "fallback-script", &fallback_script);
* }
*
* @note:
* FT_Prop_IncreaseXHeight prop;
*
*
- * FT_Init_FreeType( &library );
- * FT_New_Face( library, "foo.ttf", 0, &face );
- * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
+ * FT_Init_FreeType(&library);
+ * FT_New_Face(library, "foo.ttf", 0, &face);
+ * FT_Set_Char_Size(face, 10 * 64, 0, 72, 0);
*
* prop.face = face;
* prop.limit = 14;
*
- * FT_Property_Set( library, "autofitter",
- * "increase-x-height", &prop );
+ * FT_Property_Set(library, "autofitter",
+ * "increase-x-height", &prop);
* }
*
* @note:
/* properly shift and scale the subglyphs), then extracting the BBox, */
/* which can be eventually converted back to font units. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Get_BBox( FT_Outline* outline,
- FT_BBox *abbox );
+ FT_EXPORT(FT_Error)
+ FT_Outline_Get_BBox(FT_Outline* outline,
+ FT_BBox *abbox);
/* */
* @note:
* This function only works with BDF faces, returning an error otherwise.
*/
- FT_EXPORT( FT_Error )
- FT_Get_BDF_Charset_ID( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_BDF_Charset_ID(FT_Face face,
const char* *acharset_encoding,
- const char* *acharset_registry );
+ const char* *acharset_registry);
/**********************************************************************
* In case of error, `aproperty->type' is always set to
* @BDF_PROPERTY_TYPE_NONE.
*/
- FT_EXPORT( FT_Error )
- FT_Get_BDF_Property( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_BDF_Property(FT_Face face,
const char* prop_name,
- BDF_PropertyRec *aproperty );
+ BDF_PropertyRec *aproperty);
/* */
/* <InOut> */
/* abitmap :: A pointer to the bitmap structure. */
/* */
- FT_EXPORT( void )
- FT_Bitmap_New( FT_Bitmap *abitmap );
+ FT_EXPORT(void)
+ FT_Bitmap_New(FT_Bitmap *abitmap);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Copy( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Bitmap_Copy(FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target);
/* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */
/* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */
/* */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Embolden( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Bitmap_Embolden(FT_Library library,
FT_Bitmap* bitmap,
FT_Pos xStrength,
- FT_Pos yStrength );
+ FT_Pos yStrength);
/*************************************************************************/
/* The `library' argument is taken to have access to FreeType's */
/* memory handling functions. */
/* */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Convert( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Bitmap_Convert(FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target,
- FT_Int alignment );
+ FT_Int alignment);
/*************************************************************************/
/* This function is to be used in combination with */
/* @FT_Bitmap_Embolden. */
/* */
- FT_EXPORT( FT_Error )
- FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
+ FT_EXPORT(FT_Error)
+ FT_GlyphSlot_Own_Bitmap(FT_GlyphSlot slot);
/*************************************************************************/
/* The `library' argument is taken to have access to FreeType's */
/* memory handling functions. */
/* */
- FT_EXPORT( FT_Error )
- FT_Bitmap_Done( FT_Library library,
- FT_Bitmap *bitmap );
+ FT_EXPORT(FT_Error)
+ FT_Bitmap_Done(FT_Library library,
+ FT_Bitmap *bitmap);
/* */
* This function may return `FT_Err_Unimplemented_Feature' if your build
* of FreeType was not compiled with bzip2 support.
*/
- FT_EXPORT( FT_Error )
- FT_Stream_OpenBzip2( FT_Stream stream,
- FT_Stream source );
+ FT_EXPORT(FT_Error)
+ FT_Stream_OpenBzip2(FT_Stream stream,
+ FT_Stream source);
/* */
* transformation through @FT_Set_Transform!
*/
typedef FT_Error
- (*FTC_Face_Requester)( FTC_FaceID face_id,
+ (*FTC_Face_Requester)(FTC_FaceID face_id,
FT_Library library,
FT_Pointer request_data,
- FT_Face* aface );
+ FT_Face* aface);
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FTC_Manager_New( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FTC_Manager_New(FT_Library library,
FT_UInt max_faces,
FT_UInt max_sizes,
FT_ULong max_bytes,
FTC_Face_Requester requester,
FT_Pointer req_data,
- FTC_Manager *amanager );
+ FTC_Manager *amanager);
/*************************************************************************/
/* <InOut> */
/* manager :: A handle to the manager. */
/* */
- FT_EXPORT( void )
- FTC_Manager_Reset( FTC_Manager manager );
+ FT_EXPORT(void)
+ FTC_Manager_Reset(FTC_Manager manager);
/*************************************************************************/
/* <Input> */
/* manager :: A handle to the target cache manager object. */
/* */
- FT_EXPORT( void )
- FTC_Manager_Done( FTC_Manager manager );
+ FT_EXPORT(void)
+ FTC_Manager_Done(FTC_Manager manager);
/*************************************************************************/
/* already been completely flushed, and still no memory was available */
/* for the operation. */
/* */
- FT_EXPORT( FT_Error )
- FTC_Manager_LookupFace( FTC_Manager manager,
+ FT_EXPORT(FT_Error)
+ FTC_Manager_LookupFace(FTC_Manager manager,
FTC_FaceID face_id,
- FT_Face *aface );
+ FT_Face *aface);
/*************************************************************************/
/* already been completely flushed, and still no memory is available */
/* for the operation. */
/* */
- FT_EXPORT( FT_Error )
- FTC_Manager_LookupSize( FTC_Manager manager,
+ FT_EXPORT(FT_Error)
+ FTC_Manager_LookupSize(FTC_Manager manager,
FTC_Scaler scaler,
- FT_Size *asize );
+ FT_Size *asize);
/*************************************************************************/
/* */
/* manager :: The cache manager handle. */
/* */
- FT_EXPORT( void )
- FTC_Node_Unref( FTC_Node node,
- FTC_Manager manager );
+ FT_EXPORT(void)
+ FTC_Node_Unref(FTC_Node node,
+ FTC_Manager manager);
/*************************************************************************
* destroyed when released by all their users.
*
*/
- FT_EXPORT( void )
- FTC_Manager_RemoveFaceID( FTC_Manager manager,
- FTC_FaceID face_id );
+ FT_EXPORT(void)
+ FTC_Manager_RemoveFaceID(FTC_Manager manager,
+ FTC_FaceID face_id);
/*************************************************************************/
* manager.
*
*/
- FT_EXPORT( FT_Error )
- FTC_CMapCache_New( FTC_Manager manager,
- FTC_CMapCache *acache );
+ FT_EXPORT(FT_Error)
+ FTC_CMapCache_New(FTC_Manager manager,
+ FTC_CMapCache *acache);
/************************************************************************
* Glyph index. 0~means `no glyph'.
*
*/
- FT_EXPORT( FT_UInt )
- FTC_CMapCache_Lookup( FTC_CMapCache cache,
+ FT_EXPORT(FT_UInt)
+ FTC_CMapCache_Lookup(FTC_CMapCache cache,
FTC_FaceID face_id,
FT_Int cmap_index,
- FT_UInt32 char_code );
+ FT_UInt32 char_code);
/*************************************************************************/
/* */
-#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
- ( (d1)->face_id == (d2)->face_id && \
+#define FTC_IMAGE_TYPE_COMPARE(d1, d2) \
+ ((d1)->face_id == (d2)->face_id && \
(d1)->width == (d2)->width && \
- (d1)->flags == (d2)->flags )
+ (d1)->flags == (d2)->flags)
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FTC_ImageCache_New( FTC_Manager manager,
- FTC_ImageCache *acache );
+ FT_EXPORT(FT_Error)
+ FTC_ImageCache_New(FTC_Manager manager,
+ FTC_ImageCache *acache);
/*************************************************************************/
/* call to one of the caching sub-system APIs. Don't assume that it */
/* is persistent! */
/* */
- FT_EXPORT( FT_Error )
- FTC_ImageCache_Lookup( FTC_ImageCache cache,
+ FT_EXPORT(FT_Error)
+ FTC_ImageCache_Lookup(FTC_ImageCache cache,
FTC_ImageType type,
FT_UInt gindex,
FT_Glyph *aglyph,
- FTC_Node *anode );
+ FTC_Node *anode);
/*************************************************************************/
/* Calls to @FT_Set_Char_Size and friends have no effect on cached */
/* glyphs; you should always use the FreeType cache API instead. */
/* */
- FT_EXPORT( FT_Error )
- FTC_ImageCache_LookupScaler( FTC_ImageCache cache,
+ FT_EXPORT(FT_Error)
+ FTC_ImageCache_LookupScaler(FTC_ImageCache cache,
FTC_Scaler scaler,
FT_ULong load_flags,
FT_UInt gindex,
FT_Glyph *aglyph,
- FTC_Node *anode );
+ FTC_Node *anode);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FTC_SBitCache_New( FTC_Manager manager,
- FTC_SBitCache *acache );
+ FT_EXPORT(FT_Error)
+ FTC_SBitCache_New(FTC_Manager manager,
+ FTC_SBitCache *acache);
/*************************************************************************/
/* call to one of the caching sub-system APIs. Don't assume that it */
/* is persistent! */
/* */
- FT_EXPORT( FT_Error )
- FTC_SBitCache_Lookup( FTC_SBitCache cache,
+ FT_EXPORT(FT_Error)
+ FTC_SBitCache_Lookup(FTC_SBitCache cache,
FTC_ImageType type,
FT_UInt gindex,
FTC_SBit *sbit,
- FTC_Node *anode );
+ FTC_Node *anode);
/*************************************************************************/
/* call to one of the caching sub-system APIs. Don't assume that it */
/* is persistent! */
/* */
- FT_EXPORT( FT_Error )
- FTC_SBitCache_LookupScaler( FTC_SBitCache cache,
+ FT_EXPORT(FT_Error)
+ FTC_SBitCache_LookupScaler(FTC_SBitCache cache,
FTC_Scaler scaler,
FT_ULong load_flags,
FT_UInt gindex,
FTC_SBit *sbit,
- FTC_Node *anode );
+ FTC_Node *anode);
/* */
* FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE;
*
*
- * FT_Init_FreeType( &library );
+ * FT_Init_FreeType(&library);
*
- * FT_Property_Set( library, "cff",
- * "hinting-engine", &hinting_engine );
+ * FT_Property_Set(library, "cff",
+ * "hinting-engine", &hinting_engine);
* }
*
* @note:
* FT_Bool no_stem_darkening = TRUE;
*
*
- * FT_Init_FreeType( &library );
+ * FT_Init_FreeType(&library);
*
- * FT_Property_Set( library, "cff",
- * "no-stem-darkening", &no_stem_darkening );
+ * FT_Property_Set(library, "cff",
+ * "no-stem-darkening", &no_stem_darkening);
* }
*
* @note:
* 2000, 0 }; // x4, y4
*
*
- * FT_Init_FreeType( &library );
+ * FT_Init_FreeType(&library);
*
- * FT_Property_Set( library, "cff",
- * "darkening-parameters", darken_params );
+ * FT_Property_Set(library, "cff",
+ * "darkening-parameters", darken_params);
* }
*
* The x~values give the stem width, and the y~values the darkening
* @since:
* 2.3.6
*/
- FT_EXPORT( FT_Error )
- FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_CID_Registry_Ordering_Supplement(FT_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement);
* @since:
* 2.3.9
*/
- FT_EXPORT( FT_Error )
- FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
- FT_Bool *is_cid );
+ FT_EXPORT(FT_Error)
+ FT_Get_CID_Is_Internally_CID_Keyed(FT_Face face,
+ FT_Bool *is_cid);
/**********************************************************************
* @since:
* 2.3.9
*/
- FT_EXPORT( FT_Error )
- FT_Get_CID_From_Glyph_Index( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_CID_From_Glyph_Index(FT_Face face,
FT_UInt glyph_index,
- FT_UInt *cid );
+ FT_UInt *cid);
/* */
/* generic errors */
- FT_NOERRORDEF_( Ok, 0x00, \
- "no error" )
-
- FT_ERRORDEF_( Cannot_Open_Resource, 0x01, \
- "cannot open resource" )
- FT_ERRORDEF_( Unknown_File_Format, 0x02, \
- "unknown file format" )
- FT_ERRORDEF_( Invalid_File_Format, 0x03, \
- "broken file" )
- FT_ERRORDEF_( Invalid_Version, 0x04, \
- "invalid FreeType version" )
- FT_ERRORDEF_( Lower_Module_Version, 0x05, \
- "module version is too low" )
- FT_ERRORDEF_( Invalid_Argument, 0x06, \
- "invalid argument" )
- FT_ERRORDEF_( Unimplemented_Feature, 0x07, \
- "unimplemented feature" )
- FT_ERRORDEF_( Invalid_Table, 0x08, \
- "broken table" )
- FT_ERRORDEF_( Invalid_Offset, 0x09, \
- "broken offset within table" )
- FT_ERRORDEF_( Array_Too_Large, 0x0A, \
- "array allocation size too large" )
- FT_ERRORDEF_( Missing_Module, 0x0B, \
- "missing module" )
- FT_ERRORDEF_( Missing_Property, 0x0C, \
- "missing property" )
+ FT_NOERRORDEF_(Ok, 0x00, \
+ "no error")
+
+ FT_ERRORDEF_(Cannot_Open_Resource, 0x01, \
+ "cannot open resource")
+ FT_ERRORDEF_(Unknown_File_Format, 0x02, \
+ "unknown file format")
+ FT_ERRORDEF_(Invalid_File_Format, 0x03, \
+ "broken file")
+ FT_ERRORDEF_(Invalid_Version, 0x04, \
+ "invalid FreeType version")
+ FT_ERRORDEF_(Lower_Module_Version, 0x05, \
+ "module version is too low")
+ FT_ERRORDEF_(Invalid_Argument, 0x06, \
+ "invalid argument")
+ FT_ERRORDEF_(Unimplemented_Feature, 0x07, \
+ "unimplemented feature")
+ FT_ERRORDEF_(Invalid_Table, 0x08, \
+ "broken table")
+ FT_ERRORDEF_(Invalid_Offset, 0x09, \
+ "broken offset within table")
+ FT_ERRORDEF_(Array_Too_Large, 0x0A, \
+ "array allocation size too large")
+ FT_ERRORDEF_(Missing_Module, 0x0B, \
+ "missing module")
+ FT_ERRORDEF_(Missing_Property, 0x0C, \
+ "missing property")
/* glyph/character errors */
- FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, \
- "invalid glyph index" )
- FT_ERRORDEF_( Invalid_Character_Code, 0x11, \
- "invalid character code" )
- FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, \
- "unsupported glyph image format" )
- FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, \
- "cannot render this glyph format" )
- FT_ERRORDEF_( Invalid_Outline, 0x14, \
- "invalid outline" )
- FT_ERRORDEF_( Invalid_Composite, 0x15, \
- "invalid composite glyph" )
- FT_ERRORDEF_( Too_Many_Hints, 0x16, \
- "too many hints" )
- FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, \
- "invalid pixel size" )
+ FT_ERRORDEF_(Invalid_Glyph_Index, 0x10, \
+ "invalid glyph index")
+ FT_ERRORDEF_(Invalid_Character_Code, 0x11, \
+ "invalid character code")
+ FT_ERRORDEF_(Invalid_Glyph_Format, 0x12, \
+ "unsupported glyph image format")
+ FT_ERRORDEF_(Cannot_Render_Glyph, 0x13, \
+ "cannot render this glyph format")
+ FT_ERRORDEF_(Invalid_Outline, 0x14, \
+ "invalid outline")
+ FT_ERRORDEF_(Invalid_Composite, 0x15, \
+ "invalid composite glyph")
+ FT_ERRORDEF_(Too_Many_Hints, 0x16, \
+ "too many hints")
+ FT_ERRORDEF_(Invalid_Pixel_Size, 0x17, \
+ "invalid pixel size")
/* handle errors */
- FT_ERRORDEF_( Invalid_Handle, 0x20, \
- "invalid object handle" )
- FT_ERRORDEF_( Invalid_Library_Handle, 0x21, \
- "invalid library handle" )
- FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, \
- "invalid module handle" )
- FT_ERRORDEF_( Invalid_Face_Handle, 0x23, \
- "invalid face handle" )
- FT_ERRORDEF_( Invalid_Size_Handle, 0x24, \
- "invalid size handle" )
- FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, \
- "invalid glyph slot handle" )
- FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, \
- "invalid charmap handle" )
- FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, \
- "invalid cache manager handle" )
- FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, \
- "invalid stream handle" )
+ FT_ERRORDEF_(Invalid_Handle, 0x20, \
+ "invalid object handle")
+ FT_ERRORDEF_(Invalid_Library_Handle, 0x21, \
+ "invalid library handle")
+ FT_ERRORDEF_(Invalid_Driver_Handle, 0x22, \
+ "invalid module handle")
+ FT_ERRORDEF_(Invalid_Face_Handle, 0x23, \
+ "invalid face handle")
+ FT_ERRORDEF_(Invalid_Size_Handle, 0x24, \
+ "invalid size handle")
+ FT_ERRORDEF_(Invalid_Slot_Handle, 0x25, \
+ "invalid glyph slot handle")
+ FT_ERRORDEF_(Invalid_CharMap_Handle, 0x26, \
+ "invalid charmap handle")
+ FT_ERRORDEF_(Invalid_Cache_Handle, 0x27, \
+ "invalid cache manager handle")
+ FT_ERRORDEF_(Invalid_Stream_Handle, 0x28, \
+ "invalid stream handle")
/* driver errors */
- FT_ERRORDEF_( Too_Many_Drivers, 0x30, \
- "too many modules" )
- FT_ERRORDEF_( Too_Many_Extensions, 0x31, \
- "too many extensions" )
+ FT_ERRORDEF_(Too_Many_Drivers, 0x30, \
+ "too many modules")
+ FT_ERRORDEF_(Too_Many_Extensions, 0x31, \
+ "too many extensions")
/* memory errors */
- FT_ERRORDEF_( Out_Of_Memory, 0x40, \
- "out of memory" )
- FT_ERRORDEF_( Unlisted_Object, 0x41, \
- "unlisted object" )
+ FT_ERRORDEF_(Out_Of_Memory, 0x40, \
+ "out of memory")
+ FT_ERRORDEF_(Unlisted_Object, 0x41, \
+ "unlisted object")
/* stream errors */
- FT_ERRORDEF_( Cannot_Open_Stream, 0x51, \
- "cannot open stream" )
- FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, \
- "invalid stream seek" )
- FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, \
- "invalid stream skip" )
- FT_ERRORDEF_( Invalid_Stream_Read, 0x54, \
- "invalid stream read" )
- FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, \
- "invalid stream operation" )
- FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, \
- "invalid frame operation" )
- FT_ERRORDEF_( Nested_Frame_Access, 0x57, \
- "nested frame access" )
- FT_ERRORDEF_( Invalid_Frame_Read, 0x58, \
- "invalid frame read" )
+ FT_ERRORDEF_(Cannot_Open_Stream, 0x51, \
+ "cannot open stream")
+ FT_ERRORDEF_(Invalid_Stream_Seek, 0x52, \
+ "invalid stream seek")
+ FT_ERRORDEF_(Invalid_Stream_Skip, 0x53, \
+ "invalid stream skip")
+ FT_ERRORDEF_(Invalid_Stream_Read, 0x54, \
+ "invalid stream read")
+ FT_ERRORDEF_(Invalid_Stream_Operation, 0x55, \
+ "invalid stream operation")
+ FT_ERRORDEF_(Invalid_Frame_Operation, 0x56, \
+ "invalid frame operation")
+ FT_ERRORDEF_(Nested_Frame_Access, 0x57, \
+ "nested frame access")
+ FT_ERRORDEF_(Invalid_Frame_Read, 0x58, \
+ "invalid frame read")
/* raster errors */
- FT_ERRORDEF_( Raster_Uninitialized, 0x60, \
- "raster uninitialized" )
- FT_ERRORDEF_( Raster_Corrupted, 0x61, \
- "raster corrupted" )
- FT_ERRORDEF_( Raster_Overflow, 0x62, \
- "raster overflow" )
- FT_ERRORDEF_( Raster_Negative_Height, 0x63, \
- "negative height while rastering" )
+ FT_ERRORDEF_(Raster_Uninitialized, 0x60, \
+ "raster uninitialized")
+ FT_ERRORDEF_(Raster_Corrupted, 0x61, \
+ "raster corrupted")
+ FT_ERRORDEF_(Raster_Overflow, 0x62, \
+ "raster overflow")
+ FT_ERRORDEF_(Raster_Negative_Height, 0x63, \
+ "negative height while rastering")
/* cache errors */
- FT_ERRORDEF_( Too_Many_Caches, 0x70, \
- "too many registered caches" )
+ FT_ERRORDEF_(Too_Many_Caches, 0x70, \
+ "too many registered caches")
/* TrueType and SFNT errors */
- FT_ERRORDEF_( Invalid_Opcode, 0x80, \
- "invalid opcode" )
- FT_ERRORDEF_( Too_Few_Arguments, 0x81, \
- "too few arguments" )
- FT_ERRORDEF_( Stack_Overflow, 0x82, \
- "stack overflow" )
- FT_ERRORDEF_( Code_Overflow, 0x83, \
- "code overflow" )
- FT_ERRORDEF_( Bad_Argument, 0x84, \
- "bad argument" )
- FT_ERRORDEF_( Divide_By_Zero, 0x85, \
- "division by zero" )
- FT_ERRORDEF_( Invalid_Reference, 0x86, \
- "invalid reference" )
- FT_ERRORDEF_( Debug_OpCode, 0x87, \
- "found debug opcode" )
- FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, \
- "found ENDF opcode in execution stream" )
- FT_ERRORDEF_( Nested_DEFS, 0x89, \
- "nested DEFS" )
- FT_ERRORDEF_( Invalid_CodeRange, 0x8A, \
- "invalid code range" )
- FT_ERRORDEF_( Execution_Too_Long, 0x8B, \
- "execution context too long" )
- FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, \
- "too many function definitions" )
- FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, \
- "too many instruction definitions" )
- FT_ERRORDEF_( Table_Missing, 0x8E, \
- "SFNT font table missing" )
- FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, \
- "horizontal header (hhea) table missing" )
- FT_ERRORDEF_( Locations_Missing, 0x90, \
- "locations (loca) table missing" )
- FT_ERRORDEF_( Name_Table_Missing, 0x91, \
- "name table missing" )
- FT_ERRORDEF_( CMap_Table_Missing, 0x92, \
- "character map (cmap) table missing" )
- FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, \
- "horizontal metrics (hmtx) table missing" )
- FT_ERRORDEF_( Post_Table_Missing, 0x94, \
- "PostScript (post) table missing" )
- FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, \
- "invalid horizontal metrics" )
- FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, \
- "invalid character map (cmap) format" )
- FT_ERRORDEF_( Invalid_PPem, 0x97, \
- "invalid ppem value" )
- FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, \
- "invalid vertical metrics" )
- FT_ERRORDEF_( Could_Not_Find_Context, 0x99, \
- "could not find context" )
- FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, \
- "invalid PostScript (post) table format" )
- FT_ERRORDEF_( Invalid_Post_Table, 0x9B, \
- "invalid PostScript (post) table" )
+ FT_ERRORDEF_(Invalid_Opcode, 0x80, \
+ "invalid opcode")
+ FT_ERRORDEF_(Too_Few_Arguments, 0x81, \
+ "too few arguments")
+ FT_ERRORDEF_(Stack_Overflow, 0x82, \
+ "stack overflow")
+ FT_ERRORDEF_(Code_Overflow, 0x83, \
+ "code overflow")
+ FT_ERRORDEF_(Bad_Argument, 0x84, \
+ "bad argument")
+ FT_ERRORDEF_(Divide_By_Zero, 0x85, \
+ "division by zero")
+ FT_ERRORDEF_(Invalid_Reference, 0x86, \
+ "invalid reference")
+ FT_ERRORDEF_(Debug_OpCode, 0x87, \
+ "found debug opcode")
+ FT_ERRORDEF_(ENDF_In_Exec_Stream, 0x88, \
+ "found ENDF opcode in execution stream")
+ FT_ERRORDEF_(Nested_DEFS, 0x89, \
+ "nested DEFS")
+ FT_ERRORDEF_(Invalid_CodeRange, 0x8A, \
+ "invalid code range")
+ FT_ERRORDEF_(Execution_Too_Long, 0x8B, \
+ "execution context too long")
+ FT_ERRORDEF_(Too_Many_Function_Defs, 0x8C, \
+ "too many function definitions")
+ FT_ERRORDEF_(Too_Many_Instruction_Defs, 0x8D, \
+ "too many instruction definitions")
+ FT_ERRORDEF_(Table_Missing, 0x8E, \
+ "SFNT font table missing")
+ FT_ERRORDEF_(Horiz_Header_Missing, 0x8F, \
+ "horizontal header (hhea) table missing")
+ FT_ERRORDEF_(Locations_Missing, 0x90, \
+ "locations (loca) table missing")
+ FT_ERRORDEF_(Name_Table_Missing, 0x91, \
+ "name table missing")
+ FT_ERRORDEF_(CMap_Table_Missing, 0x92, \
+ "character map (cmap) table missing")
+ FT_ERRORDEF_(Hmtx_Table_Missing, 0x93, \
+ "horizontal metrics (hmtx) table missing")
+ FT_ERRORDEF_(Post_Table_Missing, 0x94, \
+ "PostScript (post) table missing")
+ FT_ERRORDEF_(Invalid_Horiz_Metrics, 0x95, \
+ "invalid horizontal metrics")
+ FT_ERRORDEF_(Invalid_CharMap_Format, 0x96, \
+ "invalid character map (cmap) format")
+ FT_ERRORDEF_(Invalid_PPem, 0x97, \
+ "invalid ppem value")
+ FT_ERRORDEF_(Invalid_Vert_Metrics, 0x98, \
+ "invalid vertical metrics")
+ FT_ERRORDEF_(Could_Not_Find_Context, 0x99, \
+ "could not find context")
+ FT_ERRORDEF_(Invalid_Post_Table_Format, 0x9A, \
+ "invalid PostScript (post) table format")
+ FT_ERRORDEF_(Invalid_Post_Table, 0x9B, \
+ "invalid PostScript (post) table")
/* CFF, CID, and Type 1 errors */
- FT_ERRORDEF_( Syntax_Error, 0xA0, \
- "opcode syntax error" )
- FT_ERRORDEF_( Stack_Underflow, 0xA1, \
- "argument stack underflow" )
- FT_ERRORDEF_( Ignore, 0xA2, \
- "ignore" )
- FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, \
- "no Unicode glyph name found" )
- FT_ERRORDEF_( Glyph_Too_Big, 0xA4, \
- "glyph to big for hinting" )
+ FT_ERRORDEF_(Syntax_Error, 0xA0, \
+ "opcode syntax error")
+ FT_ERRORDEF_(Stack_Underflow, 0xA1, \
+ "argument stack underflow")
+ FT_ERRORDEF_(Ignore, 0xA2, \
+ "ignore")
+ FT_ERRORDEF_(No_Unicode_Glyph_Name, 0xA3, \
+ "no Unicode glyph name found")
+ FT_ERRORDEF_(Glyph_Too_Big, 0xA4, \
+ "glyph to big for hinting")
/* BDF errors */
- FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, \
- "`STARTFONT' field missing" )
- FT_ERRORDEF_( Missing_Font_Field, 0xB1, \
- "`FONT' field missing" )
- FT_ERRORDEF_( Missing_Size_Field, 0xB2, \
- "`SIZE' field missing" )
- FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \
- "`FONTBOUNDINGBOX' field missing" )
- FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \
- "`CHARS' field missing" )
- FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \
- "`STARTCHAR' field missing" )
- FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \
- "`ENCODING' field missing" )
- FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \
- "`BBX' field missing" )
- FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \
- "`BBX' too big" )
- FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \
- "Font header corrupted or missing fields" )
- FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \
- "Font glyphs corrupted or missing fields" )
+ FT_ERRORDEF_(Missing_Startfont_Field, 0xB0, \
+ "`STARTFONT' field missing")
+ FT_ERRORDEF_(Missing_Font_Field, 0xB1, \
+ "`FONT' field missing")
+ FT_ERRORDEF_(Missing_Size_Field, 0xB2, \
+ "`SIZE' field missing")
+ FT_ERRORDEF_(Missing_Fontboundingbox_Field, 0xB3, \
+ "`FONTBOUNDINGBOX' field missing")
+ FT_ERRORDEF_(Missing_Chars_Field, 0xB4, \
+ "`CHARS' field missing")
+ FT_ERRORDEF_(Missing_Startchar_Field, 0xB5, \
+ "`STARTCHAR' field missing")
+ FT_ERRORDEF_(Missing_Encoding_Field, 0xB6, \
+ "`ENCODING' field missing")
+ FT_ERRORDEF_(Missing_Bbx_Field, 0xB7, \
+ "`BBX' field missing")
+ FT_ERRORDEF_(Bbx_Too_Big, 0xB8, \
+ "`BBX' too big")
+ FT_ERRORDEF_(Corrupted_Font_Header, 0xB9, \
+ "Font header corrupted or missing fields")
+ FT_ERRORDEF_(Corrupted_Font_Glyphs, 0xBA, \
+ "Font glyphs corrupted or missing fields")
/* END */
/* the error list. It is followed by several FT_ERROR_DEF calls */
/* (see below). */
/* */
- /* FT_ERROR_DEF( e, v, s ) :: */
+ /* FT_ERROR_DEF(e, v, s) :: */
/* This macro is called to define one single error. */
/* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */
/* `v' is the error numerical value. */
/* */
/* { */
/* #undef __FTERRORS_H__ */
- /* #define FT_ERRORDEF( e, v, s ) { e, s }, */
+ /* #define FT_ERRORDEF(e, v, s) { e, s }, */
/* #define FT_ERROR_START_LIST { */
/* #define FT_ERROR_END_LIST { 0, 0 } }; */
/* */
/* */
#ifndef FT_ERRORDEF
-#define FT_ERRORDEF( e, v, s ) e = v,
+#define FT_ERRORDEF(e, v, s) e = v,
#define FT_ERROR_START_LIST enum {
-#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
+#define FT_ERROR_END_LIST FT_ERR_CAT(FT_ERR_PREFIX, Max) };
#ifdef __cplusplus
#define FT_NEED_EXTERN_C
/* this macro is used to define an error */
-#define FT_ERRORDEF_( e, v, s ) \
- FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
+#define FT_ERRORDEF_(e, v, s) \
+ FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v + FT_ERR_BASE, s)
/* this is only used for <module>_Err_Ok, which must be 0! */
-#define FT_NOERRORDEF_( e, v, s ) \
- FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
+#define FT_NOERRORDEF_(e, v, s) \
+ FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v, s)
#ifdef FT_ERROR_START_LIST
* @since:
* 2.3.0
*/
- FT_EXPORT( FT_Int )
- FT_Get_Gasp( FT_Face face,
- FT_UInt ppem );
+ FT_EXPORT(FT_Int)
+ FT_Get_Gasp(FT_Face face,
+ FT_UInt ppem);
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Glyph( FT_GlyphSlot slot,
- FT_Glyph *aglyph );
+ FT_EXPORT(FT_Error)
+ FT_Get_Glyph(FT_GlyphSlot slot,
+ FT_Glyph *aglyph);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Glyph_Copy( FT_Glyph source,
- FT_Glyph *target );
+ FT_EXPORT(FT_Error)
+ FT_Glyph_Copy(FT_Glyph source,
+ FT_Glyph *target);
/*************************************************************************/
/* The 2x2 transformation matrix is also applied to the glyph's */
/* advance vector. */
/* */
- FT_EXPORT( FT_Error )
- FT_Glyph_Transform( FT_Glyph glyph,
+ FT_EXPORT(FT_Error)
+ FT_Glyph_Transform(FT_Glyph glyph,
FT_Matrix* matrix,
- FT_Vector* delta );
+ FT_Vector* delta);
/*************************************************************************/
/* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */
/* to @FT_GLYPH_BBOX_PIXELS. */
/* */
- FT_EXPORT( void )
- FT_Glyph_Get_CBox( FT_Glyph glyph,
+ FT_EXPORT(void)
+ FT_Glyph_Get_CBox(FT_Glyph glyph,
FT_UInt bbox_mode,
- FT_BBox *acbox );
+ FT_BBox *acbox);
/*************************************************************************/
/* */
/* */
/* // load glyph */
- /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */
+ /* error = FT_Load_Char(face, glyph_index, FT_LOAD_DEFAUT); */
/* */
/* // extract glyph image */
- /* error = FT_Get_Glyph( face->glyph, &glyph ); */
+ /* error = FT_Get_Glyph(face->glyph, &glyph); */
/* */
/* // convert to a bitmap (default render mode + destroying old) */
- /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */
+ /* if (glyph->format != FT_GLYPH_FORMAT_BITMAP) */
/* { */
- /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */
- /* 0, 1 ); */
- /* if ( error ) // `glyph' unchanged */
+ /* error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, */
+ /* 0, 1); */
+ /* if (error) // `glyph' unchanged */
/* ... */
/* } */
/* */
/* ... */
/* */
/* // discard glyph image (bitmap or not) */
- /* FT_Done_Glyph( glyph ); */
+ /* FT_Done_Glyph(glyph); */
/* } */
/* */
/* */
/* */
/* ... */
/* */
- /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
- /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */
- /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */
+ /* for (idx = 0; i < MAX_GLYPHS; i++) */
+ /* error = FT_Load_Glyph(face, idx, FT_LOAD_DEFAULT) || */
+ /* FT_Get_Glyph (face->glyph, &glyph[idx]); */
/* */
/* ... */
/* */
- /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
+ /* for (idx = 0; i < MAX_GLYPHS; i++) */
/* { */
/* FT_Glyph bitmap = glyphs[idx]; */
/* */
/* */
/* // after this call, `bitmap' no longer points into */
/* // the `glyphs' array (and the old value isn't destroyed) */
- /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */
+ /* FT_Glyph_To_Bitmap(&bitmap, FT_RENDER_MODE_MONO, 0, 0); */
/* */
/* ... */
/* */
- /* FT_Done_Glyph( bitmap ); */
+ /* FT_Done_Glyph(bitmap); */
/* } */
/* */
/* ... */
/* */
- /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
- /* FT_Done_Glyph( glyphs[idx] ); */
+ /* for (idx = 0; i < MAX_GLYPHS; i++) */
+ /* FT_Done_Glyph(glyphs[idx]); */
/* } */
/* */
- FT_EXPORT( FT_Error )
- FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
+ FT_EXPORT(FT_Error)
+ FT_Glyph_To_Bitmap(FT_Glyph* the_glyph,
FT_Render_Mode render_mode,
FT_Vector* origin,
- FT_Bool destroy );
+ FT_Bool destroy);
/*************************************************************************/
/* <Input> */
/* glyph :: A handle to the target glyph object. */
/* */
- FT_EXPORT( void )
- FT_Done_Glyph( FT_Glyph glyph );
+ FT_EXPORT(void)
+ FT_Done_Glyph(FT_Glyph glyph);
/* */
/* <Note> */
/* The result is undefined if either `a' or `b' is zero. */
/* */
- FT_EXPORT( void )
- FT_Matrix_Multiply( const FT_Matrix* a,
- FT_Matrix* b );
+ FT_EXPORT(void)
+ FT_Matrix_Multiply(const FT_Matrix* a,
+ FT_Matrix* b);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Matrix_Invert( FT_Matrix* matrix );
+ FT_EXPORT(FT_Error)
+ FT_Matrix_Invert(FT_Matrix* matrix);
/* */
/* Up to 0x1000 is used by otvalid.
Ox2xxx is reserved for feature OT extension. */
#define FT_VALIDATE_GX_START 0x4000
-#define FT_VALIDATE_GX_BITFIELD( tag ) \
- ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX )
+#define FT_VALIDATE_GX_BITFIELD(tag) \
+ (FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX)
/**********************************************************************
*
*/
-#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat )
-#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort )
-#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx )
-#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln )
-#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just )
-#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern )
-#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd )
-#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak )
-#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop )
-#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar )
-
-#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \
+#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD(feat)
+#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD(mort)
+#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD(morx)
+#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD(bsln)
+#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD(just)
+#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD(kern)
+#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD(opbd)
+#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD(trak)
+#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD(prop)
+#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD(lcar)
+
+#define FT_VALIDATE_GX (FT_VALIDATE_feat | \
FT_VALIDATE_mort | \
FT_VALIDATE_morx | \
FT_VALIDATE_bsln | \
FT_VALIDATE_opbd | \
FT_VALIDATE_trak | \
FT_VALIDATE_prop | \
- FT_VALIDATE_lcar )
+ FT_VALIDATE_lcar)
/* */
* application hasn't asked for validation, or the validator doesn't have
* the ability to validate the sfnt table.
*/
- FT_EXPORT( FT_Error )
- FT_TrueTypeGX_Validate( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_TrueTypeGX_Validate(FT_Face face,
FT_UInt validation_flags,
FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
- FT_UInt table_length );
+ FT_UInt table_length);
/* */
* This function must be used to free the buffer allocated by
* @FT_TrueTypeGX_Validate only.
*/
- FT_EXPORT( void )
- FT_TrueTypeGX_Free( FT_Face face,
- FT_Bytes table );
+ FT_EXPORT(void)
+ FT_TrueTypeGX_Free(FT_Face face,
+ FT_Bytes table);
/* */
* FT_VALIDATE_CKERN ::
* Handle the `kern' as either classic Apple or Microsoft kern table.
*/
-#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 )
-#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 )
+#define FT_VALIDATE_MS (FT_VALIDATE_GX_START << 0)
+#define FT_VALIDATE_APPLE (FT_VALIDATE_GX_START << 1)
-#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
+#define FT_VALIDATE_CKERN (FT_VALIDATE_MS | FT_VALIDATE_APPLE)
/* */
* `ckern_table', by calling @FT_ClassicKern_Free. A NULL value
* indicates that the table doesn't exist in the font.
*/
- FT_EXPORT( FT_Error )
- FT_ClassicKern_Validate( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_ClassicKern_Validate(FT_Face face,
FT_UInt validation_flags,
- FT_Bytes *ckern_table );
+ FT_Bytes *ckern_table);
/* */
* This function must be used to free the buffer allocated by
* @FT_ClassicKern_Validate only.
*/
- FT_EXPORT( void )
- FT_ClassicKern_Free( FT_Face face,
- FT_Bytes table );
+ FT_EXPORT(void)
+ FT_ClassicKern_Free(FT_Face face,
+ FT_Bytes table);
/* */
* This function may return `FT_Err_Unimplemented_Feature' if your build
* of FreeType was not compiled with zlib support.
*/
- FT_EXPORT( FT_Error )
- FT_Stream_OpenGzip( FT_Stream stream,
- FT_Stream source );
+ FT_EXPORT(FT_Error)
+ FT_Stream_OpenGzip(FT_Stream stream,
+ FT_Stream source);
/************************************************************************
* This function may return `FT_Err_Unimplemented_Feature' if your build
* of FreeType was not compiled with zlib support.
*/
- FT_EXPORT( FT_Error )
- FT_Gzip_Uncompress( FT_Memory memory,
+ FT_EXPORT(FT_Error)
+ FT_Gzip_Uncompress(FT_Memory memory,
FT_Byte* output,
FT_ULong* output_len,
const FT_Byte* input,
- FT_ULong input_len );
+ FT_ULong input_len);
/* */
/* */
-#define FT_CURVE_TAG( flag ) ( flag & 3 )
+#define FT_CURVE_TAG(flag) (flag & 3)
#define FT_CURVE_TAG_ON 1
#define FT_CURVE_TAG_CONIC 0
#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
-#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
- FT_CURVE_TAG_TOUCH_Y )
+#define FT_CURVE_TAG_TOUCH_BOTH (FT_CURVE_TAG_TOUCH_X | \
+ FT_CURVE_TAG_TOUCH_Y)
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
/* Error code. 0~means success. */
/* */
typedef int
- (*FT_Outline_MoveToFunc)( const FT_Vector* to,
- void* user );
+ (*FT_Outline_MoveToFunc)(const FT_Vector* to,
+ void* user);
#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
/* Error code. 0~means success. */
/* */
typedef int
- (*FT_Outline_LineToFunc)( const FT_Vector* to,
- void* user );
+ (*FT_Outline_LineToFunc)(const FT_Vector* to,
+ void* user);
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
/* Error code. 0~means success. */
/* */
typedef int
- (*FT_Outline_ConicToFunc)( const FT_Vector* control,
+ (*FT_Outline_ConicToFunc)(const FT_Vector* control,
const FT_Vector* to,
- void* user );
+ void* user);
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
/* Error code. 0~means success. */
/* */
typedef int
- (*FT_Outline_CubicToFunc)( const FT_Vector* control1,
+ (*FT_Outline_CubicToFunc)(const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to,
- void* user );
+ void* user);
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
/* this: */
/* */
/* { */
- /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
+ /* #define FT_IMAGE_TAG(value, _x1, _x2, _x3, _x4) value */
/* } */
/* */
/* to get a simple enumeration without assigning special numbers. */
/* */
#ifndef FT_IMAGE_TAG
-#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
- value = ( ( (unsigned long)_x1 << 24 ) | \
- ( (unsigned long)_x2 << 16 ) | \
- ( (unsigned long)_x3 << 8 ) | \
- (unsigned long)_x4 )
+#define FT_IMAGE_TAG(value, _x1, _x2, _x3, _x4) \
+ value = (((unsigned long)_x1 << 24) | \
+ ((unsigned long)_x2 << 16) | \
+ ((unsigned long)_x3 << 8) | \
+ (unsigned long)_x4 )
#endif /* FT_IMAGE_TAG */
/* */
typedef enum FT_Glyph_Format_
{
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
+ FT_IMAGE_TAG(FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
- FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
+ FT_IMAGE_TAG(FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p'),
+ FT_IMAGE_TAG(FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's'),
+ FT_IMAGE_TAG(FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l'),
+ FT_IMAGE_TAG(FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't')
} FT_Glyph_Format;
/* only for those scanlines that do have `gray' pixels on them. */
/* */
typedef void
- (*FT_SpanFunc)( int y,
+ (*FT_SpanFunc)(int y,
int count,
const FT_Span* spans,
- void* user );
+ void* user);
#define FT_Raster_Span_Func FT_SpanFunc
/* 1~if the pixel is `set', 0~otherwise. */
/* */
typedef int
- (*FT_Raster_BitTest_Func)( int y,
+ (*FT_Raster_BitTest_Func)(int y,
int x,
- void* user );
+ void* user);
/*************************************************************************/
/* 1~if the pixel is `set', 0~otherwise. */
/* */
typedef void
- (*FT_Raster_BitSet_Func)( int y,
+ (*FT_Raster_BitSet_Func)(int y,
int x,
- void* user );
+ void* user);
/*************************************************************************/
/* completely ignored by a given raster implementation. */
/* */
typedef int
- (*FT_Raster_NewFunc)( void* memory,
- FT_Raster* raster );
+ (*FT_Raster_NewFunc)(void* memory,
+ FT_Raster* raster);
#define FT_Raster_New_Func FT_Raster_NewFunc
/* raster :: A handle to the raster object. */
/* */
typedef void
- (*FT_Raster_DoneFunc)( FT_Raster raster );
+ (*FT_Raster_DoneFunc)(FT_Raster raster);
#define FT_Raster_Done_Func FT_Raster_DoneFunc
/* recommended for efficiency purposes. */
/* */
typedef void
- (*FT_Raster_ResetFunc)( FT_Raster raster,
+ (*FT_Raster_ResetFunc)(FT_Raster raster,
unsigned char* pool_base,
- unsigned long pool_size );
+ unsigned long pool_size);
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
/* args :: A pointer to the new mode/property to use. */
/* */
typedef int
- (*FT_Raster_SetModeFunc)( FT_Raster raster,
+ (*FT_Raster_SetModeFunc)(FT_Raster raster,
unsigned long mode,
- void* args );
+ void* args);
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
/* composition). */
/* */
typedef int
- (*FT_Raster_RenderFunc)( FT_Raster raster,
- const FT_Raster_Params* params );
+ (*FT_Raster_RenderFunc)(FT_Raster raster,
+ const FT_Raster_Params* params);
#define FT_Raster_Render_Func FT_Raster_RenderFunc
*
*/
typedef FT_Error
- (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
+ (*FT_Incremental_GetGlyphDataFunc)(FT_Incremental incremental,
FT_UInt glyph_index,
- FT_Data* adata );
+ FT_Data* adata);
/***************************************************************************
*
*/
typedef void
- (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
- FT_Data* data );
+ (*FT_Incremental_FreeGlyphDataFunc)(FT_Incremental incremental,
+ FT_Data* data);
/***************************************************************************
*/
typedef FT_Error
(*FT_Incremental_GetGlyphMetricsFunc)
- ( FT_Incremental incremental,
+ (FT_Incremental incremental,
FT_UInt glyph_index,
FT_Bool vertical,
- FT_Incremental_MetricsRec *ametrics );
+ FT_Incremental_MetricsRec *ametrics);
/**************************************************************************
* open_args.params = ¶meter; // we use one optional argument
*
* // open the font
- * error = FT_Open_Face( library, &open_args, index, &face );
+ * error = FT_Open_Face(library, &open_args, index, &face);
* ...
* }
*
* an incremental loading object to be used by FreeType.
*
*/
-#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
+#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG('i', 'n', 'c', 'r')
/* */
* @since:
* 2.3.0
*/
- FT_EXPORT( FT_Error )
- FT_Library_SetLcdFilter( FT_Library library,
- FT_LcdFilter filter );
+ FT_EXPORT(FT_Error)
+ FT_Library_SetLcdFilter(FT_Library library,
+ FT_LcdFilter filter);
/**************************************************************************
* @since:
* 2.4.0
*/
- FT_EXPORT( FT_Error )
- FT_Library_SetLcdFilterWeights( FT_Library library,
- unsigned char *weights );
+ FT_EXPORT(FT_Error)
+ FT_Library_SetLcdFilterWeights(FT_Library library,
+ unsigned char *weights);
/* */
/* <Return> */
/* List node. NULL if it wasn't found. */
/* */
- FT_EXPORT( FT_ListNode )
- FT_List_Find( FT_List list,
- void* data );
+ FT_EXPORT(FT_ListNode)
+ FT_List_Find(FT_List list,
+ void* data);
/*************************************************************************/
/* list :: A pointer to the parent list. */
/* node :: The node to append. */
/* */
- FT_EXPORT( void )
- FT_List_Add( FT_List list,
- FT_ListNode node );
+ FT_EXPORT(void)
+ FT_List_Add(FT_List list,
+ FT_ListNode node);
/*************************************************************************/
/* list :: A pointer to parent list. */
/* node :: The node to insert. */
/* */
- FT_EXPORT( void )
- FT_List_Insert( FT_List list,
- FT_ListNode node );
+ FT_EXPORT(void)
+ FT_List_Insert(FT_List list,
+ FT_ListNode node);
/*************************************************************************/
/* <InOut> */
/* list :: A pointer to the parent list. */
/* */
- FT_EXPORT( void )
- FT_List_Remove( FT_List list,
- FT_ListNode node );
+ FT_EXPORT(void)
+ FT_List_Remove(FT_List list,
+ FT_ListNode node);
/*************************************************************************/
/* list :: A pointer to the parent list. */
/* node :: The node to move. */
/* */
- FT_EXPORT( void )
- FT_List_Up( FT_List list,
- FT_ListNode node );
+ FT_EXPORT(void)
+ FT_List_Up(FT_List list,
+ FT_ListNode node);
/*************************************************************************/
/* Can be used to point to the iteration's state. */
/* */
typedef FT_Error
- (*FT_List_Iterator)( FT_ListNode node,
- void* user );
+ (*FT_List_Iterator)(FT_ListNode node,
+ void* user);
/*************************************************************************/
/* <Return> */
/* The result (a FreeType error code) of the last iterator call. */
/* */
- FT_EXPORT( FT_Error )
- FT_List_Iterate( FT_List list,
+ FT_EXPORT(FT_Error)
+ FT_List_Iterate(FT_List list,
FT_List_Iterator iterator,
- void* user );
+ void* user);
/*************************************************************************/
/* be used to point to the iteration's state. */
/* */
typedef void
- (*FT_List_Destructor)( FT_Memory memory,
+ (*FT_List_Destructor)(FT_Memory memory,
void* data,
- void* user );
+ void* user);
/*************************************************************************/
/* This function expects that all nodes added by @FT_List_Add or */
/* @FT_List_Insert have been dynamically allocated. */
/* */
- FT_EXPORT( void )
- FT_List_Finalize( FT_List list,
+ FT_EXPORT(void)
+ FT_List_Finalize(FT_List list,
FT_List_Destructor destroy,
FT_Memory memory,
- void* user );
+ void* user);
/* */
* This function may return `FT_Err_Unimplemented_Feature' if your build
* of FreeType was not compiled with LZW support.
*/
- FT_EXPORT( FT_Error )
- FT_Stream_OpenLZW( FT_Stream stream,
- FT_Stream source );
+ FT_EXPORT(FT_Error)
+ FT_Stream_OpenLZW(FT_Stream stream,
+ FT_Stream source);
/* */
/* that are installed in the system as follows. */
/* */
/* { */
- /* fond = GetResource( 'FOND', fontName ); */
- /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */
+ /* fond = GetResource('FOND', fontName); */
+ /* error = FT_New_Face_From_FOND(library, fond, 0, &face); */
/* } */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Face_From_FOND( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_New_Face_From_FOND(FT_Library library,
Handle fond,
FT_Long face_index,
- FT_Face *aface )
+ FT_Face *aface)
FT_DEPRECATED_ATTRIBUTE;
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_GetFile_From_Mac_Name( const char* fontName,
+ FT_EXPORT(FT_Error)
+ FT_GetFile_From_Mac_Name(const char* fontName,
FSSpec* pathSpec,
- FT_Long* face_index )
+ FT_Long* face_index)
FT_DEPRECATED_ATTRIBUTE;
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_GetFile_From_Mac_ATS_Name( const char* fontName,
+ FT_EXPORT(FT_Error)
+ FT_GetFile_From_Mac_ATS_Name(const char* fontName,
FSSpec* pathSpec,
- FT_Long* face_index )
+ FT_Long* face_index)
FT_DEPRECATED_ATTRIBUTE;
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
+ FT_EXPORT(FT_Error)
+ FT_GetFilePath_From_Mac_ATS_Name(const char* fontName,
UInt8* path,
UInt32 maxPathSize,
- FT_Long* face_index )
+ FT_Long* face_index)
FT_DEPRECATED_ATTRIBUTE;
/* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */
/* it accepts an FSSpec instead of a path. */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Face_From_FSSpec( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_New_Face_From_FSSpec(FT_Library library,
const FSSpec *spec,
FT_Long face_index,
- FT_Face *aface )
+ FT_Face *aface)
FT_DEPRECATED_ATTRIBUTE;
/* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */
/* it accepts an FSRef instead of a path. */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Face_From_FSRef( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_New_Face_From_FSRef(FT_Library library,
const FSRef *ref,
FT_Long face_index,
- FT_Face *aface )
+ FT_Face *aface)
FT_DEPRECATED_ATTRIBUTE;
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Multi_Master( FT_Face face,
- FT_Multi_Master *amaster );
+ FT_EXPORT(FT_Error)
+ FT_Get_Multi_Master(FT_Face face,
+ FT_Multi_Master *amaster);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_MM_Var( FT_Face face,
- FT_MM_Var* *amaster );
+ FT_EXPORT(FT_Error)
+ FT_Get_MM_Var(FT_Face face,
+ FT_MM_Var* *amaster);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_MM_Design_Coordinates( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Set_MM_Design_Coordinates(FT_Face face,
FT_UInt num_coords,
- FT_Long* coords );
+ FT_Long* coords);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_Var_Design_Coordinates( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Set_Var_Design_Coordinates(FT_Face face,
FT_UInt num_coords,
- FT_Fixed* coords );
+ FT_Fixed* coords);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_MM_Blend_Coordinates( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Set_MM_Blend_Coordinates(FT_Face face,
FT_UInt num_coords,
- FT_Fixed* coords );
+ FT_Fixed* coords);
/*************************************************************************/
/* <Description> */
/* This is another name of @FT_Set_MM_Blend_Coordinates. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_Var_Blend_Coordinates( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Set_Var_Blend_Coordinates(FT_Face face,
FT_UInt num_coords,
- FT_Fixed* coords );
+ FT_Fixed* coords);
/* */
/* module :: The module to initialize. */
/* */
typedef FT_Error
- (*FT_Module_Constructor)( FT_Module module );
+ (*FT_Module_Constructor)(FT_Module module);
/*************************************************************************/
/* module :: The module to finalize. */
/* */
typedef void
- (*FT_Module_Destructor)( FT_Module module );
+ (*FT_Module_Destructor)(FT_Module module);
/*************************************************************************/
/* name :: The name of the interface in the module. */
/* */
typedef FT_Module_Interface
- (*FT_Module_Requester)( FT_Module module,
- const char* name );
+ (*FT_Module_Requester)(FT_Module module,
+ const char* name);
/*************************************************************************/
/* An error will be returned if a module already exists by that name, */
/* or if the module requires a version of FreeType that is too great. */
/* */
- FT_EXPORT( FT_Error )
- FT_Add_Module( FT_Library library,
- const FT_Module_Class* clazz );
+ FT_EXPORT(FT_Error)
+ FT_Add_Module(FT_Library library,
+ const FT_Module_Class* clazz);
/*************************************************************************/
/* FreeType's internal modules aren't documented very well, and you */
/* should look up the source code for details. */
/* */
- FT_EXPORT( FT_Module )
- FT_Get_Module( FT_Library library,
- const char* module_name );
+ FT_EXPORT(FT_Module)
+ FT_Get_Module(FT_Library library,
+ const char* module_name);
/*************************************************************************/
/* <Note> */
/* The module object is destroyed by the function in case of success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Remove_Module( FT_Library library,
- FT_Module module );
+ FT_EXPORT(FT_Error)
+ FT_Remove_Module(FT_Library library,
+ FT_Module module);
/**********************************************************************
*
*
* bar = 1;
- * FT_Property_Set( library, "foo", "bar", &bar );
+ * FT_Property_Set(library, "foo", "bar", &bar);
* }
*
* Note that the FreeType Cache sub-system doesn't recognize module
* 2.4.11
*
*/
- FT_EXPORT( FT_Error )
- FT_Property_Set( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Property_Set(FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
- const void* value );
+ const void* value);
/**********************************************************************
* range baz;
*
*
- * FT_Property_Get( library, "foo", "baz", &baz );
+ * FT_Property_Get(library, "foo", "baz", &baz);
* }
*
* It is not possible to retrieve properties of the FreeType Cache
* 2.4.11
*
*/
- FT_EXPORT( FT_Error )
- FT_Property_Get( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Property_Get(FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
- void* value );
+ void* value);
/*************************************************************************/
/* <Since> */
/* 2.4.2 */
/* */
- FT_EXPORT( FT_Error )
- FT_Reference_Library( FT_Library library );
+ FT_EXPORT(FT_Error)
+ FT_Reference_Library(FT_Library library);
/*************************************************************************/
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Library. */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Library( FT_Memory memory,
- FT_Library *alibrary );
+ FT_EXPORT(FT_Error)
+ FT_New_Library(FT_Memory memory,
+ FT_Library *alibrary);
/*************************************************************************/
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Library. */
/* */
- FT_EXPORT( FT_Error )
- FT_Done_Library( FT_Library library );
+ FT_EXPORT(FT_Error)
+ FT_Done_Library(FT_Library library);
/* */
typedef void
- (*FT_DebugHook_Func)( void* arg );
+ (*FT_DebugHook_Func)(void* arg);
/*************************************************************************/
/* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
/* This is a bug and will be fixed in a forthcoming release. */
/* */
- FT_EXPORT( void )
- FT_Set_Debug_Hook( FT_Library library,
+ FT_EXPORT(void)
+ FT_Set_Debug_Hook(FT_Library library,
FT_UInt hook_index,
- FT_DebugHook_Func debug_hook );
+ FT_DebugHook_Func debug_hook);
/*************************************************************************/
/* <InOut> */
/* library :: A handle to a new library object. */
/* */
- FT_EXPORT( void )
- FT_Add_Default_Modules( FT_Library library );
+ FT_EXPORT(void)
+ FT_Add_Default_Modules(FT_Library library);
* 2.2
*
*/
- FT_EXPORT( FT_TrueTypeEngineType )
- FT_Get_TrueType_Engine_Type( FT_Library library );
+ FT_EXPORT(FT_TrueTypeEngineType)
+ FT_Get_TrueType_Engine_Type(FT_Library library);
/* */
/* To hide the various `XXX_Err_' prefixes in the source code, FreeType */
/* provides some macros in `fttypes.h'. */
/* */
- /* FT_ERR( err ) */
+ /* FT_ERR(err) */
/* Add current error module prefix (as defined with the */
/* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */
/* the line */
/* */
- /* error = FT_ERR( Invalid_Outline ); */
+ /* error = FT_ERR(Invalid_Outline); */
/* */
/* expands to */
/* */
/* error = BDF_Err_Invalid_Outline; */
/* */
/* For simplicity, you can always use `FT_Err_Ok' directly instead */
- /* of `FT_ERR( Ok )'. */
+ /* of `FT_ERR(Ok)'. */
/* */
- /* FT_ERR_EQ( errcode, err ) */
- /* FT_ERR_NEQ( errcode, err ) */
+ /* FT_ERR_EQ(errcode, err) */
+ /* FT_ERR_NEQ(errcode, err) */
/* Compare error code `errcode' with the error `err' for equality */
/* and inequality, respectively. Example: */
/* */
- /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */
+ /* if (FT_ERR_EQ(error, Invalid_Outline)) */
/* ... */
/* */
/* Using this macro you don't have to think about error prefixes. */
/* Of course, if module errors are not active, the above example is */
/* the same as */
/* */
- /* if ( error == FT_Err_Invalid_Outline ) */
+ /* if (error == FT_Err_Invalid_Outline) */
/* ... */
/* */
- /* FT_ERROR_BASE( errcode ) */
- /* FT_ERROR_MODULE( errcode ) */
+ /* FT_ERROR_BASE(errcode) */
+ /* FT_ERROR_MODULE(errcode) */
/* Get base error and module error code, respectively. */
/* */
/* */
/* */
/* { */
/* #undef __FTMODERR_H__ */
- /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */
+ /* #define FT_MODERRDEF(e, v, s) { FT_Mod_Err_ ## e, s }, */
/* #define FT_MODERR_START_LIST { */
/* #define FT_MODERR_END_LIST { 0, 0 } }; */
/* */
#ifndef FT_MODERRDEF
#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
-#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v,
+#define FT_MODERRDEF(e, v, s) FT_Mod_Err_ ## e = v,
#else
-#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0,
+#define FT_MODERRDEF(e, v, s) FT_Mod_Err_ ## e = 0,
#endif
#define FT_MODERR_START_LIST enum {
#endif
- FT_MODERRDEF( Base, 0x000, "base module" )
- FT_MODERRDEF( Autofit, 0x100, "autofitter module" )
- FT_MODERRDEF( BDF, 0x200, "BDF module" )
- FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" )
- FT_MODERRDEF( Cache, 0x400, "cache module" )
- FT_MODERRDEF( CFF, 0x500, "CFF module" )
- FT_MODERRDEF( CID, 0x600, "CID module" )
- FT_MODERRDEF( Gzip, 0x700, "Gzip module" )
- FT_MODERRDEF( LZW, 0x800, "LZW module" )
- FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" )
- FT_MODERRDEF( PCF, 0xA00, "PCF module" )
- FT_MODERRDEF( PFR, 0xB00, "PFR module" )
- FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" )
- FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" )
- FT_MODERRDEF( PSnames, 0xE00, "PS names module" )
- FT_MODERRDEF( Raster, 0xF00, "raster module" )
- FT_MODERRDEF( SFNT, 0x1000, "SFNT module" )
- FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" )
- FT_MODERRDEF( TrueType, 0x1200, "TrueType module" )
- FT_MODERRDEF( Type1, 0x1300, "Type 1 module" )
- FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
- FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
- FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
+ FT_MODERRDEF(Base, 0x000, "base module")
+ FT_MODERRDEF(Autofit, 0x100, "autofitter module")
+ FT_MODERRDEF(BDF, 0x200, "BDF module")
+ FT_MODERRDEF(Bzip2, 0x300, "Bzip2 module")
+ FT_MODERRDEF(Cache, 0x400, "cache module")
+ FT_MODERRDEF(CFF, 0x500, "CFF module")
+ FT_MODERRDEF(CID, 0x600, "CID module")
+ FT_MODERRDEF(Gzip, 0x700, "Gzip module")
+ FT_MODERRDEF(LZW, 0x800, "LZW module")
+ FT_MODERRDEF(OTvalid, 0x900, "OpenType validation module")
+ FT_MODERRDEF(PCF, 0xA00, "PCF module")
+ FT_MODERRDEF(PFR, 0xB00, "PFR module")
+ FT_MODERRDEF(PSaux, 0xC00, "PS auxiliary module")
+ FT_MODERRDEF(PShinter, 0xD00, "PS hinter module")
+ FT_MODERRDEF(PSnames, 0xE00, "PS names module")
+ FT_MODERRDEF(Raster, 0xF00, "raster module")
+ FT_MODERRDEF(SFNT, 0x1000, "SFNT module")
+ FT_MODERRDEF(Smooth, 0x1100, "smooth raster module")
+ FT_MODERRDEF(TrueType, 0x1200, "TrueType module")
+ FT_MODERRDEF(Type1, 0x1300, "Type 1 module")
+ FT_MODERRDEF(Type42, 0x1400, "Type 42 module")
+ FT_MODERRDEF(Winfonts, 0x1500, "Windows FON/FNT module")
+ FT_MODERRDEF(GXvalid, 0x1600, "GX validation module")
#ifdef FT_MODERR_END_LIST
* doesn't exist in the font, or the application hasn't asked for
* validation.
*/
- FT_EXPORT( FT_Error )
- FT_OpenType_Validate( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_OpenType_Validate(FT_Face face,
FT_UInt validation_flags,
FT_Bytes *BASE_table,
FT_Bytes *GDEF_table,
FT_Bytes *GPOS_table,
FT_Bytes *GSUB_table,
- FT_Bytes *JSTF_table );
+ FT_Bytes *JSTF_table);
/* */
* This function must be used to free the buffer allocated by
* @FT_OpenType_Validate only.
*/
- FT_EXPORT( void )
- FT_OpenType_Free( FT_Face face,
- FT_Bytes table );
+ FT_EXPORT(void)
+ FT_OpenType_Free(FT_Face face,
+ FT_Bytes table);
/* */
/* outline for stroking purposes (otherwise it would result in a */
/* visible dot when round caps are used). */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Decompose( FT_Outline* outline,
+ FT_EXPORT(FT_Error)
+ FT_Outline_Decompose(FT_Outline* outline,
const FT_Outline_Funcs* func_interface,
- void* user );
+ void* user);
/*************************************************************************/
/* The reason why this function takes a `library' parameter is simply */
/* to use the library's memory allocator. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_New( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Outline_New(FT_Library library,
FT_UInt numPoints,
FT_Int numContours,
- FT_Outline *anoutline );
+ FT_Outline *anoutline);
- FT_EXPORT( FT_Error )
- FT_Outline_New_Internal( FT_Memory memory,
+ FT_EXPORT(FT_Error)
+ FT_Outline_New_Internal(FT_Memory memory,
FT_UInt numPoints,
FT_Int numContours,
- FT_Outline *anoutline );
+ FT_Outline *anoutline);
/*************************************************************************/
/* The reason why this function takes an `library' parameter is */
/* simply to use ft_mem_free(). */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Done( FT_Library library,
- FT_Outline* outline );
+ FT_EXPORT(FT_Error)
+ FT_Outline_Done(FT_Library library,
+ FT_Outline* outline);
- FT_EXPORT( FT_Error )
- FT_Outline_Done_Internal( FT_Memory memory,
- FT_Outline* outline );
+ FT_EXPORT(FT_Error)
+ FT_Outline_Done_Internal(FT_Memory memory,
+ FT_Outline* outline);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Check( FT_Outline* outline );
+ FT_EXPORT(FT_Error)
+ FT_Outline_Check(FT_Outline* outline);
/*************************************************************************/
/* <Note> */
/* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
/* */
- FT_EXPORT( void )
- FT_Outline_Get_CBox( const FT_Outline* outline,
- FT_BBox *acbox );
+ FT_EXPORT(void)
+ FT_Outline_Get_CBox(const FT_Outline* outline,
+ FT_BBox *acbox);
/*************************************************************************/
/* */
/* yOffset :: The vertical offset. */
/* */
- FT_EXPORT( void )
- FT_Outline_Translate( const FT_Outline* outline,
+ FT_EXPORT(void)
+ FT_Outline_Translate(const FT_Outline* outline,
FT_Pos xOffset,
- FT_Pos yOffset );
+ FT_Pos yOffset);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Copy( const FT_Outline* source,
- FT_Outline *target );
+ FT_EXPORT(FT_Error)
+ FT_Outline_Copy(const FT_Outline* source,
+ FT_Outline *target);
/*************************************************************************/
/* You can use @FT_Outline_Translate if you need to translate the */
/* outline's points. */
/* */
- FT_EXPORT( void )
- FT_Outline_Transform( const FT_Outline* outline,
- const FT_Matrix* matrix );
+ FT_EXPORT(void)
+ FT_Outline_Transform(const FT_Outline* outline,
+ const FT_Matrix* matrix);
/*************************************************************************/
/* Example call: */
/* */
/* { */
- /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
- /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */
- /* FT_Outline_Embolden( &face->slot->outline, strength ); */
+ /* FT_Load_Glyph(face, index, FT_LOAD_DEFAULT); */
+ /* if (face->slot->format == FT_GLYPH_FORMAT_OUTLINE) */
+ /* FT_Outline_Embolden(&face->slot->outline, strength); */
/* } */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Embolden( FT_Outline* outline,
- FT_Pos strength );
+ FT_EXPORT(FT_Error)
+ FT_Outline_Embolden(FT_Outline* outline,
+ FT_Pos strength);
/*************************************************************************/
/* @FT_Outline_Embolden, which uses the same strength in both */
/* directions. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_EmboldenXY( FT_Outline* outline,
+ FT_EXPORT(FT_Error)
+ FT_Outline_EmboldenXY(FT_Outline* outline,
FT_Pos xstrength,
- FT_Pos ystrength );
+ FT_Pos ystrength);
/*************************************************************************/
/* It shouldn't be used by a normal client application, unless it */
/* knows what it is doing. */
/* */
- FT_EXPORT( void )
- FT_Outline_Reverse( FT_Outline* outline );
+ FT_EXPORT(void)
+ FT_Outline_Reverse(FT_Outline* outline);
/*************************************************************************/
/* you select the gray-level rasterizer, and you want less than 256 */
/* gray levels, you have to use @FT_Outline_Render directly. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Get_Bitmap( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Outline_Get_Bitmap(FT_Library library,
FT_Outline* outline,
- const FT_Bitmap *abitmap );
+ const FT_Bitmap *abitmap);
/*************************************************************************/
/* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */
/* @FT_Raster_Params structure for more details. */
/* */
- FT_EXPORT( FT_Error )
- FT_Outline_Render( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Outline_Render(FT_Library library,
FT_Outline* outline,
- FT_Raster_Params* params );
+ FT_Raster_Params* params);
/**************************************************************************
* The orientation.
*
*/
- FT_EXPORT( FT_Orientation )
- FT_Outline_Get_Orientation( FT_Outline* outline );
+ FT_EXPORT(FT_Orientation)
+ FT_Outline_Get_Orientation(FT_Outline* outline);
/* */
* If the input face is not a PFR, this function will return an error.
* However, in all cases, it will return valid values.
*/
- FT_EXPORT( FT_Error )
- FT_Get_PFR_Metrics( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_PFR_Metrics(FT_Face face,
FT_UInt *aoutline_resolution,
FT_UInt *ametrics_resolution,
FT_Fixed *ametrics_x_scale,
- FT_Fixed *ametrics_y_scale );
+ FT_Fixed *ametrics_y_scale);
/**********************************************************************
* You can use the value of the `x_scale' and `y_scale' parameters
* returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels.
*/
- FT_EXPORT( FT_Error )
- FT_Get_PFR_Kerning( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_PFR_Kerning(FT_Face face,
FT_UInt left,
FT_UInt right,
- FT_Vector *avector );
+ FT_Vector *avector);
/**********************************************************************
* You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics
* to convert the advance to device sub-pixels (i.e., 1/64th of pixels).
*/
- FT_EXPORT( FT_Error )
- FT_Get_PFR_Advance( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_PFR_Advance(FT_Face face,
FT_UInt gindex,
- FT_Pos *aadvance );
+ FT_Pos *aadvance);
/* */
/* create a new glyph object */
typedef FT_Error
- (*FT_Glyph_InitFunc)( FT_Glyph glyph,
- FT_GlyphSlot slot );
+ (*FT_Glyph_InitFunc)(FT_Glyph glyph,
+ FT_GlyphSlot slot);
/* destroys a given glyph object */
typedef void
- (*FT_Glyph_DoneFunc)( FT_Glyph glyph );
+ (*FT_Glyph_DoneFunc)(FT_Glyph glyph);
typedef void
- (*FT_Glyph_TransformFunc)( FT_Glyph glyph,
+ (*FT_Glyph_TransformFunc)(FT_Glyph glyph,
const FT_Matrix* matrix,
- const FT_Vector* delta );
+ const FT_Vector* delta);
typedef void
- (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
- FT_BBox* abbox );
+ (*FT_Glyph_GetBBoxFunc)(FT_Glyph glyph,
+ FT_BBox* abbox);
typedef FT_Error
- (*FT_Glyph_CopyFunc)( FT_Glyph source,
- FT_Glyph target );
+ (*FT_Glyph_CopyFunc)(FT_Glyph source,
+ FT_Glyph target);
typedef FT_Error
- (*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
- FT_GlyphSlot slot );
+ (*FT_Glyph_PrepareFunc)(FT_Glyph glyph,
+ FT_GlyphSlot slot);
/* deprecated */
#define FT_Glyph_Init_Func FT_Glyph_InitFunc
typedef FT_Error
- (*FT_Renderer_RenderFunc)( FT_Renderer renderer,
+ (*FT_Renderer_RenderFunc)(FT_Renderer renderer,
FT_GlyphSlot slot,
FT_UInt mode,
- const FT_Vector* origin );
+ const FT_Vector* origin);
typedef FT_Error
- (*FT_Renderer_TransformFunc)( FT_Renderer renderer,
+ (*FT_Renderer_TransformFunc)(FT_Renderer renderer,
FT_GlyphSlot slot,
const FT_Matrix* matrix,
- const FT_Vector* delta );
+ const FT_Vector* delta);
typedef void
- (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
+ (*FT_Renderer_GetCBoxFunc)(FT_Renderer renderer,
FT_GlyphSlot slot,
- FT_BBox* cbox );
+ FT_BBox* cbox);
typedef FT_Error
- (*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
+ (*FT_Renderer_SetModeFunc)(FT_Renderer renderer,
FT_ULong mode_tag,
- FT_Pointer mode_ptr );
+ FT_Pointer mode_ptr);
/* deprecated identifiers */
#define FTRenderer_render FT_Renderer_RenderFunc
/* To add a new renderer, simply use @FT_Add_Module. To retrieve a */
/* renderer by its name, use @FT_Get_Module. */
/* */
- FT_EXPORT( FT_Renderer )
- FT_Get_Renderer( FT_Library library,
- FT_Glyph_Format format );
+ FT_EXPORT(FT_Renderer)
+ FT_Get_Renderer(FT_Library library,
+ FT_Glyph_Format format);
/*************************************************************************/
/* 5~elements. Consequently, the third and fourth argument are zero */
/* normally. */
/* */
- FT_EXPORT( FT_Error )
- FT_Set_Renderer( FT_Library library,
+ FT_EXPORT(FT_Error)
+ FT_Set_Renderer(FT_Library library,
FT_Renderer renderer,
FT_UInt num_params,
- FT_Parameter* parameters );
+ FT_Parameter* parameters);
/* */
/* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */
/* @FT_Load_Glyph, @FT_Load_Char, etc. */
/* */
- FT_EXPORT( FT_Error )
- FT_New_Size( FT_Face face,
- FT_Size* size );
+ FT_EXPORT(FT_Error)
+ FT_New_Size(FT_Face face,
+ FT_Size* size);
/*************************************************************************/
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
- FT_EXPORT( FT_Error )
- FT_Done_Size( FT_Size size );
+ FT_EXPORT(FT_Error)
+ FT_Done_Size(FT_Size size);
/*************************************************************************/
/* If `face' is the size's parent face object, this function changes */
/* the value of `face->size' to the input size handle. */
/* */
- FT_EXPORT( FT_Error )
- FT_Activate_Size( FT_Size size );
+ FT_EXPORT(FT_Error)
+ FT_Activate_Size(FT_Size size);
/* */
/* <Return> */
/* The number of strings in the `name' table. */
/* */
- FT_EXPORT( FT_UInt )
- FT_Get_Sfnt_Name_Count( FT_Face face );
+ FT_EXPORT(FT_UInt)
+ FT_Get_Sfnt_Name_Count(FT_Face face);
/*************************************************************************/
/* `name' table entries, then do a loop until you get the right */
/* platform, encoding, and name ID. */
/* */
- FT_EXPORT( FT_Error )
- FT_Get_Sfnt_Name( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Get_Sfnt_Name(FT_Face face,
FT_UInt idx,
- FT_SfntName *aname );
+ FT_SfntName *aname);
/***************************************************************************
* legacy systems that have a 4-face-per-family restriction.
*
*/
-#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' )
+#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG('i', 'g', 'p', 'f')
/***************************************************************************
* systems that have a 4-face-per-family restriction.
*
*/
-#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' )
+#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG('i', 'g', 'p', 's')
/* */
* The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid
* outlines.
*/
- FT_EXPORT( FT_StrokerBorder )
- FT_Outline_GetInsideBorder( FT_Outline* outline );
+ FT_EXPORT(FT_StrokerBorder)
+ FT_Outline_GetInsideBorder(FT_Outline* outline);
/**************************************************************
* The border index. @FT_STROKER_BORDER_LEFT for empty or invalid
* outlines.
*/
- FT_EXPORT( FT_StrokerBorder )
- FT_Outline_GetOutsideBorder( FT_Outline* outline );
+ FT_EXPORT(FT_StrokerBorder)
+ FT_Outline_GetOutsideBorder(FT_Outline* outline);
/**************************************************************
* @return:
* FreeType error code. 0~means success.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_New( FT_Library library,
- FT_Stroker *astroker );
+ FT_EXPORT(FT_Error)
+ FT_Stroker_New(FT_Library library,
+ FT_Stroker *astroker);
/**************************************************************
* The radius is expressed in the same units as the outline
* coordinates.
*/
- FT_EXPORT( void )
- FT_Stroker_Set( FT_Stroker stroker,
+ FT_EXPORT(void)
+ FT_Stroker_Set(FT_Stroker stroker,
FT_Fixed radius,
FT_Stroker_LineCap line_cap,
FT_Stroker_LineJoin line_join,
- FT_Fixed miter_limit );
+ FT_Fixed miter_limit);
/**************************************************************
* stroker ::
* The target stroker handle.
*/
- FT_EXPORT( void )
- FT_Stroker_Rewind( FT_Stroker stroker );
+ FT_EXPORT(void)
+ FT_Stroker_Rewind(FT_Stroker stroker);
/**************************************************************
*
* This function calls @FT_Stroker_Rewind automatically.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_ParseOutline( FT_Stroker stroker,
+ FT_EXPORT(FT_Error)
+ FT_Stroker_ParseOutline(FT_Stroker stroker,
FT_Outline* outline,
- FT_Bool opened );
+ FT_Bool opened);
/**************************************************************
* This function is useful when you need to stroke a path that is
* not stored as an @FT_Outline object.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_BeginSubPath( FT_Stroker stroker,
+ FT_EXPORT(FT_Error)
+ FT_Stroker_BeginSubPath(FT_Stroker stroker,
FT_Vector* to,
- FT_Bool open );
+ FT_Bool open);
/**************************************************************
* If the subpath was not `opened', this function `draws' a
* single line segment to the start position when needed.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_EndSubPath( FT_Stroker stroker );
+ FT_EXPORT(FT_Error)
+ FT_Stroker_EndSubPath(FT_Stroker stroker);
/**************************************************************
* You should call this function between @FT_Stroker_BeginSubPath and
* @FT_Stroker_EndSubPath.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_LineTo( FT_Stroker stroker,
- FT_Vector* to );
+ FT_EXPORT(FT_Error)
+ FT_Stroker_LineTo(FT_Stroker stroker,
+ FT_Vector* to);
/**************************************************************
* You should call this function between @FT_Stroker_BeginSubPath and
* @FT_Stroker_EndSubPath.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_ConicTo( FT_Stroker stroker,
+ FT_EXPORT(FT_Error)
+ FT_Stroker_ConicTo(FT_Stroker stroker,
FT_Vector* control,
- FT_Vector* to );
+ FT_Vector* to);
/**************************************************************
* You should call this function between @FT_Stroker_BeginSubPath and
* @FT_Stroker_EndSubPath.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_CubicTo( FT_Stroker stroker,
+ FT_EXPORT(FT_Error)
+ FT_Stroker_CubicTo(FT_Stroker stroker,
FT_Vector* control1,
FT_Vector* control2,
- FT_Vector* to );
+ FT_Vector* to);
/**************************************************************
* Use the function @FT_Stroker_GetCounts instead if you want to
* retrieve the counts associated to both borders.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_GetBorderCounts( FT_Stroker stroker,
+ FT_EXPORT(FT_Error)
+ FT_Stroker_GetBorderCounts(FT_Stroker stroker,
FT_StrokerBorder border,
FT_UInt *anum_points,
- FT_UInt *anum_contours );
+ FT_UInt *anum_contours);
/**************************************************************
* Use the function @FT_Stroker_Export instead if you want to
* retrieve all borders at once.
*/
- FT_EXPORT( void )
- FT_Stroker_ExportBorder( FT_Stroker stroker,
+ FT_EXPORT(void)
+ FT_Stroker_ExportBorder(FT_Stroker stroker,
FT_StrokerBorder border,
- FT_Outline* outline );
+ FT_Outline* outline);
/**************************************************************
* @return:
* FreeType error code. 0~means success.
*/
- FT_EXPORT( FT_Error )
- FT_Stroker_GetCounts( FT_Stroker stroker,
+ FT_EXPORT(FT_Error)
+ FT_Stroker_GetCounts(FT_Stroker stroker,
FT_UInt *anum_points,
- FT_UInt *anum_contours );
+ FT_UInt *anum_contours);
/**************************************************************
* outline ::
* The target outline handle.
*/
- FT_EXPORT( void )
- FT_Stroker_Export( FT_Stroker stroker,
- FT_Outline* outline );
+ FT_EXPORT(void)
+ FT_Stroker_Export(FT_Stroker stroker,
+ FT_Outline* outline);
/**************************************************************
* stroker ::
* A stroker handle. Can be NULL.
*/
- FT_EXPORT( void )
- FT_Stroker_Done( FT_Stroker stroker );
+ FT_EXPORT(void)
+ FT_Stroker_Done(FT_Stroker stroker);
/**************************************************************
* may need to manually adjust horizontal and vertical advance amounts
* to account for this added size.
*/
- FT_EXPORT( FT_Error )
- FT_Glyph_Stroke( FT_Glyph *pglyph,
+ FT_EXPORT(FT_Error)
+ FT_Glyph_Stroke(FT_Glyph *pglyph,
FT_Stroker stroker,
- FT_Bool destroy );
+ FT_Bool destroy);
/**************************************************************
* may need to manually adjust horizontal and vertical advance amounts
* to account for this added size.
*/
- FT_EXPORT( FT_Error )
- FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
+ FT_EXPORT(FT_Error)
+ FT_Glyph_StrokeBorder(FT_Glyph *pglyph,
FT_Stroker stroker,
FT_Bool inside,
- FT_Bool destroy );
+ FT_Bool destroy);
/* */
/* For emboldened outlines the height, width, and advance metrics are */
/* increased by the strength of the emboldening. You can also call */
/* @FT_Outline_Get_CBox to get precise values. */
- FT_EXPORT( void )
- FT_GlyphSlot_Embolden( FT_GlyphSlot slot );
+ FT_EXPORT(void)
+ FT_GlyphSlot_Embolden(FT_GlyphSlot slot);
/* Slant an outline glyph to the right by about 12 degrees. */
- FT_EXPORT( void )
- FT_GlyphSlot_Oblique( FT_GlyphSlot slot );
+ FT_EXPORT(void)
+ FT_GlyphSlot_Oblique(FT_GlyphSlot slot);
/* */
*
*/
typedef void*
- (*FT_Alloc_Func)( FT_Memory memory,
- long size );
+ (*FT_Alloc_Func)(FT_Memory memory,
+ long size);
/*************************************************************************
*
*/
typedef void
- (*FT_Free_Func)( FT_Memory memory,
- void* block );
+ (*FT_Free_Func)(FT_Memory memory,
+ void* block);
/*************************************************************************
*
*/
typedef void*
- (*FT_Realloc_Func)( FT_Memory memory,
+ (*FT_Realloc_Func)(FT_Memory memory,
long cur_size,
long new_size,
- void* block );
+ void* block);
/*************************************************************************
*
*/
typedef unsigned long
- (*FT_Stream_IoFunc)( FT_Stream stream,
+ (*FT_Stream_IoFunc)(FT_Stream stream,
unsigned long offset,
unsigned char* buffer,
- unsigned long count );
+ unsigned long count);
/*************************************************************************
*
*/
typedef void
- (*FT_Stream_CloseFunc)( FT_Stream stream );
+ (*FT_Stream_CloseFunc)(FT_Stream stream);
/*************************************************************************
* The angle pi expressed in @FT_Angle units.
*
*/
-#define FT_ANGLE_PI ( 180L << 16 )
+#define FT_ANGLE_PI (180L << 16)
/*************************************************************************
* The angle 2*pi expressed in @FT_Angle units.
*
*/
-#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
+#define FT_ANGLE_2PI (FT_ANGLE_PI * 2)
/*************************************************************************
* The angle pi/2 expressed in @FT_Angle units.
*
*/
-#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
+#define FT_ANGLE_PI2 (FT_ANGLE_PI / 2)
/*************************************************************************
* The angle pi/4 expressed in @FT_Angle units.
*
*/
-#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
+#define FT_ANGLE_PI4 (FT_ANGLE_PI / 4)
/*************************************************************************
* function @FT_Vector_Unit.
*
*/
- FT_EXPORT( FT_Fixed )
- FT_Sin( FT_Angle angle );
+ FT_EXPORT(FT_Fixed)
+ FT_Sin(FT_Angle angle);
/*************************************************************************
* function @FT_Vector_Unit.
*
*/
- FT_EXPORT( FT_Fixed )
- FT_Cos( FT_Angle angle );
+ FT_EXPORT(FT_Fixed)
+ FT_Cos(FT_Angle angle);
/*************************************************************************
* The tangent value.
*
*/
- FT_EXPORT( FT_Fixed )
- FT_Tan( FT_Angle angle );
+ FT_EXPORT(FT_Fixed)
+ FT_Tan(FT_Angle angle);
/*************************************************************************
* The arc-tangent value (i.e. angle).
*
*/
- FT_EXPORT( FT_Angle )
- FT_Atan2( FT_Fixed x,
- FT_Fixed y );
+ FT_EXPORT(FT_Angle)
+ FT_Atan2(FT_Fixed x,
+ FT_Fixed y);
/*************************************************************************
* Constrained value of `value2-value1'.
*
*/
- FT_EXPORT( FT_Angle )
- FT_Angle_Diff( FT_Angle angle1,
- FT_Angle angle2 );
+ FT_EXPORT(FT_Angle)
+ FT_Angle_Diff(FT_Angle angle1,
+ FT_Angle angle2);
/*************************************************************************
* The address of angle.
*
*/
- FT_EXPORT( void )
- FT_Vector_Unit( FT_Vector* vec,
- FT_Angle angle );
+ FT_EXPORT(void)
+ FT_Vector_Unit(FT_Vector* vec,
+ FT_Angle angle);
/*************************************************************************
* The address of angle.
*
*/
- FT_EXPORT( void )
- FT_Vector_Rotate( FT_Vector* vec,
- FT_Angle angle );
+ FT_EXPORT(void)
+ FT_Vector_Rotate(FT_Vector* vec,
+ FT_Angle angle);
/*************************************************************************
* vector coordinates.
*
*/
- FT_EXPORT( FT_Fixed )
- FT_Vector_Length( FT_Vector* vec );
+ FT_EXPORT(FT_Fixed)
+ FT_Vector_Length(FT_Vector* vec);
/*************************************************************************
* The vector angle.
*
*/
- FT_EXPORT( void )
- FT_Vector_Polarize( FT_Vector* vec,
+ FT_EXPORT(void)
+ FT_Vector_Polarize(FT_Vector* vec,
FT_Fixed *length,
- FT_Angle *angle );
+ FT_Angle *angle);
/*************************************************************************
* The vector angle.
*
*/
- FT_EXPORT( void )
- FT_Vector_From_Polar( FT_Vector* vec,
+ FT_EXPORT(void)
+ FT_Vector_From_Polar(FT_Vector* vec,
FT_Fixed length,
- FT_Angle angle );
+ FT_Angle angle);
/* */
* FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38;
*
*
- * FT_Init_FreeType( &library );
+ * FT_Init_FreeType(&library);
*
- * FT_Property_Set( library, "truetype",
+ * FT_Property_Set(library, "truetype",
* "interpreter-version",
- * &interpreter_version );
+ * &interpreter_version);
* }
*
* @note:
/* The produced values *must* be 32-bit integers. Don't redefine */
/* this macro. */
/* */
-#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
+#define FT_MAKE_TAG(_x1, _x2, _x3, _x4) \
(FT_Tag) \
- ( ( (FT_ULong)_x1 << 24 ) | \
- ( (FT_ULong)_x2 << 16 ) | \
- ( (FT_ULong)_x3 << 8 ) | \
- (FT_ULong)_x4 )
+ (((FT_ULong)_x1 << 24) | \
+ ((FT_ULong)_x2 << 16) | \
+ ((FT_ULong)_x3 << 8) | \
+ (FT_ULong)_x4 )
/*************************************************************************/
/* */
-#define FT_IS_EMPTY( list ) ( (list).head == 0 )
-#define FT_BOOL( x ) ( (FT_Bool)( x ) )
+#define FT_IS_EMPTY(list) ((list).head == 0)
+#define FT_BOOL(x) ((FT_Bool)(x))
/* concatenate C tokens */
-#define FT_ERR_XCAT( x, y ) x ## y
-#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
+#define FT_ERR_XCAT(x, y) x ## y
+#define FT_ERR_CAT(x, y) FT_ERR_XCAT(x, y)
/* see `ftmoderr.h' for descriptions of the following macros */
-#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
+#define FT_ERR(e) FT_ERR_CAT(FT_ERR_PREFIX, e)
-#define FT_ERROR_BASE( x ) ( (x) & 0xFF )
-#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
+#define FT_ERROR_BASE(x) ((x) & 0xFF)
+#define FT_ERROR_MODULE(x) ((x) & 0xFF00U)
-#define FT_ERR_EQ( x, e ) \
- ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) )
-#define FT_ERR_NEQ( x, e ) \
- ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) )
+#define FT_ERR_EQ(x, e) \
+ (FT_ERROR_BASE(x) == FT_ERROR_BASE(FT_ERR(e)))
+#define FT_ERR_NEQ(x, e) \
+ (FT_ERROR_BASE(x) != FT_ERROR_BASE(FT_ERR(e)))
FT_END_HEADER
* This function only works with Windows FNT faces, returning an error
* otherwise.
*/
- FT_EXPORT( FT_Error )
- FT_Get_WinFNT_Header( FT_Face face,
- FT_WinFNT_HeaderRec *aheader );
+ FT_EXPORT(FT_Error)
+ FT_Get_WinFNT_Header(FT_Face face,
+ FT_WinFNT_HeaderRec *aheader);
/* */
/* <Return> */
/* Font format string. NULL in case of error. */
/* */
- FT_EXPORT( const char* )
- FT_Get_X11_Font_Format( FT_Face face );
+ FT_EXPORT(const char*)
+ FT_Get_X11_Font_Format(FT_Face face);
/* */
* Boolean. True if glyph names are reliable.
*
*/
- FT_EXPORT( FT_Int )
- FT_Has_PS_Glyph_Names( FT_Face face );
+ FT_EXPORT(FT_Int)
+ FT_Has_PS_Glyph_Names(FT_Face face);
/************************************************************************
* return the `FT_Err_Invalid_Argument' error code.
*
*/
- FT_EXPORT( FT_Error )
- FT_Get_PS_Font_Info( FT_Face face,
- PS_FontInfo afont_info );
+ FT_EXPORT(FT_Error)
+ FT_Get_PS_Font_Info(FT_Face face,
+ PS_FontInfo afont_info);
/************************************************************************
* the `FT_Err_Invalid_Argument' error code.
*
*/
- FT_EXPORT( FT_Error )
- FT_Get_PS_Font_Private( FT_Face face,
- PS_Private afont_private );
+ FT_EXPORT(FT_Error)
+ FT_Get_PS_Font_Private(FT_Face face,
+ PS_Private afont_private);
/*************************************************************************/
* the `FT_Err_Invalid_Argument' error code.
*
*/
- FT_EXPORT( FT_Long )
- FT_Get_PS_Font_Value( FT_Face face,
+ FT_EXPORT(FT_Long)
+ FT_Get_PS_Font_Value(FT_Face face,
PS_Dict_Keys key,
FT_UInt idx,
void *value,
- FT_Long value_len );
+ FT_Long value_len);
/* */
/* */
/* Some compilers have a very limited length of identifiers. */
/* */
-#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ )
+#if defined(__TURBOC__) && __TURBOC__ < 0x0410 || defined(__PACIFIC__)
#define HAVE_LIMIT_ON_IDENTS
#endif
/* */
/* */
/* vert_header = */
- /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, ft_sfnt_vhea ); */
+ /* (TT_VertHeader*)FT_Get_Sfnt_Table(face, ft_sfnt_vhea); */
/* } */
/* */
- FT_EXPORT( void* )
- FT_Get_Sfnt_Table( FT_Face face,
- FT_Sfnt_Tag tag );
+ FT_EXPORT(void*)
+ FT_Get_Sfnt_Table(FT_Face face,
+ FT_Sfnt_Tag tag);
/**************************************************************************
* FT_ULong length = 0;
*
*
- * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
- * if ( error ) { ... table does not exist ... }
+ * error = FT_Load_Sfnt_Table(face, tag, 0, NULL, &length);
+ * if (error) { ... table does not exist ... }
*
- * buffer = malloc( length );
- * if ( buffer == NULL ) { ... not enough memory ... }
+ * buffer = malloc(length);
+ * if (buffer == NULL) { ... not enough memory ... }
*
- * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
- * if ( error ) { ... could not load table ... }
+ * error = FT_Load_Sfnt_Table(face, tag, 0, buffer, &length);
+ * if (error) { ... could not load table ... }
* }
*
* Note that structures like @TT_Header or @TT_OS2 can't be used with
* size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian).
*
*/
- FT_EXPORT( FT_Error )
- FT_Load_Sfnt_Table( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Load_Sfnt_Table(FT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
- FT_ULong* length );
+ FT_ULong* length);
/**************************************************************************
* missing.
*
*/
- FT_EXPORT( FT_Error )
- FT_Sfnt_Table_Info( FT_Face face,
+ FT_EXPORT(FT_Error)
+ FT_Sfnt_Table_Info(FT_Face face,
FT_UInt table_index,
FT_ULong *tag,
- FT_ULong *length );
+ FT_ULong *length);
/*************************************************************************/
/* For a format~14 cmap (to access Unicode IVS), the return value is */
/* 0xFFFFFFFF. */
/* */
- FT_EXPORT( FT_ULong )
- FT_Get_CMap_Language_ID( FT_CharMap charmap );
+ FT_EXPORT(FT_ULong)
+ FT_Get_CMap_Language_ID(FT_CharMap charmap);
/*************************************************************************/
/* The format of `charmap'. If `charmap' doesn't belong to a */
/* TrueType/sfnt face, return -1. */
/* */
- FT_EXPORT( FT_Long )
- FT_Get_CMap_Format( FT_CharMap charmap );
+ FT_EXPORT(FT_Long)
+ FT_Get_CMap_Format(FT_CharMap charmap);
/* */
FT_BEGIN_HEADER
-#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' )
-#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' )
-#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
-#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' )
-#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
-#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
-#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' )
-#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' )
-#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' )
-#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
-#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
-#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
-#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
-#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
-#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
-#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
-#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
-#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
-#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' )
-#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' )
-#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
-#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
-#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
-#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
-#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
-#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
-#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
-#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
-#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
-#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
-#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
-#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
-#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' )
-#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' )
-#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
-#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
-#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
-#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
-#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' )
-#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
-#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
-#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
-#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
-#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
-#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' )
-#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' )
-#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
-#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' )
-#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
-#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
-#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
-#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' )
-#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
-#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
-#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' )
-#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' )
-#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' )
-#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' )
-#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' )
-#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
-#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
-#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
-#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' )
-#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' )
-#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
-#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
-#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
-#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
+#define TTAG_avar FT_MAKE_TAG('a', 'v', 'a', 'r')
+#define TTAG_BASE FT_MAKE_TAG('B', 'A', 'S', 'E')
+#define TTAG_bdat FT_MAKE_TAG('b', 'd', 'a', 't')
+#define TTAG_BDF FT_MAKE_TAG('B', 'D', 'F', ' ')
+#define TTAG_bhed FT_MAKE_TAG('b', 'h', 'e', 'd')
+#define TTAG_bloc FT_MAKE_TAG('b', 'l', 'o', 'c')
+#define TTAG_bsln FT_MAKE_TAG('b', 's', 'l', 'n')
+#define TTAG_CBDT FT_MAKE_TAG('C', 'B', 'D', 'T')
+#define TTAG_CBLC FT_MAKE_TAG('C', 'B', 'L', 'C')
+#define TTAG_CFF FT_MAKE_TAG('C', 'F', 'F', ' ')
+#define TTAG_CID FT_MAKE_TAG('C', 'I', 'D', ' ')
+#define TTAG_cmap FT_MAKE_TAG('c', 'm', 'a', 'p')
+#define TTAG_cvar FT_MAKE_TAG('c', 'v', 'a', 'r')
+#define TTAG_cvt FT_MAKE_TAG('c', 'v', 't', ' ')
+#define TTAG_DSIG FT_MAKE_TAG('D', 'S', 'I', 'G')
+#define TTAG_EBDT FT_MAKE_TAG('E', 'B', 'D', 'T')
+#define TTAG_EBLC FT_MAKE_TAG('E', 'B', 'L', 'C')
+#define TTAG_EBSC FT_MAKE_TAG('E', 'B', 'S', 'C')
+#define TTAG_feat FT_MAKE_TAG('f', 'e', 'a', 't')
+#define TTAG_FOND FT_MAKE_TAG('F', 'O', 'N', 'D')
+#define TTAG_fpgm FT_MAKE_TAG('f', 'p', 'g', 'm')
+#define TTAG_fvar FT_MAKE_TAG('f', 'v', 'a', 'r')
+#define TTAG_gasp FT_MAKE_TAG('g', 'a', 's', 'p')
+#define TTAG_GDEF FT_MAKE_TAG('G', 'D', 'E', 'F')
+#define TTAG_glyf FT_MAKE_TAG('g', 'l', 'y', 'f')
+#define TTAG_GPOS FT_MAKE_TAG('G', 'P', 'O', 'S')
+#define TTAG_GSUB FT_MAKE_TAG('G', 'S', 'U', 'B')
+#define TTAG_gvar FT_MAKE_TAG('g', 'v', 'a', 'r')
+#define TTAG_hdmx FT_MAKE_TAG('h', 'd', 'm', 'x')
+#define TTAG_head FT_MAKE_TAG('h', 'e', 'a', 'd')
+#define TTAG_hhea FT_MAKE_TAG('h', 'h', 'e', 'a')
+#define TTAG_hmtx FT_MAKE_TAG('h', 'm', 't', 'x')
+#define TTAG_JSTF FT_MAKE_TAG('J', 'S', 'T', 'F')
+#define TTAG_just FT_MAKE_TAG('j', 'u', 's', 't')
+#define TTAG_kern FT_MAKE_TAG('k', 'e', 'r', 'n')
+#define TTAG_lcar FT_MAKE_TAG('l', 'c', 'a', 'r')
+#define TTAG_loca FT_MAKE_TAG('l', 'o', 'c', 'a')
+#define TTAG_LTSH FT_MAKE_TAG('L', 'T', 'S', 'H')
+#define TTAG_LWFN FT_MAKE_TAG('L', 'W', 'F', 'N')
+#define TTAG_MATH FT_MAKE_TAG('M', 'A', 'T', 'H')
+#define TTAG_maxp FT_MAKE_TAG('m', 'a', 'x', 'p')
+#define TTAG_META FT_MAKE_TAG('M', 'E', 'T', 'A')
+#define TTAG_MMFX FT_MAKE_TAG('M', 'M', 'F', 'X')
+#define TTAG_MMSD FT_MAKE_TAG('M', 'M', 'S', 'D')
+#define TTAG_mort FT_MAKE_TAG('m', 'o', 'r', 't')
+#define TTAG_morx FT_MAKE_TAG('m', 'o', 'r', 'x')
+#define TTAG_name FT_MAKE_TAG('n', 'a', 'm', 'e')
+#define TTAG_opbd FT_MAKE_TAG('o', 'p', 'b', 'd')
+#define TTAG_OS2 FT_MAKE_TAG('O', 'S', '/', '2')
+#define TTAG_OTTO FT_MAKE_TAG('O', 'T', 'T', 'O')
+#define TTAG_PCLT FT_MAKE_TAG('P', 'C', 'L', 'T')
+#define TTAG_POST FT_MAKE_TAG('P', 'O', 'S', 'T')
+#define TTAG_post FT_MAKE_TAG('p', 'o', 's', 't')
+#define TTAG_prep FT_MAKE_TAG('p', 'r', 'e', 'p')
+#define TTAG_prop FT_MAKE_TAG('p', 'r', 'o', 'p')
+#define TTAG_sbix FT_MAKE_TAG('s', 'b', 'i', 'x')
+#define TTAG_sfnt FT_MAKE_TAG('s', 'f', 'n', 't')
+#define TTAG_SING FT_MAKE_TAG('S', 'I', 'N', 'G')
+#define TTAG_trak FT_MAKE_TAG('t', 'r', 'a', 'k')
+#define TTAG_true FT_MAKE_TAG('t', 'r', 'u', 'e')
+#define TTAG_ttc FT_MAKE_TAG('t', 't', 'c', ' ')
+#define TTAG_ttcf FT_MAKE_TAG('t', 't', 'c', 'f')
+#define TTAG_TYP1 FT_MAKE_TAG('T', 'Y', 'P', '1')
+#define TTAG_typ1 FT_MAKE_TAG('t', 'y', 'p', '1')
+#define TTAG_VDMX FT_MAKE_TAG('V', 'D', 'M', 'X')
+#define TTAG_vhea FT_MAKE_TAG('v', 'h', 'e', 'a')
+#define TTAG_vmtx FT_MAKE_TAG('v', 'm', 't', 'x')
+#define TTAG_wOFF FT_MAKE_TAG('w', 'O', 'F', 'F')
FT_END_HEADER
* interpreter for a typeface opened by @FT_Open_Face.
*
*/
-#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' )
+#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG('u', 'n', 'p', 'a')
/* */
Texturec(uint amt,const char **paths);
Texturec(std::vector<std::string>vec);
- Texturec( std::initializer_list<std::string> l );
+ Texturec(std::initializer_list<std::string> l);
/**
* Frees memory taken by the image array.
AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h\r
*/\r
\r
-#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)\r
+#if defined(_DEBUG) || defined(DEBUG) || defined (__DEBUG__)\r
# ifndef DEBUG\r
# define DEBUG\r
# endif\r
#if defined(DEBUG)\r
# if defined(_MSC_VER)\r
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like\r
-# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }\r
+# define TIXMLASSERT(x) if (!((void)0,(x))) { __debugbreak(); }\r
# elif defined (ANDROID_NDK)\r
# include <android/log.h>\r
-# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }\r
+# define TIXMLASSERT(x) if (!(x)) { __android_log_assert("assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__); }\r
# else\r
# include <assert.h>\r
# define TIXMLASSERT assert\r
# endif\r
#else\r
-# define TIXMLASSERT( x ) {}\r
+# define TIXMLASSERT(x) {}\r
#endif\r
\r
\r
COMMENT = NEEDS_NEWLINE_NORMALIZATION\r
};\r
\r
- StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}\r
+ StrPair() : _flags(0), _start(0), _end(0) {}\r
~StrPair();\r
\r
- void Set( char* start, char* end, int flags ) {\r
+ void Set(char* start, char* end, int flags) {\r
Reset();\r
_start = start;\r
_end = end;\r
return _start == _end;\r
}\r
\r
- void SetInternedStr( const char* str ) {\r
+ void SetInternedStr(const char* str) {\r
Reset();\r
_start = const_cast<char*>(str);\r
}\r
\r
- void SetStr( const char* str, int flags=0 );\r
+ void SetStr(const char* str, int flags=0);\r
\r
- char* ParseText( char* in, const char* endTag, int strFlags );\r
- char* ParseName( char* in );\r
+ char* ParseText(char* in, const char* endTag, int strFlags);\r
+ char* ParseName(char* in);\r
\r
- void TransferTo( StrPair* other );\r
+ void TransferTo(StrPair* other);\r
\r
private:\r
void Reset();\r
char* _start;\r
char* _end;\r
\r
- StrPair( const StrPair& other ); // not supported\r
- void operator=( StrPair& other ); // not supported, use TransferTo()\r
+ StrPair(const StrPair& other); // not supported\r
+ void operator=(StrPair& other); // not supported, use TransferTo()\r
};\r
\r
\r
}\r
\r
~DynArray() {\r
- if ( _mem != _pool ) {\r
+ if (_mem != _pool) {\r
delete [] _mem;\r
}\r
}\r
_size = 0;\r
}\r
\r
- void Push( T t ) {\r
- TIXMLASSERT( _size < INT_MAX );\r
- EnsureCapacity( _size+1 );\r
+ void Push(T t) {\r
+ TIXMLASSERT(_size < INT_MAX);\r
+ EnsureCapacity(_size+1);\r
_mem[_size++] = t;\r
}\r
\r
- T* PushArr( int count ) {\r
- TIXMLASSERT( count >= 0 );\r
- TIXMLASSERT( _size <= INT_MAX - count );\r
- EnsureCapacity( _size+count );\r
+ T* PushArr(int count) {\r
+ TIXMLASSERT(count >= 0);\r
+ TIXMLASSERT(_size <= INT_MAX - count);\r
+ EnsureCapacity(_size+count);\r
T* ret = &_mem[_size];\r
_size += count;\r
return ret;\r
}\r
\r
T Pop() {\r
- TIXMLASSERT( _size > 0 );\r
+ TIXMLASSERT(_size > 0);\r
return _mem[--_size];\r
}\r
\r
- void PopArr( int count ) {\r
- TIXMLASSERT( _size >= count );\r
+ void PopArr(int count) {\r
+ TIXMLASSERT(_size >= count);\r
_size -= count;\r
}\r
\r
}\r
\r
T& operator[](int i) {\r
- TIXMLASSERT( i>= 0 && i < _size );\r
+ TIXMLASSERT(i>= 0 && i < _size);\r
return _mem[i];\r
}\r
\r
const T& operator[](int i) const {\r
- TIXMLASSERT( i>= 0 && i < _size );\r
+ TIXMLASSERT(i>= 0 && i < _size);\r
return _mem[i];\r
}\r
\r
const T& PeekTop() const {\r
- TIXMLASSERT( _size > 0 );\r
+ TIXMLASSERT(_size > 0);\r
return _mem[ _size - 1];\r
}\r
\r
int Size() const {\r
- TIXMLASSERT( _size >= 0 );\r
+ TIXMLASSERT(_size >= 0);\r
return _size;\r
}\r
\r
int Capacity() const {\r
- TIXMLASSERT( _allocated >= INITIAL_SIZE );\r
+ TIXMLASSERT(_allocated >= INITIAL_SIZE);\r
return _allocated;\r
}\r
\r
const T* Mem() const {\r
- TIXMLASSERT( _mem );\r
+ TIXMLASSERT(_mem);\r
return _mem;\r
}\r
\r
T* Mem() {\r
- TIXMLASSERT( _mem );\r
+ TIXMLASSERT(_mem);\r
return _mem;\r
}\r
\r
private:\r
- DynArray( const DynArray& ); // not supported\r
- void operator=( const DynArray& ); // not supported\r
+ DynArray(const DynArray&); // not supported\r
+ void operator=(const DynArray&); // not supported\r
\r
- void EnsureCapacity( int cap ) {\r
- TIXMLASSERT( cap > 0 );\r
- if ( cap > _allocated ) {\r
- TIXMLASSERT( cap <= INT_MAX / 2 );\r
+ void EnsureCapacity(int cap) {\r
+ TIXMLASSERT(cap > 0);\r
+ if (cap > _allocated) {\r
+ TIXMLASSERT(cap <= INT_MAX / 2);\r
int newAllocated = cap * 2;\r
T* newMem = new T[newAllocated];\r
- memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs\r
- if ( _mem != _pool ) {\r
+ memcpy(newMem, _mem, sizeof(T)*_size); // warning: not using constructors, only works for PODs\r
+ if (_mem != _pool) {\r
delete [] _mem;\r
}\r
_mem = newMem;\r
\r
virtual int ItemSize() const = 0;\r
virtual void* Alloc() = 0;\r
- virtual void Free( void* ) = 0;\r
+ virtual void Free(void*) = 0;\r
virtual void SetTracked() = 0;\r
virtual void Clear() = 0;\r
};\r
\r
void Clear() {\r
// Delete the blocks.\r
- while( !_blockPtrs.Empty()) {\r
+ while(!_blockPtrs.Empty()) {\r
Block* b = _blockPtrs.Pop();\r
delete b;\r
}\r
}\r
\r
virtual void* Alloc() {\r
- if ( !_root ) {\r
+ if (!_root) {\r
// Need a new block.\r
Block* block = new Block();\r
- _blockPtrs.Push( block );\r
+ _blockPtrs.Push(block);\r
\r
- for( int i=0; i<COUNT-1; ++i ) {\r
+ for(int i=0; i<COUNT-1; ++i) {\r
block->chunk[i].next = &block->chunk[i+1];\r
}\r
block->chunk[COUNT-1].next = 0;\r
_root = _root->next;\r
\r
++_currentAllocs;\r
- if ( _currentAllocs > _maxAllocs ) {\r
+ if (_currentAllocs > _maxAllocs) {\r
_maxAllocs = _currentAllocs;\r
}\r
_nAllocs++;\r
return result;\r
}\r
\r
- virtual void Free( void* mem ) {\r
- if ( !mem ) {\r
+ virtual void Free(void* mem) {\r
+ if (!mem) {\r
return;\r
}\r
--_currentAllocs;\r
- Chunk* chunk = static_cast<Chunk*>( mem );\r
+ Chunk* chunk = static_cast<Chunk*>(mem);\r
#ifdef DEBUG\r
- memset( chunk, 0xfe, sizeof(Chunk) );\r
+ memset(chunk, 0xfe, sizeof(Chunk));\r
#endif\r
chunk->next = _root;\r
_root = chunk;\r
}\r
- void Trace( const char* name ) {\r
- printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",\r
- name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );\r
+ void Trace(const char* name) {\r
+ printf("Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",\r
+ name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size());\r
}\r
\r
void SetTracked() {\r
enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private\r
\r
private:\r
- MemPoolT( const MemPoolT& ); // not supported\r
- void operator=( const MemPoolT& ); // not supported\r
+ MemPoolT(const MemPoolT&); // not supported\r
+ void operator=(const MemPoolT&); // not supported\r
\r
union Chunk {\r
Chunk* next;\r
virtual ~XMLVisitor() {}\r
\r
/// Visit a document.\r
- virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {\r
+ virtual bool VisitEnter(const XMLDocument& /*doc*/) {\r
return true;\r
}\r
/// Visit a document.\r
- virtual bool VisitExit( const XMLDocument& /*doc*/ ) {\r
+ virtual bool VisitExit(const XMLDocument& /*doc*/) {\r
return true;\r
}\r
\r
/// Visit an element.\r
- virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {\r
+ virtual bool VisitEnter(const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/) {\r
return true;\r
}\r
/// Visit an element.\r
- virtual bool VisitExit( const XMLElement& /*element*/ ) {\r
+ virtual bool VisitExit(const XMLElement& /*element*/) {\r
return true;\r
}\r
\r
/// Visit a declaration.\r
- virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {\r
+ virtual bool Visit(const XMLDeclaration& /*declaration*/) {\r
return true;\r
}\r
/// Visit a text node.\r
- virtual bool Visit( const XMLText& /*text*/ ) {\r
+ virtual bool Visit(const XMLText& /*text*/) {\r
return true;\r
}\r
/// Visit a comment node.\r
- virtual bool Visit( const XMLComment& /*comment*/ ) {\r
+ virtual bool Visit(const XMLComment& /*comment*/) {\r
return true;\r
}\r
/// Visit an unknown node.\r
- virtual bool Visit( const XMLUnknown& /*unknown*/ ) {\r
+ virtual bool Visit(const XMLUnknown& /*unknown*/) {\r
return true;\r
}\r
};\r
class XMLUtil\r
{\r
public:\r
- static const char* SkipWhiteSpace( const char* p ) {\r
- TIXMLASSERT( p );\r
- while( IsWhiteSpace(*p) ) {\r
+ static const char* SkipWhiteSpace(const char* p) {\r
+ TIXMLASSERT(p);\r
+ while(IsWhiteSpace(*p)) {\r
++p;\r
}\r
- TIXMLASSERT( p );\r
+ TIXMLASSERT(p);\r
return p;\r
}\r
- static char* SkipWhiteSpace( char* p ) {\r
- return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );\r
+ static char* SkipWhiteSpace(char* p) {\r
+ return const_cast<char*>(SkipWhiteSpace(const_cast<const char*>(p)));\r
}\r
\r
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't\r
// correct, but simple, and usually works.\r
- static bool IsWhiteSpace( char p ) {\r
- return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );\r
+ static bool IsWhiteSpace(char p) {\r
+ return !IsUTF8Continuation(p) && isspace(static_cast<unsigned char>(p));\r
}\r
\r
- inline static bool IsNameStartChar( unsigned char ch ) {\r
- if ( ch >= 128 ) {\r
+ inline static bool IsNameStartChar(unsigned char ch) {\r
+ if (ch >= 128) {\r
// This is a heuristic guess in attempt to not implement Unicode-aware isalpha()\r
return true;\r
}\r
- if ( isalpha( ch ) ) {\r
+ if (isalpha(ch)) {\r
return true;\r
}\r
return ch == ':' || ch == '_';\r
}\r
\r
- inline static bool IsNameChar( unsigned char ch ) {\r
- return IsNameStartChar( ch )\r
- || isdigit( ch )\r
+ inline static bool IsNameChar(unsigned char ch) {\r
+ return IsNameStartChar(ch)\r
+ || isdigit(ch)\r
|| ch == '.'\r
|| ch == '-';\r
}\r
\r
- inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {\r
- if ( p == q ) {\r
+ inline static bool StringEqual(const char* p, const char* q, int nChar=INT_MAX) {\r
+ if (p == q) {\r
return true;\r
}\r
- return strncmp( p, q, nChar ) == 0;\r
+ return strncmp(p, q, nChar) == 0;\r
}\r
\r
- inline static bool IsUTF8Continuation( char p ) {\r
- return ( p & 0x80 ) != 0;\r
+ inline static bool IsUTF8Continuation(char p) {\r
+ return (p & 0x80) != 0;\r
}\r
\r
- static const char* ReadBOM( const char* p, bool* hasBOM );\r
+ static const char* ReadBOM(const char* p, bool* hasBOM);\r
// p is the starting location,\r
// the UTF-8 value of the entity will be placed in value, and length filled in.\r
- static const char* GetCharacterRef( const char* p, char* value, int* length );\r
- static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );\r
+ static const char* GetCharacterRef(const char* p, char* value, int* length);\r
+ static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length);\r
\r
// converts primitive types to strings\r
- static void ToStr( int v, char* buffer, int bufferSize );\r
- static void ToStr( unsigned v, char* buffer, int bufferSize );\r
- static void ToStr( bool v, char* buffer, int bufferSize );\r
- static void ToStr( float v, char* buffer, int bufferSize );\r
- static void ToStr( double v, char* buffer, int bufferSize );\r
+ static void ToStr(int v, char* buffer, int bufferSize);\r
+ static void ToStr(unsigned v, char* buffer, int bufferSize);\r
+ static void ToStr(bool v, char* buffer, int bufferSize);\r
+ static void ToStr(float v, char* buffer, int bufferSize);\r
+ static void ToStr(double v, char* buffer, int bufferSize);\r
\r
// converts strings to primitive types\r
- static bool ToInt( const char* str, int* value );\r
- static bool ToUnsigned( const char* str, unsigned* value );\r
- static bool ToBool( const char* str, bool* value );\r
- static bool ToFloat( const char* str, float* value );\r
- static bool ToDouble( const char* str, double* value );\r
+ static bool ToInt(const char* str, int* value);\r
+ static bool ToUnsigned(const char* str, unsigned* value);\r
+ static bool ToBool(const char* str, bool* value);\r
+ static bool ToFloat(const char* str, float* value);\r
+ static bool ToDouble(const char* str, double* value);\r
};\r
\r
\r
A Document can contain: Element (container or leaf)\r
Comment (leaf)\r
Unknown (leaf)\r
- Declaration( leaf )\r
+ Declaration(leaf)\r
\r
An Element can contain: Element (container or leaf)\r
Text (leaf)\r
\r
/// Get the XMLDocument that owns this XMLNode.\r
const XMLDocument* GetDocument() const {\r
- TIXMLASSERT( _document );\r
+ TIXMLASSERT(_document);\r
return _document;\r
}\r
/// Get the XMLDocument that owns this XMLNode.\r
XMLDocument* GetDocument() {\r
- TIXMLASSERT( _document );\r
+ TIXMLASSERT(_document);\r
return _document;\r
}\r
\r
/** Set the Value of an XML node.\r
@sa Value()\r
*/\r
- void SetValue( const char* val, bool staticMem=false );\r
+ void SetValue(const char* val, bool staticMem=false);\r
\r
/// Get the parent of this node on the DOM.\r
const XMLNode* Parent() const {\r
/** Get the first child element, or optionally the first child\r
element with the specified name.\r
*/\r
- const XMLElement* FirstChildElement( const char* name = 0 ) const;\r
+ const XMLElement* FirstChildElement(const char* name = 0) const;\r
\r
- XMLElement* FirstChildElement( const char* name = 0 ) {\r
- return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));\r
+ XMLElement* FirstChildElement(const char* name = 0) {\r
+ return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement(name));\r
}\r
\r
/// Get the last child node, or null if none exists.\r
/** Get the last child element or optionally the last child\r
element with the specified name.\r
*/\r
- const XMLElement* LastChildElement( const char* name = 0 ) const;\r
+ const XMLElement* LastChildElement(const char* name = 0) const;\r
\r
- XMLElement* LastChildElement( const char* name = 0 ) {\r
- return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );\r
+ XMLElement* LastChildElement(const char* name = 0) {\r
+ return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name));\r
}\r
\r
/// Get the previous (left) sibling node of this node.\r
}\r
\r
/// Get the previous (left) sibling element of this node, with an optionally supplied name.\r
- const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;\r
+ const XMLElement* PreviousSiblingElement(const char* name = 0) const ;\r
\r
- XMLElement* PreviousSiblingElement( const char* name = 0 ) {\r
- return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );\r
+ XMLElement* PreviousSiblingElement(const char* name = 0) {\r
+ return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement(name));\r
}\r
\r
/// Get the next (right) sibling node of this node.\r
}\r
\r
/// Get the next (right) sibling element of this node, with an optionally supplied name.\r
- const XMLElement* NextSiblingElement( const char* name = 0 ) const;\r
+ const XMLElement* NextSiblingElement(const char* name = 0) const;\r
\r
- XMLElement* NextSiblingElement( const char* name = 0 ) {\r
- return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );\r
+ XMLElement* NextSiblingElement(const char* name = 0) {\r
+ return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement(name));\r
}\r
\r
/**\r
Returns the addThis argument or 0 if the node does not\r
belong to the same document.\r
*/\r
- XMLNode* InsertEndChild( XMLNode* addThis );\r
+ XMLNode* InsertEndChild(XMLNode* addThis);\r
\r
- XMLNode* LinkEndChild( XMLNode* addThis ) {\r
- return InsertEndChild( addThis );\r
+ XMLNode* LinkEndChild(XMLNode* addThis) {\r
+ return InsertEndChild(addThis);\r
}\r
/**\r
Add a child node as the first (left) child.\r
Returns the addThis argument or 0 if the node does not\r
belong to the same document.\r
*/\r
- XMLNode* InsertFirstChild( XMLNode* addThis );\r
+ XMLNode* InsertFirstChild(XMLNode* addThis);\r
/**\r
Add a node after the specified child node.\r
If the child node is already part of the document,\r
is not a child of this node, or if the node does not\r
belong to the same document.\r
*/\r
- XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );\r
+ XMLNode* InsertAfterChild(XMLNode* afterThis, XMLNode* addThis);\r
\r
/**\r
Delete all the children of this node.\r
/**\r
Delete a child of this node.\r
*/\r
- void DeleteChild( XMLNode* node );\r
+ void DeleteChild(XMLNode* node);\r
\r
/**\r
Make a copy of this node, but not its children.\r
\r
Note: if called on a XMLDocument, this will return null.\r
*/\r
- virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;\r
+ virtual XMLNode* ShallowClone(XMLDocument* document) const = 0;\r
\r
/**\r
Test if 2 nodes are the same, but don't test children.\r
\r
Note: if called on a XMLDocument, this will return false.\r
*/\r
- virtual bool ShallowEqual( const XMLNode* compare ) const = 0;\r
+ virtual bool ShallowEqual(const XMLNode* compare) const = 0;\r
\r
/** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the\r
XML tree will be conditionally visited and the host will be called back\r
An example of using Accept():\r
@verbatim\r
XMLPrinter printer;\r
- tinyxmlDoc.Accept( &printer );\r
+ tinyxmlDoc.Accept(&printer);\r
const char* xmlcstr = printer.CStr();\r
@endverbatim\r
*/\r
- virtual bool Accept( XMLVisitor* visitor ) const = 0;\r
+ virtual bool Accept(XMLVisitor* visitor) const = 0;\r
\r
protected:\r
- XMLNode( XMLDocument* );\r
+ XMLNode(XMLDocument*);\r
virtual ~XMLNode();\r
\r
- virtual char* ParseDeep( char*, StrPair* );\r
+ virtual char* ParseDeep(char*, StrPair*);\r
\r
XMLDocument* _document;\r
XMLNode* _parent;\r
\r
private:\r
MemPool* _memPool;\r
- void Unlink( XMLNode* child );\r
- static void DeleteNode( XMLNode* node );\r
- void InsertChildPreamble( XMLNode* insertThis ) const;\r
+ void Unlink(XMLNode* child);\r
+ static void DeleteNode(XMLNode* node);\r
+ void InsertChildPreamble(XMLNode* insertThis) const;\r
\r
- XMLNode( const XMLNode& ); // not supported\r
- XMLNode& operator=( const XMLNode& ); // not supported\r
+ XMLNode(const XMLNode&); // not supported\r
+ XMLNode& operator=(const XMLNode&); // not supported\r
};\r
\r
\r
friend class XMLBase;\r
friend class XMLDocument;\r
public:\r
- virtual bool Accept( XMLVisitor* visitor ) const;\r
+ virtual bool Accept(XMLVisitor* visitor) const;\r
\r
virtual XMLText* ToText() {\r
return this;\r
}\r
\r
/// Declare whether this should be CDATA or standard text.\r
- void SetCData( bool isCData ) {\r
+ void SetCData(bool isCData) {\r
_isCData = isCData;\r
}\r
/// Returns true if this is a CDATA text element.\r
return _isCData;\r
}\r
\r
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;\r
- virtual bool ShallowEqual( const XMLNode* compare ) const;\r
+ virtual XMLNode* ShallowClone(XMLDocument* document) const;\r
+ virtual bool ShallowEqual(const XMLNode* compare) const;\r
\r
protected:\r
- XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}\r
+ XMLText(XMLDocument* doc) : XMLNode(doc), _isCData(false) {}\r
virtual ~XMLText() {}\r
\r
- char* ParseDeep( char*, StrPair* endTag );\r
+ char* ParseDeep(char*, StrPair* endTag);\r
\r
private:\r
bool _isCData;\r
\r
- XMLText( const XMLText& ); // not supported\r
- XMLText& operator=( const XMLText& ); // not supported\r
+ XMLText(const XMLText&); // not supported\r
+ XMLText& operator=(const XMLText&); // not supported\r
};\r
\r
\r
return this;\r
}\r
\r
- virtual bool Accept( XMLVisitor* visitor ) const;\r
+ virtual bool Accept(XMLVisitor* visitor) const;\r
\r
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;\r
- virtual bool ShallowEqual( const XMLNode* compare ) const;\r
+ virtual XMLNode* ShallowClone(XMLDocument* document) const;\r
+ virtual bool ShallowEqual(const XMLNode* compare) const;\r
\r
protected:\r
- XMLComment( XMLDocument* doc );\r
+ XMLComment(XMLDocument* doc);\r
virtual ~XMLComment();\r
\r
- char* ParseDeep( char*, StrPair* endTag );\r
+ char* ParseDeep(char*, StrPair* endTag);\r
\r
private:\r
- XMLComment( const XMLComment& ); // not supported\r
- XMLComment& operator=( const XMLComment& ); // not supported\r
+ XMLComment(const XMLComment&); // not supported\r
+ XMLComment& operator=(const XMLComment&); // not supported\r
};\r
\r
\r
return this;\r
}\r
\r
- virtual bool Accept( XMLVisitor* visitor ) const;\r
+ virtual bool Accept(XMLVisitor* visitor) const;\r
\r
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;\r
- virtual bool ShallowEqual( const XMLNode* compare ) const;\r
+ virtual XMLNode* ShallowClone(XMLDocument* document) const;\r
+ virtual bool ShallowEqual(const XMLNode* compare) const;\r
\r
protected:\r
- XMLDeclaration( XMLDocument* doc );\r
+ XMLDeclaration(XMLDocument* doc);\r
virtual ~XMLDeclaration();\r
\r
- char* ParseDeep( char*, StrPair* endTag );\r
+ char* ParseDeep(char*, StrPair* endTag);\r
\r
private:\r
- XMLDeclaration( const XMLDeclaration& ); // not supported\r
- XMLDeclaration& operator=( const XMLDeclaration& ); // not supported\r
+ XMLDeclaration(const XMLDeclaration&); // not supported\r
+ XMLDeclaration& operator=(const XMLDeclaration&); // not supported\r
};\r
\r
\r
return this;\r
}\r
\r
- virtual bool Accept( XMLVisitor* visitor ) const;\r
+ virtual bool Accept(XMLVisitor* visitor) const;\r
\r
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;\r
- virtual bool ShallowEqual( const XMLNode* compare ) const;\r
+ virtual XMLNode* ShallowClone(XMLDocument* document) const;\r
+ virtual bool ShallowEqual(const XMLNode* compare) const;\r
\r
protected:\r
- XMLUnknown( XMLDocument* doc );\r
+ XMLUnknown(XMLDocument* doc);\r
virtual ~XMLUnknown();\r
\r
- char* ParseDeep( char*, StrPair* endTag );\r
+ char* ParseDeep(char*, StrPair* endTag);\r
\r
private:\r
- XMLUnknown( const XMLUnknown& ); // not supported\r
- XMLUnknown& operator=( const XMLUnknown& ); // not supported\r
+ XMLUnknown(const XMLUnknown&); // not supported\r
+ XMLUnknown& operator=(const XMLUnknown&); // not supported\r
};\r
\r
\r
*/\r
int IntValue() const {\r
int i=0;\r
- QueryIntValue( &i );\r
+ QueryIntValue(&i);\r
return i;\r
}\r
/// Query as an unsigned integer. See IntValue()\r
unsigned UnsignedValue() const {\r
unsigned i=0;\r
- QueryUnsignedValue( &i );\r
+ QueryUnsignedValue(&i);\r
return i;\r
}\r
/// Query as a boolean. See IntValue()\r
bool BoolValue() const {\r
bool b=false;\r
- QueryBoolValue( &b );\r
+ QueryBoolValue(&b);\r
return b;\r
}\r
/// Query as a double. See IntValue()\r
double DoubleValue() const {\r
double d=0;\r
- QueryDoubleValue( &d );\r
+ QueryDoubleValue(&d);\r
return d;\r
}\r
/// Query as a float. See IntValue()\r
float FloatValue() const {\r
float f=0;\r
- QueryFloatValue( &f );\r
+ QueryFloatValue(&f);\r
return f;\r
}\r
\r
in the provided parameter. The function will return XML_NO_ERROR on success,\r
and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.\r
*/\r
- XMLError QueryIntValue( int* value ) const;\r
+ XMLError QueryIntValue(int* value) const;\r
/// See QueryIntValue\r
- XMLError QueryUnsignedValue( unsigned int* value ) const;\r
+ XMLError QueryUnsignedValue(unsigned int* value) const;\r
/// See QueryIntValue\r
- XMLError QueryBoolValue( bool* value ) const;\r
+ XMLError QueryBoolValue(bool* value) const;\r
/// See QueryIntValue\r
- XMLError QueryDoubleValue( double* value ) const;\r
+ XMLError QueryDoubleValue(double* value) const;\r
/// See QueryIntValue\r
- XMLError QueryFloatValue( float* value ) const;\r
+ XMLError QueryFloatValue(float* value) const;\r
\r
/// Set the attribute to a string value.\r
- void SetAttribute( const char* value );\r
+ void SetAttribute(const char* value);\r
/// Set the attribute to value.\r
- void SetAttribute( int value );\r
+ void SetAttribute(int value);\r
/// Set the attribute to value.\r
- void SetAttribute( unsigned value );\r
+ void SetAttribute(unsigned value);\r
/// Set the attribute to value.\r
- void SetAttribute( bool value );\r
+ void SetAttribute(bool value);\r
/// Set the attribute to value.\r
- void SetAttribute( double value );\r
+ void SetAttribute(double value);\r
/// Set the attribute to value.\r
- void SetAttribute( float value );\r
+ void SetAttribute(float value);\r
\r
private:\r
enum { BUF_SIZE = 200 };\r
\r
- XMLAttribute() : _next( 0 ), _memPool( 0 ) {}\r
+ XMLAttribute() : _next(0), _memPool(0) {}\r
virtual ~XMLAttribute() {}\r
\r
- XMLAttribute( const XMLAttribute& ); // not supported\r
- void operator=( const XMLAttribute& ); // not supported\r
- void SetName( const char* name );\r
+ XMLAttribute(const XMLAttribute&); // not supported\r
+ void operator=(const XMLAttribute&); // not supported\r
+ void SetName(const char* name);\r
\r
- char* ParseDeep( char* p, bool processEntities );\r
+ char* ParseDeep(char* p, bool processEntities);\r
\r
mutable StrPair _name;\r
mutable StrPair _value;\r
return Value();\r
}\r
/// Set the name of the element.\r
- void SetName( const char* str, bool staticMem=false ) {\r
- SetValue( str, staticMem );\r
+ void SetName(const char* str, bool staticMem=false) {\r
+ SetValue(str, staticMem);\r
}\r
\r
virtual XMLElement* ToElement() {\r
virtual const XMLElement* ToElement() const {\r
return this;\r
}\r
- virtual bool Accept( XMLVisitor* visitor ) const;\r
+ virtual bool Accept(XMLVisitor* visitor) const;\r
\r
/** Given an attribute name, Attribute() returns the value\r
for the attribute of that name, or null if none\r
exists. For example:\r
\r
@verbatim\r
- const char* value = ele->Attribute( "foo" );\r
+ const char* value = ele->Attribute("foo");\r
@endverbatim\r
\r
The 'value' parameter is normally null. However, if specified,\r
match. This allow you to write code:\r
\r
@verbatim\r
- if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();\r
+ if (ele->Attribute("foo", "bar")) callFooIsBar();\r
@endverbatim\r
\r
rather than:\r
@verbatim\r
- if ( ele->Attribute( "foo" ) ) {\r
- if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();\r
+ if (ele->Attribute("foo")) {\r
+ if (strcmp(ele->Attribute("foo"), "bar") == 0) callFooIsBar();\r
}\r
@endverbatim\r
*/\r
- const char* Attribute( const char* name, const char* value=0 ) const;\r
+ const char* Attribute(const char* name, const char* value=0) const;\r
\r
/** Functions the same as Attribute(), but returns the result\r
as a std::string.\r
*/\r
- std::string StrAttribute( const char* name, const char* value=0 ) const;\r
+ std::string StrAttribute(const char* name, const char* value=0) const;\r
\r
/** Given an attribute name, IntAttribute() returns the value\r
of the attribute interpreted as an integer. 0 will be\r
returned if there is an error. For a method with error\r
checking, see QueryIntAttribute()\r
*/\r
- int IntAttribute( const char* name ) const {\r
+ int IntAttribute(const char* name) const {\r
int i=0;\r
- QueryIntAttribute( name, &i );\r
+ QueryIntAttribute(name, &i);\r
return i;\r
}\r
/// See IntAttribute()\r
- unsigned UnsignedAttribute( const char* name ) const {\r
+ unsigned UnsignedAttribute(const char* name) const {\r
unsigned i=0;\r
- QueryUnsignedAttribute( name, &i );\r
+ QueryUnsignedAttribute(name, &i);\r
return i;\r
}\r
/// See IntAttribute()\r
- bool BoolAttribute( const char* name ) const {\r
+ bool BoolAttribute(const char* name) const {\r
bool b=false;\r
- QueryBoolAttribute( name, &b );\r
+ QueryBoolAttribute(name, &b);\r
return b;\r
}\r
/// See IntAttribute()\r
- double DoubleAttribute( const char* name ) const {\r
+ double DoubleAttribute(const char* name) const {\r
double d=0;\r
- QueryDoubleAttribute( name, &d );\r
+ QueryDoubleAttribute(name, &d);\r
return d;\r
}\r
/// See IntAttribute()\r
- float FloatAttribute( const char* name ) const {\r
+ float FloatAttribute(const char* name) const {\r
float f=0;\r
- QueryFloatAttribute( name, &f );\r
+ QueryFloatAttribute(name, &f);\r
return f;\r
}\r
\r
\r
@verbatim\r
int value = 10;\r
- QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10\r
+ QueryIntAttribute("foo", &value); // if "foo" isn't found, value will still be 10\r
@endverbatim\r
*/\r
- XMLError QueryIntAttribute( const char* name, int* value ) const {\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( !a ) {\r
+ XMLError QueryIntAttribute(const char* name, int* value) const {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (!a) {\r
return XML_NO_ATTRIBUTE;\r
}\r
- return a->QueryIntValue( value );\r
+ return a->QueryIntValue(value);\r
}\r
/// See QueryIntAttribute()\r
- XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( !a ) {\r
+ XMLError QueryUnsignedAttribute(const char* name, unsigned int* value) const {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (!a) {\r
return XML_NO_ATTRIBUTE;\r
}\r
- return a->QueryUnsignedValue( value );\r
+ return a->QueryUnsignedValue(value);\r
}\r
/// See QueryIntAttribute()\r
- XMLError QueryBoolAttribute( const char* name, bool* value ) const {\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( !a ) {\r
+ XMLError QueryBoolAttribute(const char* name, bool* value) const {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (!a) {\r
return XML_NO_ATTRIBUTE;\r
}\r
- return a->QueryBoolValue( value );\r
+ return a->QueryBoolValue(value);\r
}\r
/// See QueryIntAttribute()\r
- XMLError QueryDoubleAttribute( const char* name, double* value ) const {\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( !a ) {\r
+ XMLError QueryDoubleAttribute(const char* name, double* value) const {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (!a) {\r
return XML_NO_ATTRIBUTE;\r
}\r
- return a->QueryDoubleValue( value );\r
+ return a->QueryDoubleValue(value);\r
}\r
/// See QueryIntAttribute()\r
- XMLError QueryFloatAttribute( const char* name, float* value ) const {\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( !a ) {\r
+ XMLError QueryFloatAttribute(const char* name, float* value) const {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (!a) {\r
return XML_NO_ATTRIBUTE;\r
}\r
- return a->QueryFloatValue( value );\r
+ return a->QueryFloatValue(value);\r
}\r
\r
\r
\r
@verbatim\r
int value = 10;\r
- QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10\r
+ QueryAttribute("foo", &value); // if "foo" isn't found, value will still be 10\r
@endverbatim\r
*/\r
- int QueryAttribute( const char* name, int* value ) const {\r
- return QueryIntAttribute( name, value );\r
+ int QueryAttribute(const char* name, int* value) const {\r
+ return QueryIntAttribute(name, value);\r
}\r
\r
- int QueryAttribute( const char* name, unsigned int* value ) const {\r
- return QueryUnsignedAttribute( name, value );\r
+ int QueryAttribute(const char* name, unsigned int* value) const {\r
+ return QueryUnsignedAttribute(name, value);\r
}\r
\r
- int QueryAttribute( const char* name, bool* value ) const {\r
- return QueryBoolAttribute( name, value );\r
+ int QueryAttribute(const char* name, bool* value) const {\r
+ return QueryBoolAttribute(name, value);\r
}\r
\r
- int QueryAttribute( const char* name, double* value ) const {\r
- return QueryDoubleAttribute( name, value );\r
+ int QueryAttribute(const char* name, double* value) const {\r
+ return QueryDoubleAttribute(name, value);\r
}\r
\r
- int QueryAttribute( const char* name, float* value ) const {\r
- return QueryFloatAttribute( name, value );\r
+ int QueryAttribute(const char* name, float* value) const {\r
+ return QueryFloatAttribute(name, value);\r
}\r
\r
/// Sets the named attribute to value.\r
- void SetAttribute( const char* name, const char* value ) {\r
- XMLAttribute* a = FindOrCreateAttribute( name );\r
- a->SetAttribute( value );\r
+ void SetAttribute(const char* name, const char* value) {\r
+ XMLAttribute* a = FindOrCreateAttribute(name);\r
+ a->SetAttribute(value);\r
}\r
/// Sets the named attribute to value.\r
- void SetAttribute( const char* name, int value ) {\r
- XMLAttribute* a = FindOrCreateAttribute( name );\r
- a->SetAttribute( value );\r
+ void SetAttribute(const char* name, int value) {\r
+ XMLAttribute* a = FindOrCreateAttribute(name);\r
+ a->SetAttribute(value);\r
}\r
/// Sets the named attribute to value.\r
- void SetAttribute( const char* name, unsigned value ) {\r
- XMLAttribute* a = FindOrCreateAttribute( name );\r
- a->SetAttribute( value );\r
+ void SetAttribute(const char* name, unsigned value) {\r
+ XMLAttribute* a = FindOrCreateAttribute(name);\r
+ a->SetAttribute(value);\r
}\r
/// Sets the named attribute to value.\r
- void SetAttribute( const char* name, bool value ) {\r
- XMLAttribute* a = FindOrCreateAttribute( name );\r
- a->SetAttribute( value );\r
+ void SetAttribute(const char* name, bool value) {\r
+ XMLAttribute* a = FindOrCreateAttribute(name);\r
+ a->SetAttribute(value);\r
}\r
/// Sets the named attribute to value.\r
- void SetAttribute( const char* name, double value ) {\r
- XMLAttribute* a = FindOrCreateAttribute( name );\r
- a->SetAttribute( value );\r
+ void SetAttribute(const char* name, double value) {\r
+ XMLAttribute* a = FindOrCreateAttribute(name);\r
+ a->SetAttribute(value);\r
}\r
/// Sets the named attribute to value.\r
- void SetAttribute( const char* name, float value ) {\r
- XMLAttribute* a = FindOrCreateAttribute( name );\r
- a->SetAttribute( value );\r
+ void SetAttribute(const char* name, float value) {\r
+ XMLAttribute* a = FindOrCreateAttribute(name);\r
+ a->SetAttribute(value);\r
}\r
\r
/**\r
Delete an attribute.\r
*/\r
- void DeleteAttribute( const char* name );\r
+ void DeleteAttribute(const char* name);\r
\r
/// Return the first attribute in the list.\r
const XMLAttribute* FirstAttribute() const {\r
return _rootAttribute;\r
}\r
/// Query a specific attribute in the list.\r
- const XMLAttribute* FindAttribute( const char* name ) const;\r
+ const XMLAttribute* FindAttribute(const char* name) const;\r
\r
/** Convenience function for easy access to the text inside an element. Although easy\r
and concise, GetText() is limited compared to getting the XMLText child\r
This is a convenient method for setting the text of simple contained text:\r
@verbatim\r
<foo>This is text</foo>\r
- fooElement->SetText( "Hullaballoo!" );\r
+ fooElement->SetText("Hullaballoo!");\r
<foo>Hullaballoo!</foo>\r
@endverbatim\r
\r
<foo>Hullaballoo!</foo>\r
@endverbatim\r
*/\r
- void SetText( const char* inText );\r
+ void SetText(const char* inText);\r
/// Convenience method for setting text inside an element. See SetText() for important limitations.\r
- void SetText( int value );\r
+ void SetText(int value);\r
/// Convenience method for setting text inside an element. See SetText() for important limitations.\r
- void SetText( unsigned value ); \r
+ void SetText(unsigned value); \r
/// Convenience method for setting text inside an element. See SetText() for important limitations.\r
- void SetText( bool value ); \r
+ void SetText(bool value); \r
/// Convenience method for setting text inside an element. See SetText() for important limitations.\r
- void SetText( double value ); \r
+ void SetText(double value); \r
/// Convenience method for setting text inside an element. See SetText() for important limitations.\r
- void SetText( float value ); \r
+ void SetText(float value); \r
\r
/**\r
Convenience method to query the value of a child text node. This is probably best\r
@verbatim\r
int x = 0;\r
float y = 0; // types of x and y are contrived for example\r
- const XMLElement* xElement = pointElement->FirstChildElement( "x" );\r
- const XMLElement* yElement = pointElement->FirstChildElement( "y" );\r
- xElement->QueryIntText( &x );\r
- yElement->QueryFloatText( &y );\r
+ const XMLElement* xElement = pointElement->FirstChildElement("x");\r
+ const XMLElement* yElement = pointElement->FirstChildElement("y");\r
+ xElement->QueryIntText(&x);\r
+ yElement->QueryFloatText(&y);\r
@endverbatim\r
\r
@returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted\r
to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.\r
\r
*/\r
- XMLError QueryIntText( int* ival ) const;\r
+ XMLError QueryIntText(int* ival) const;\r
/// See QueryIntText()\r
- XMLError QueryUnsignedText( unsigned* uval ) const;\r
+ XMLError QueryUnsignedText(unsigned* uval) const;\r
/// See QueryIntText()\r
- XMLError QueryBoolText( bool* bval ) const;\r
+ XMLError QueryBoolText(bool* bval) const;\r
/// See QueryIntText()\r
- XMLError QueryDoubleText( double* dval ) const;\r
+ XMLError QueryDoubleText(double* dval) const;\r
/// See QueryIntText()\r
- XMLError QueryFloatText( float* fval ) const;\r
+ XMLError QueryFloatText(float* fval) const;\r
\r
// internal:\r
enum {\r
int ClosingType() const {\r
return _closingType;\r
}\r
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;\r
- virtual bool ShallowEqual( const XMLNode* compare ) const;\r
+ virtual XMLNode* ShallowClone(XMLDocument* document) const;\r
+ virtual bool ShallowEqual(const XMLNode* compare) const;\r
\r
protected:\r
- char* ParseDeep( char* p, StrPair* endTag );\r
+ char* ParseDeep(char* p, StrPair* endTag);\r
\r
private:\r
- XMLElement( XMLDocument* doc );\r
+ XMLElement(XMLDocument* doc);\r
virtual ~XMLElement();\r
- XMLElement( const XMLElement& ); // not supported\r
- void operator=( const XMLElement& ); // not supported\r
+ XMLElement(const XMLElement&); // not supported\r
+ void operator=(const XMLElement&); // not supported\r
\r
- XMLAttribute* FindAttribute( const char* name ) {\r
- return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));\r
+ XMLAttribute* FindAttribute(const char* name) {\r
+ return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute(name));\r
}\r
- XMLAttribute* FindOrCreateAttribute( const char* name );\r
- //void LinkAttribute( XMLAttribute* attrib );\r
- char* ParseAttributes( char* p );\r
- static void DeleteAttribute( XMLAttribute* attribute );\r
+ XMLAttribute* FindOrCreateAttribute(const char* name);\r
+ //void LinkAttribute(XMLAttribute* attrib);\r
+ char* ParseAttributes(char* p);\r
+ static void DeleteAttribute(XMLAttribute* attribute);\r
\r
enum { BUF_SIZE = 200 };\r
int _closingType;\r
friend class XMLElement;\r
public:\r
/// constructor\r
- XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );\r
+ XMLDocument(bool processEntities = true, Whitespace = PRESERVE_WHITESPACE);\r
~XMLDocument();\r
\r
virtual XMLDocument* ToDocument() {\r
- TIXMLASSERT( this == _document );\r
+ TIXMLASSERT(this == _document);\r
return this;\r
}\r
virtual const XMLDocument* ToDocument() const {\r
- TIXMLASSERT( this == _document );\r
+ TIXMLASSERT(this == _document);\r
return this;\r
}\r
\r
specified, TinyXML-2 will assume 'xml' points to a\r
null terminated string.\r
*/\r
- XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );\r
+ XMLError Parse(const char* xml, size_t nBytes=(size_t)(-1));\r
\r
/**\r
Load an XML file from disk.\r
Returns XML_NO_ERROR (0) on success, or\r
an errorID.\r
*/\r
- XMLError LoadFile( const char* filename );\r
+ XMLError LoadFile(const char* filename);\r
\r
/**\r
Load an XML file from disk. You are responsible\r
Returns XML_NO_ERROR (0) on success, or\r
an errorID.\r
*/\r
- XMLError LoadFile( FILE* );\r
+ XMLError LoadFile(FILE*);\r
\r
/**\r
Save the XML file to disk.\r
Returns XML_NO_ERROR (0) on success, or\r
an errorID.\r
*/\r
- XMLError SaveFile( const char* filename, bool compact = false );\r
+ XMLError SaveFile(const char* filename, bool compact = false);\r
\r
/**\r
Save the XML file to disk. You are responsible\r
Returns XML_NO_ERROR (0) on success, or\r
an errorID.\r
*/\r
- XMLError SaveFile( FILE* fp, bool compact = false );\r
+ XMLError SaveFile(FILE* fp, bool compact = false);\r
\r
bool ProcessEntities() const {\r
return _processEntities;\r
}\r
/** Sets whether to write the BOM when writing the file.\r
*/\r
- void SetBOM( bool useBOM ) {\r
+ void SetBOM(bool useBOM) {\r
_writeBOM = useBOM;\r
}\r
\r
/** Print the Document. If the Printer is not provided, it will\r
print to stdout. If you provide Printer, this can print to a file:\r
@verbatim\r
- XMLPrinter printer( fp );\r
- doc.Print( &printer );\r
+ XMLPrinter printer(fp);\r
+ doc.Print(&printer);\r
@endverbatim\r
\r
Or you can use a printer to print to memory:\r
@verbatim\r
XMLPrinter printer;\r
- doc.Print( &printer );\r
+ doc.Print(&printer);\r
// printer.CStr() has a const char* to the XML\r
@endverbatim\r
*/\r
- void Print( XMLPrinter* streamer=0 ) const;\r
- virtual bool Accept( XMLVisitor* visitor ) const;\r
+ void Print(XMLPrinter* streamer=0) const;\r
+ virtual bool Accept(XMLVisitor* visitor) const;\r
\r
/**\r
Create a new Element associated with\r
this Document. The memory for the Element\r
is managed by the Document.\r
*/\r
- XMLElement* NewElement( const char* name );\r
+ XMLElement* NewElement(const char* name);\r
/**\r
Create a new Comment associated with\r
this Document. The memory for the Comment\r
is managed by the Document.\r
*/\r
- XMLComment* NewComment( const char* comment );\r
+ XMLComment* NewComment(const char* comment);\r
/**\r
Create a new Text associated with\r
this Document. The memory for the Text\r
is managed by the Document.\r
*/\r
- XMLText* NewText( const char* text );\r
+ XMLText* NewText(const char* text);\r
/**\r
Create a new Declaration associated with\r
this Document. The memory for the object\r
<?xml version="1.0" encoding="UTF-8"?>\r
@endverbatim\r
*/\r
- XMLDeclaration* NewDeclaration( const char* text=0 );\r
+ XMLDeclaration* NewDeclaration(const char* text=0);\r
/**\r
Create a new Unknown associated with\r
this Document. The memory for the object\r
is managed by the Document.\r
*/\r
- XMLUnknown* NewUnknown( const char* text );\r
+ XMLUnknown* NewUnknown(const char* text);\r
\r
/**\r
Delete a node associated with this document.\r
It will be unlinked from the DOM.\r
*/\r
- void DeleteNode( XMLNode* node );\r
+ void DeleteNode(XMLNode* node);\r
\r
- void SetError( XMLError error, const char* str1, const char* str2 );\r
+ void SetError(XMLError error, const char* str1, const char* str2);\r
\r
/// Return true if there was an error parsing the document.\r
bool Error() const {\r
void Clear();\r
\r
// internal\r
- char* Identify( char* p, XMLNode** node );\r
+ char* Identify(char* p, XMLNode** node);\r
\r
- virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {\r
+ virtual XMLNode* ShallowClone(XMLDocument* /*document*/) const {\r
return 0;\r
}\r
- virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {\r
+ virtual bool ShallowEqual(const XMLNode* /*compare*/) const {\r
return false;\r
}\r
\r
private:\r
- XMLDocument( const XMLDocument& ); // not supported\r
- void operator=( const XMLDocument& ); // not supported\r
+ XMLDocument(const XMLDocument&); // not supported\r
+ void operator=(const XMLDocument&); // not supported\r
\r
bool _writeBOM;\r
bool _processEntities;\r
easy to write a *lot* of code that looks like:\r
\r
@verbatim\r
- XMLElement* root = document.FirstChildElement( "Document" );\r
- if ( root )\r
+ XMLElement* root = document.FirstChildElement("Document");\r
+ if (root)\r
{\r
- XMLElement* element = root->FirstChildElement( "Element" );\r
- if ( element )\r
+ XMLElement* element = root->FirstChildElement("Element");\r
+ if (element)\r
{\r
- XMLElement* child = element->FirstChildElement( "Child" );\r
- if ( child )\r
+ XMLElement* child = element->FirstChildElement("Child");\r
+ if (child)\r
{\r
- XMLElement* child2 = child->NextSiblingElement( "Child" );\r
- if ( child2 )\r
+ XMLElement* child2 = child->NextSiblingElement("Child");\r
+ if (child2)\r
{\r
// Finally do something useful.\r
@endverbatim\r
and correct to use:\r
\r
@verbatim\r
- XMLHandle docHandle( &document );\r
- XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement();\r
- if ( child2 )\r
+ XMLHandle docHandle(&document);\r
+ XMLElement* child2 = docHandle.FirstChildElement("Document").FirstChildElement("Element").FirstChildElement().NextSiblingElement();\r
+ if (child2)\r
{\r
// do something useful\r
@endverbatim\r
{\r
public:\r
/// Create a handle from any node (at any depth of the tree.) This can be a null pointer.\r
- XMLHandle( XMLNode* node ) {\r
+ XMLHandle(XMLNode* node) {\r
_node = node;\r
}\r
/// Create a handle from a node.\r
- XMLHandle( XMLNode& node ) {\r
+ XMLHandle(XMLNode& node) {\r
_node = &node;\r
}\r
/// Copy constructor\r
- XMLHandle( const XMLHandle& ref ) {\r
+ XMLHandle(const XMLHandle& ref) {\r
_node = ref._node;\r
}\r
/// Assignment\r
- XMLHandle& operator=( const XMLHandle& ref ) {\r
+ XMLHandle& operator=(const XMLHandle& ref) {\r
_node = ref._node;\r
return *this;\r
}\r
\r
/// Get the first child of this handle.\r
XMLHandle FirstChild() {\r
- return XMLHandle( _node ? _node->FirstChild() : 0 );\r
+ return XMLHandle(_node ? _node->FirstChild() : 0);\r
}\r
/// Get the first child element of this handle.\r
- XMLHandle FirstChildElement( const char* name = 0 ) {\r
- return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );\r
+ XMLHandle FirstChildElement(const char* name = 0) {\r
+ return XMLHandle(_node ? _node->FirstChildElement(name) : 0);\r
}\r
/// Get the last child of this handle.\r
XMLHandle LastChild() {\r
- return XMLHandle( _node ? _node->LastChild() : 0 );\r
+ return XMLHandle(_node ? _node->LastChild() : 0);\r
}\r
/// Get the last child element of this handle.\r
- XMLHandle LastChildElement( const char* name = 0 ) {\r
- return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );\r
+ XMLHandle LastChildElement(const char* name = 0) {\r
+ return XMLHandle(_node ? _node->LastChildElement(name) : 0);\r
}\r
/// Get the previous sibling of this handle.\r
XMLHandle PreviousSibling() {\r
- return XMLHandle( _node ? _node->PreviousSibling() : 0 );\r
+ return XMLHandle(_node ? _node->PreviousSibling() : 0);\r
}\r
/// Get the previous sibling element of this handle.\r
- XMLHandle PreviousSiblingElement( const char* name = 0 ) {\r
- return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );\r
+ XMLHandle PreviousSiblingElement(const char* name = 0) {\r
+ return XMLHandle(_node ? _node->PreviousSiblingElement(name) : 0);\r
}\r
/// Get the next sibling of this handle.\r
XMLHandle NextSibling() {\r
- return XMLHandle( _node ? _node->NextSibling() : 0 );\r
+ return XMLHandle(_node ? _node->NextSibling() : 0);\r
}\r
/// Get the next sibling element of this handle.\r
- XMLHandle NextSiblingElement( const char* name = 0 ) {\r
- return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );\r
+ XMLHandle NextSiblingElement(const char* name = 0) {\r
+ return XMLHandle(_node ? _node->NextSiblingElement(name) : 0);\r
}\r
\r
/// Safe cast to XMLNode. This can return null.\r
}\r
/// Safe cast to XMLElement. This can return null.\r
XMLElement* ToElement() {\r
- return ( ( _node == 0 ) ? 0 : _node->ToElement() );\r
+ return ((_node == 0) ? 0 : _node->ToElement());\r
}\r
/// Safe cast to XMLText. This can return null.\r
XMLText* ToText() {\r
- return ( ( _node == 0 ) ? 0 : _node->ToText() );\r
+ return ((_node == 0) ? 0 : _node->ToText());\r
}\r
/// Safe cast to XMLUnknown. This can return null.\r
XMLUnknown* ToUnknown() {\r
- return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );\r
+ return ((_node == 0) ? 0 : _node->ToUnknown());\r
}\r
/// Safe cast to XMLDeclaration. This can return null.\r
XMLDeclaration* ToDeclaration() {\r
- return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );\r
+ return ((_node == 0) ? 0 : _node->ToDeclaration());\r
}\r
\r
private:\r
class TINYXML2_LIB XMLConstHandle\r
{\r
public:\r
- XMLConstHandle( const XMLNode* node ) {\r
+ XMLConstHandle(const XMLNode* node) {\r
_node = node;\r
}\r
- XMLConstHandle( const XMLNode& node ) {\r
+ XMLConstHandle(const XMLNode& node) {\r
_node = &node;\r
}\r
- XMLConstHandle( const XMLConstHandle& ref ) {\r
+ XMLConstHandle(const XMLConstHandle& ref) {\r
_node = ref._node;\r
}\r
\r
- XMLConstHandle& operator=( const XMLConstHandle& ref ) {\r
+ XMLConstHandle& operator=(const XMLConstHandle& ref) {\r
_node = ref._node;\r
return *this;\r
}\r
\r
const XMLConstHandle FirstChild() const {\r
- return XMLConstHandle( _node ? _node->FirstChild() : 0 );\r
+ return XMLConstHandle(_node ? _node->FirstChild() : 0);\r
}\r
- const XMLConstHandle FirstChildElement( const char* name = 0 ) const {\r
- return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );\r
+ const XMLConstHandle FirstChildElement(const char* name = 0) const {\r
+ return XMLConstHandle(_node ? _node->FirstChildElement(name) : 0);\r
}\r
const XMLConstHandle LastChild() const {\r
- return XMLConstHandle( _node ? _node->LastChild() : 0 );\r
+ return XMLConstHandle(_node ? _node->LastChild() : 0);\r
}\r
- const XMLConstHandle LastChildElement( const char* name = 0 ) const {\r
- return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );\r
+ const XMLConstHandle LastChildElement(const char* name = 0) const {\r
+ return XMLConstHandle(_node ? _node->LastChildElement(name) : 0);\r
}\r
const XMLConstHandle PreviousSibling() const {\r
- return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );\r
+ return XMLConstHandle(_node ? _node->PreviousSibling() : 0);\r
}\r
- const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {\r
- return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );\r
+ const XMLConstHandle PreviousSiblingElement(const char* name = 0) const {\r
+ return XMLConstHandle(_node ? _node->PreviousSiblingElement(name) : 0);\r
}\r
const XMLConstHandle NextSibling() const {\r
- return XMLConstHandle( _node ? _node->NextSibling() : 0 );\r
+ return XMLConstHandle(_node ? _node->NextSibling() : 0);\r
}\r
- const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {\r
- return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );\r
+ const XMLConstHandle NextSiblingElement(const char* name = 0) const {\r
+ return XMLConstHandle(_node ? _node->NextSiblingElement(name) : 0);\r
}\r
\r
\r
return _node;\r
}\r
const XMLElement* ToElement() const {\r
- return ( ( _node == 0 ) ? 0 : _node->ToElement() );\r
+ return ((_node == 0) ? 0 : _node->ToElement());\r
}\r
const XMLText* ToText() const {\r
- return ( ( _node == 0 ) ? 0 : _node->ToText() );\r
+ return ((_node == 0) ? 0 : _node->ToText());\r
}\r
const XMLUnknown* ToUnknown() const {\r
- return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );\r
+ return ((_node == 0) ? 0 : _node->ToUnknown());\r
}\r
const XMLDeclaration* ToDeclaration() const {\r
- return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );\r
+ return ((_node == 0) ? 0 : _node->ToDeclaration());\r
}\r
\r
private:\r
\r
@verbatim\r
XMLPrinter printer;\r
- doc.Print( &printer );\r
- SomeFunction( printer.CStr() );\r
+ doc.Print(&printer);\r
+ SomeFunction(printer.CStr());\r
@endverbatim\r
\r
Print to a File\r
\r
You provide the file pointer.\r
@verbatim\r
- XMLPrinter printer( fp );\r
- doc.Print( &printer );\r
+ XMLPrinter printer(fp);\r
+ doc.Print(&printer);\r
@endverbatim\r
\r
Print without a XMLDocument\r
an XML document.\r
\r
@verbatim\r
- XMLPrinter printer( fp );\r
- printer.OpenElement( "foo" );\r
- printer.PushAttribute( "foo", "bar" );\r
+ XMLPrinter printer(fp);\r
+ printer.OpenElement("foo");\r
+ printer.PushAttribute("foo", "bar");\r
printer.CloseElement();\r
@endverbatim\r
*/\r
If 'compact' is set to true, then output is created\r
with only required whitespace and newlines.\r
*/\r
- XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );\r
+ XMLPrinter(FILE* file=0, bool compact = false, int depth = 0);\r
virtual ~XMLPrinter() {}\r
\r
/** If streaming, write the BOM and declaration. */\r
- void PushHeader( bool writeBOM, bool writeDeclaration );\r
+ void PushHeader(bool writeBOM, bool writeDeclaration);\r
/** If streaming, start writing an element.\r
The element must be closed with CloseElement()\r
*/\r
- void OpenElement( const char* name, bool compactMode=false );\r
+ void OpenElement(const char* name, bool compactMode=false);\r
/// If streaming, add an attribute to an open element.\r
- void PushAttribute( const char* name, const char* value );\r
- void PushAttribute( const char* name, int value );\r
- void PushAttribute( const char* name, unsigned value );\r
- void PushAttribute( const char* name, bool value );\r
- void PushAttribute( const char* name, double value );\r
+ void PushAttribute(const char* name, const char* value);\r
+ void PushAttribute(const char* name, int value);\r
+ void PushAttribute(const char* name, unsigned value);\r
+ void PushAttribute(const char* name, bool value);\r
+ void PushAttribute(const char* name, double value);\r
/// If streaming, close the Element.\r
- virtual void CloseElement( bool compactMode=false );\r
+ virtual void CloseElement(bool compactMode=false);\r
\r
/// Add a text node.\r
- void PushText( const char* text, bool cdata=false );\r
+ void PushText(const char* text, bool cdata=false);\r
/// Add a text node from an integer.\r
- void PushText( int value );\r
+ void PushText(int value);\r
/// Add a text node from an unsigned.\r
- void PushText( unsigned value );\r
+ void PushText(unsigned value);\r
/// Add a text node from a bool.\r
- void PushText( bool value );\r
+ void PushText(bool value);\r
/// Add a text node from a float.\r
- void PushText( float value );\r
+ void PushText(float value);\r
/// Add a text node from a double.\r
- void PushText( double value );\r
+ void PushText(double value);\r
\r
/// Add a comment\r
- void PushComment( const char* comment );\r
+ void PushComment(const char* comment);\r
\r
- void PushDeclaration( const char* value );\r
- void PushUnknown( const char* value );\r
+ void PushDeclaration(const char* value);\r
+ void PushUnknown(const char* value);\r
\r
- virtual bool VisitEnter( const XMLDocument& /*doc*/ );\r
- virtual bool VisitExit( const XMLDocument& /*doc*/ ) {\r
+ virtual bool VisitEnter(const XMLDocument& /*doc*/);\r
+ virtual bool VisitExit(const XMLDocument& /*doc*/) {\r
return true;\r
}\r
\r
- virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );\r
- virtual bool VisitExit( const XMLElement& element );\r
+ virtual bool VisitEnter(const XMLElement& element, const XMLAttribute* attribute);\r
+ virtual bool VisitExit(const XMLElement& element);\r
\r
- virtual bool Visit( const XMLText& text );\r
- virtual bool Visit( const XMLComment& comment );\r
- virtual bool Visit( const XMLDeclaration& declaration );\r
- virtual bool Visit( const XMLUnknown& unknown );\r
+ virtual bool Visit(const XMLText& text);\r
+ virtual bool Visit(const XMLComment& comment);\r
+ virtual bool Visit(const XMLDeclaration& declaration);\r
+ virtual bool Visit(const XMLUnknown& unknown);\r
\r
/**\r
If in print to memory mode, return a pointer to\r
}\r
\r
protected:\r
- virtual bool CompactMode( const XMLElement& ) { return _compactMode; }\r
+ virtual bool CompactMode(const XMLElement&) { return _compactMode; }\r
\r
/** Prints out the space before an element. You may override to change\r
the space and tabs used. A PrintSpace() override should call Print().\r
*/\r
- virtual void PrintSpace( int depth );\r
- void Print( const char* format, ... );\r
+ virtual void PrintSpace(int depth);\r
+ void Print(const char* format, ...);\r
\r
void SealElementIfJustOpened();\r
bool _elementJustOpened;\r
DynArray< const char*, 10 > _stack;\r
\r
private:\r
- void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.\r
+ void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities.\r
\r
bool _firstElement;\r
FILE* _fp;\r
void closeBox();
void waitForDialog(void);
- bool pageExists( void );
- void drawPage( std::string path );
+ bool pageExists(void);
+ void drawPage(std::string path);
- void dontTypeOut( void );
+ void dontTypeOut(void);
/*
* Draws a larger string in the center of the screen. Drawing is done inside this function.
*/
void draw(void);
void quitGame();
-
+
/*
menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t);
menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v);
- void draw( void );
+ void draw(void);
}
}
#define GROUND_HEIGHT_INITIAL 80
#define GROUND_HEIGHT_MINIMUM 60
#define GROUND_HEIGHT_MAXIMUM 110
-
#define GROUND_HILLINESS 10
#define PLAYER_SPEED_CONSTANT 0.15f
* World::detect(), which is why it is declared private.
*/
- virtual void singleDetect( Entity *e );
+ virtual void singleDetect(Entity *e);
/**
* Empties all entity vectors.
* call this function.
*/
- void deleteEntities( void );
+ void deleteEntities(void);
/**
* Number of lines in the world.
std::vector<std::string> bgFiles;
std::vector<std::string> bgFilesIndoors;
-public:
-
/**
* The filename of the XML file for the world to the left; NULL if no world
* is present.
std::string toRight;
/**
- * Sets what XML file to use for loading the world to the left.
+ * Vector of all building textures for the current world style
*/
- std::string setToLeft( std::string file );
+ std::vector<std::string> sTexLoc;
+
+ std::vector<Light> light;
+ std::vector<Village> village;
+ std::vector<Particles> particles;
+ std::vector<Object> object;
+ std::vector<Mob> mob;
+
+public:
+
+ Light *getLastLight(void);
+ Mob *getLastMob(void);
+
+ std::string getSTextureLocation(unsigned int index) const;
/**
- * Sets what XML file to use for loading the world to the right.
+ * These handle accessing/modifying pathnames for worlds linked to the left
+ * and right of this one.
*/
- std::string setToRight( std::string file );
+ std::string setToLeft(std::string file);
+ std::string setToRight(std::string file);
+
+ std::string getToLeft(void) const;
+ std::string getToRight(void) const;
/**
* A vector of pointers to every NPC, Structure, Mob, and Object in this
std::vector<Structures *> build;
- /**
- * A vector of all Mobs in this world.
- */
-
- std::vector<Mob *> mob;
-
- /**
- * A vector of all Objects in this world.
- */
-
- std::vector<Object *> object;
-
- /**
- * A vector of all particles in this world.
- */
-
- std::vector<Particles> particles;
-
-
- std::vector<Village *> village;
-
- /**
- * A vector of all light elements in this world.
- */
-
- std::vector<Light> light;
-
- /**
- * Vector of all building textures for the current world style
- */
-
- std::vector<std::string> sTexLoc;
-
/**
* NULLifies pointers and allocates necessary memory. This should be
* followed by some combination of setBackground(), setBGM(), or
* generate().
*/
- World( void );
+ World(void);
/**
* Frees resources taken by the world.
*/
void addStructure(BUILD_SUB subtype,float x,float y, std::string tex, std::string inside);
+ Village *addVillage(std::string name, World *world);
/**
* Adds a Mob to the world with the specified type and coordinates.
* upon object interaction.
*/
- void addObject( std::string in, std::string pickupDialog, float x, float y);
+ void addObject(std::string in, std::string pickupDialog, float x, float y);
/**
* Adds a particle to the world with the specified coordinates, dimensions,
*/
void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d);
- void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity );
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, unsigned char flags);
/**
* Adds a light to the world with the specified coordinates and color.
* and a velocity. The provided delta time is used for smoother updating.
*/
- void update( Player *p, unsigned int delta );
+ void update(Player *p, unsigned int delta);
/**
* Generate a world of the provided width. Worlds are drawn centered on the
*/
World *goWorldLeft(Player *p);
- bool goWorldLeft( NPC *e );
+ bool goWorldLeft(NPC *e);
/**
* Attempts to let the player enter the right-linked world specified by
* hill can be.
*/
- void addHill( ivec2 peak, unsigned int width );
+ void addHill(ivec2 peak, unsigned int width);
/**
* Gets the world's width.
std::vector<std::vector<float>> floor;
std::vector<float> fstart;
- void singleDetect( Entity *e );
+ void singleDetect(Entity *e);
public:
IndoorWorld(void);
~IndoorWorld(void);
- void addFloor( unsigned int width );
- void addFloor( unsigned int width, unsigned int start );
- bool moveToFloor( Entity *e, unsigned int _floor );
+ void addFloor(unsigned int width);
+ void addFloor(unsigned int width, unsigned int start);
+ bool moveToFloor(Entity *e, unsigned int _floor);
- bool isFloorAbove( Entity *e );
- bool isFloorBelow( Entity *e );
+ bool isFloorAbove(Entity *e);
+ bool isFloorBelow(Entity *e);
void draw(Player *p); // Draws the world (ignores layers)
};
* world `leave` upon exit.
*/
- Arena( World *leave, Player *p, Mob *m );
+ Arena(World *leave, Player *p, Mob *m);
/**
* Frees resources taken by the arena.
*/
- ~Arena( void );
+ ~Arena(void);
/**
* Attempts to exit the world, returning the player to the world they were
* last in.
*/
- World *exitArena( Player *p );
+ World *exitArena(Player *p);
};
-bool isCurrentWorldIndoors( void );
-float getIndoorWorldFloorHeight( void );
+bool isCurrentWorldIndoors(void);
+float getIndoorWorldFloorHeight(void);
-std::string getWorldWeatherStr( WorldWeather ww );
+std::string getWorldWeatherStr(WorldWeather ww);
/**
* Loads the player into the world created by the given XML file. If a world is
World *loadWorldFromXMLNoSave(std::string path);
-World *loadWorldFromPtr( World *ptr );
+World *loadWorldFromPtr(World *ptr);
#endif // WORLD_H
* (Attempt to) Initialize SDL_mixer libraries for loading and playing music/sound files.
*/
- if(Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){
+ if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){
std::cout << "SDL_mixer could not initialize! Error: " << Mix_GetError() << std::endl;
return -1;
}
SCREEN_WIDTH,
SCREEN_HEIGHT,
SDL_CreateWindowFlags
- );
+ );
/*
* Exit if the window cannot be created
glGetShaderInfoLog(fragShader, logLength, NULL, &fragShaderError[0]);
std::cout << &fragShaderError[0] << std::endl;
- if ( bufferln == GL_FALSE )
+ if (bufferln == GL_FALSE)
UserError("Error compiling shader");
shaderProgram = glCreateProgram();
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &bufferln);
glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &logLength);
- std::vector<char> programError( (logLength > 1) ? logLength : 1 );
+ std::vector<char> programError((logLength > 1) ? logLength : 1);
glGetProgramInfoLog(shaderProgram, logLength, NULL, &programError[0]);
std::cout << &programError[0] << std::endl;
glClearColor(1,1,1,1);
gameRunning = true;
- while ( gameRunning )
+ while (gameRunning)
mainLoop();
/**************************
deltaTime = currentTime - prevTime;
prevTime = currentTime;
- if ( currentMenu )
+ if (currentMenu)
goto MENU;
/*
/*pool.Enqueue([](){
currentWorld->update(player,deltaTime);
});*/
- currentWorld->update( player, deltaTime );
+ currentWorld->update(player, deltaTime);
currentWorld->detect(player);
/*
* Update debug variables if necessary
*/
- if ( ++debugDiv == 20 ) {
+ if (++debugDiv == 20) {
debugDiv=0;
- if ( deltaTime )
+ if (deltaTime)
fps = 1000 / deltaTime;
- if ( !(debugDiv % 10) )
+ if (!(debugDiv % 10))
debugY = player->loc.y;
}
MENU:
* GL_COLOR_BUFFER_BIT allows the matrices to have color on them
*/
- glPushAttrib( GL_DEPTH_BUFFER_BIT);
+ glPushAttrib(GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/**************************
tickCount,
handAngle,
VOLUME_MASTER,
- getWorldWeatherStr( weather ).c_str()
+ getWorldWeatherStr(weather).c_str()
);
- if ( ui::posFlag ) {
+ if (ui::posFlag) {
glBegin(GL_LINES);
/*glColor3ub(255,0,0);
glVertex2i(0,0);
/*glColor3ub(255,255,255);
glVertex2i(player->loc.x + player->width/2,0);
glVertex2i(player->loc.x + player->width/2,SCREEN_HEIGHT);
- glVertex2i( offset.x - SCREEN_WIDTH / 2, player->loc.y + player->height / 2 );
- glVertex2i( offset.x + SCREEN_WIDTH / 2, player->loc.y + player->height / 2 );*/
+ glVertex2i(offset.x - SCREEN_WIDTH / 2, player->loc.y + player->height / 2);
+ glVertex2i(offset.x + SCREEN_WIDTH / 2, player->loc.y + player->height / 2);*/
- /*glVertex2i( -SCREEN_WIDTH / 2 + offset.x, player->loc.y );
- glVertex2i( SCREEN_WIDTH / 2 + offset.x, player->loc.y );*/
+ /*glVertex2i(-SCREEN_WIDTH / 2 + offset.x, player->loc.y);
+ glVertex2i( SCREEN_WIDTH / 2 + offset.x, player->loc.y);*/
glColor3ub(100,100,255);
- for ( auto &e : currentWorld->entity ) {
- glVertex2i( player->loc.x + player->width / 2, player->loc.y + player->height / 2 );
- glVertex2i( e->loc.x + e->width / 2, e->loc.y + e->height / 2 );
+ for (auto &e : currentWorld->entity) {
+ glVertex2i(player->loc.x + player->width / 2, player->loc.y + player->height / 2);
+ glVertex2i(e->loc.x + e->width / 2, e->loc.y + e->height / 2);
}
glEnd();
}
- if ( currentMenu )
+ if (currentMenu)
ui::menu::draw();
// draw the mouse cursor
SDL_GL_SwapWindow(window);
}
-static bool objectInteracting = false;
-
void logic(){
- static bool NPCSelected = false;
+ static bool NPCSelected = false;
+ static bool ObjectSelected = false;
// exit the game if the player falls out of the world
- if ( player->loc.y < 0 )
+ if (player->loc.y < 0)
gameRunning = false;
- if ( player->inv->usingi ) {
- for ( auto &e : currentWorld->entity ) {
+ if (player->inv->usingi) {
+ for (auto &e : currentWorld->entity) {
e->hit = false;
- if ( player->inv->usingi && !e->hit &&
- player->inv->detectCollision( { e->loc.x, e->loc.y }, { e->loc.x + e->width, e->loc.y + e->height} ) ) {
+ if (player->inv->usingi && !e->hit &&
+ player->inv->detectCollision({ e->loc.x, e->loc.y }, { e->loc.x + e->width, e->loc.y + e->height})) {
e->health -= 25;
e->hit = true;
e->forcedMove = true;
break;
//for(int r = 0; r < (rand()%5);r++)
// currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);
- //if ( e->health <= 0 ) {
+ //if (e->health <= 0) {
//for(int r = 0; r < (rand()%30)+15;r++)
// currentWorld->addParticle(rand()%HLINE*3 + n->loc.x - .05f,n->loc.y + n->height*.5, HLINE,HLINE, -(rand()%10)*.01,((rand()%10)*.01-.05), {(rand()%75)+10/100.0f,0,0}, 10000);
}
player->inv->usingi = false;
}
- /*
- * Entity logic: This loop finds every entity that is alive and in the current world. It then
- * basically runs their AI functions depending on what type of entity they are. For NPCs,
- * click detection is done as well for NPC/player interaction.
- */
-
- for(auto &n : currentWorld->npc){
- if(n->alive){
-
- /*
- * Make the NPC 'wander' about the world if they're allowed to do so.
- * Entity->canMove is modified when a player interacts with an NPC so
- * that the NPC doesn't move when it talks to the player.
- */
-
- if(n->canMove)
- n->wander((rand() % 120 + 30));
-
- /*
- * Don't bother handling the NPC if another has already been handled.
- */
-
- if(NPCSelected){
- n->near=false;
- break;
- }
-
- /*
- * Check if the NPC is under the mouse.
- */
-
- if(ui::mouse.x >= n->loc.x &&
- ui::mouse.x <= n->loc.x + n->width &&
- ui::mouse.y >= n->loc.y &&
- ui::mouse.y <= n->loc.y + n->width ){
-
- /*
- * Check of the NPC is close enough to the player for interaction to be
- * considered legal. In other words, require the player to be close to
- * the NPC in order to interact with it.
- *
- * This uses the Pythagorean theorem to check for NPCs within a certain
- */
-
- if(pow((n->loc.x - player->loc.x),2) + pow((n->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){
-
- /*
- * Set Entity->near so that this NPC's name is drawn under them, and toggle NPCSelected
- * so this NPC is the only one that's clickable.
- */
-
- n->near=true;
- NPCSelected=true;
-
- /*
- * Check for a right click, and allow the NPC to interact with the
- * player if one was made.
- */
-
- if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){
-
- if(!ui::dialogBoxExists)
- n->interact();
-
+ for (auto &e : currentWorld->entity) {
+ if (e->alive) {
+ if (e->type == NPCT || e->type == MERCHT || e->type == OBJECTT) {
+
+ if (e->type == OBJECTT && ObjectSelected) {
+ e->near = false;
+ continue;
+ } else { // has to be NPC
+ if (e->canMove) {
+ e->wander((rand() % 120 + 30));
+ if (NPCSelected) {
+ e->near = false;
+ continue;
+ }
}
}
- /*
- * Hide the NPC's name if the mouse isn't on the NPC.
- */
-
- }else n->near=false;
- }
- }
-
- for(auto &m : currentWorld->mob){
- if(m->alive){
-
- /*
- * Run the Mob's AI function.
- */
-
- switch(m->subtype){
- case MS_RABBIT:
- case MS_BIRD:
- m->wander((rand()%240 + 15)); // Make the mob wander
- break;
- case MS_TRIGGER:
- case MS_PAGE:
- m->wander(0);
- break;
- case MS_DOOR:
- break;
- default:
- std::cout<<"Unhandled mob of subtype "<<m->subtype<<"."<<std::endl;
- break;
- }
- }
- }
-
- if(!objectInteracting){
- for(auto &o : currentWorld->object){
- if(o->alive){
- if(ui::mouse.x >= o->loc.x &&
- ui::mouse.x <= o->loc.x + o->width &&
- ui::mouse.y >= o->loc.y &&
- ui::mouse.y <= o->loc.y + o->height ){
- if(pow((o->loc.x - player->loc.x),2) + pow((o->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){
-
- /*
- * Check for a right click, and allow the Object to interact with the
- * player if one was made.
- */
-
- if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){
- objectInteracting=true;
- o->interact();
- objectInteracting=false;
- }
- }
+ if(e->isInside(ui::mouse) && player->isNear(*e)) {
+ if (e->type == OBJECTT)
+ ObjectSelected = true;
+ else
+ NPCSelected = true;
+ e->near = true;
+
+ if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) && !ui::dialogBoxExists)
+ e->interact();
+ } else
+ e->near = false;
+ } else if (e->type == MOBT) {
+ switch (e->subtype) {
+ case MS_RABBIT:
+ case MS_BIRD:
+ e->wander((rand()%240 + 15));
+ break;
+ case MS_TRIGGER:
+ case MS_PAGE:
+ e->wander(0);
+ break;
+ case MS_DOOR:
+ break;
+ default:
+ std::cout<<"Unhandled mob of subtype "<<e->subtype<<"."<<std::endl;
+ break;
}
}
}
*/
if(!(tickCount%DAY_CYCLE)||!tickCount){
- if ( weather == WorldWeather::Sunny )
+ if (weather == WorldWeather::Sunny)
weather = WorldWeather::Dark;
else {
weather = WorldWeather::Sunny;
* Rain?
*/
- if ( weather == WorldWeather::Rain ) {
- for ( unsigned int r = (randGet() % 25) + 11; r--; ) {
+ if (weather == WorldWeather::Rain) {
+ for (unsigned int r = (randGet() % 25) + 11; r--;) {
currentWorld->addParticle(randGet() % currentWorld->getTheWidth() - (currentWorld->getTheWidth() / 2),
offset.y + SCREEN_HEIGHT / 2,
HLINE * 1.25, // width
randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x
(4 + randGet() % 6) * .05, // vel.y
{ 0, 0, 255 }, // RGB color
- 2500 // duration (ms)
- );
- currentWorld->particles.back().bounce = true;
+ 2500, // duration (ms)
+ (1 << 0) | (1 << 1) // gravity and bounce
+ );
}
- } else if ( weather == WorldWeather::Snowy ) {
- for ( unsigned int r = (randGet() % 25) + 11; r--; ) {
+ } else if (weather == WorldWeather::Snowy) {
+ for (unsigned int r = (randGet() % 25) + 11; r--;) {
currentWorld->addParticle(randGet() % currentWorld->getTheWidth() - (currentWorld->getTheWidth() / 2),
offset.y + SCREEN_HEIGHT / 2,
HLINE * 1.25, // width
(4 + randGet() % 6) * -.03, // vel.y
{ 255, 255, 255 }, // RGB color
5000, // duration (ms)
- false
- );
+ 0 // no gravity, no bounce
+ );
}
}
TARGET_OS = linux
# Bits setting, 32 or 64
-TARGET_BITS = 64
+TARGET_BITS = 32
unsigned int size;
GLchar *buf;
- if ( !in.is_open() )
+ if (!in.is_open())
UserError("Error reading file " + (std::string)path + "!");
in.seekg(0,in.end);
}
void
-UserError( std::string reason )
+UserError(std::string reason)
{
std::cout << "User error: " << reason << "!" << std::endl;
abort();
namespace config {
- void read( void ) {
+ void read(void) {
unsigned int uval;
float fval;
bool bval;
ui::initFonts();
ui::setFontFace(xml.FirstChildElement("font")->Attribute("path"));
- if ( xml.FirstChildElement("debug") )
+ if (xml.FirstChildElement("debug"))
ui::debug = ui::posFlag = true;
config::update();
}
- void update( void ) {
+ void update(void) {
Mix_Volume(0,VOLUME_MASTER);
Mix_Volume(1,VOLUME_SFX * (VOLUME_MASTER/100.0f));
Mix_VolumeMusic(VOLUME_MUSIC * (VOLUME_MASTER/100.0f));
}
- void save( void ) {
+ void save(void) {
vol->FirstChildElement("master")->SetAttribute("volume",VOLUME_MASTER);
vol->FirstChildElement("music")->SetAttribute("volume",VOLUME_MUSIC);
vol->FirstChildElement("sfx")->SetAttribute("volume", VOLUME_SFX);
break;
}
- strcpy( e->name, bufs + 1 );
+ strcpy(e->name, bufs + 1);
delete[] bufs;
}
height = getItemHeight(iname);
}
+bool Entity::isNear(Entity e){
+ return pow(e.loc.x - loc.x, 2) + pow(e.loc.y - loc.y, 2) <= pow(40 * HLINE, 2);
+}
+
void Entity::draw(void){ //draws the entities
glPushMatrix();
glColor3ub(255,255,255);
- if ( !alive )
+ if (!alive)
return;
if(type==NPCT){
break;
}
- if ( hitCooldown )
+ if (hitCooldown)
glColor3ub(255,255,0);
else
glColor3ub(255,255,255);
glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
- if ( near )
+ if (near)
ui::putStringCentered(loc.x+width/2,loc.y-ui::fontSize-HLINE/2,name);
- if ( health != maxHealth ) {
- glColor3ub(150,0,0); glRectf( loc.x, loc.y + height, loc.x + width, loc.y + height + HLINE * 2 );
- glColor3ub(255,0,0); glRectf( loc.x, loc.y + height, loc.x + width * ( health / maxHealth ), loc.y + height + HLINE * 2 );
+ if (health != maxHealth) {
+ glColor3ub(150,0,0); glRectf(loc.x, loc.y + height, loc.x + width, loc.y + height + HLINE * 2);
+ glColor3ub(255,0,0); glRectf(loc.x, loc.y + height, loc.x + width * (health / maxHealth), loc.y + height + HLINE * 2);
}
}
*/
void NPC::
-wander( int timeRun )
+wander(int timeRun)
{
static int direction;
- if ( forcedMove )
+ if (forcedMove)
return;
- if ( hitCooldown )
+ if (hitCooldown)
hitCooldown--;
- if ( followee ) {
- if ( loc.x < followee->loc.x - 40 )
+ if (followee) {
+ if (loc.x < followee->loc.x - 40)
direction = 1;
- else if ( loc.x > followee->loc.x + 40 )
+ else if (loc.x > followee->loc.x + 40)
direction = -1;
else
direction = 0;
vel.x = .018 * HLINE * direction;
- } else if ( targetx != 0.9112001f ) {
- if ( loc.x > targetx + HLINE * 5)
+ } else if (targetx != 0.9112001f) {
+ if (loc.x > targetx + HLINE * 5)
vel.x = -0.018 * HLINE;
- else if ( loc.x < targetx - HLINE * 5)
+ else if (loc.x < targetx - HLINE * 5)
vel.x = 0.018 * HLINE;
else
targetx = 0.9112001f;
- } else if ( ticksToUse == 0 ) {
+ } else if (ticksToUse == 0) {
ticksToUse = timeRun;
vel.x = .008 * HLINE;
direction = (getRand() % 3 - 1);
- if ( direction == 0 )
+ if (direction == 0)
ticksToUse *= 2;
vel.x *= direction;
}
- if( vel.x < 0)
- currentWorld->goWorldLeft( this );
+ if(vel.x < 0)
+ currentWorld->goWorldLeft(this);
ticksToUse--;
}
void Merchant::wander(int timeRun){
static int direction;
- if ( forcedMove )
+ if (forcedMove)
return;
- if ( ticksToUse == 0 ) {
+ if (ticksToUse == 0) {
ticksToUse = timeRun;
vel.x = .008 * HLINE;
direction = (getRand() % 3 - 1);
- if ( direction == 0 )
+ if (direction == 0)
ticksToUse *= 2;
vel.x *= direction;
}
- if( vel.x < 0)
- currentWorld->goWorldLeft( this );
- if ( inside != nullptr ) {
+ if(vel.x < 0)
+ currentWorld->goWorldLeft(this);
+ if (inside != nullptr) {
loc.y = inside->loc.y + HLINE * 2;
vel.y = GRAVITY_CONSTANT * 5;
- if ( loc.x <= inside->loc.x + HLINE * 5 )
+ if (loc.x <= inside->loc.x + HLINE * 5)
loc.x = inside->loc.x + HLINE * 5;
- else if ( loc.x + width >= inside->loc.x + inside->width - HLINE * 5 )
+ else if (loc.x + width >= inside->loc.x + inside->width - HLINE * 5)
loc.x = inside->loc.x + inside->width - width - HLINE * 5;
}
ticksToUse--;
ui::waitForDialog();
// handle normal dialog options
- switch ( ui::dialogOptChosen ) {
+ switch (ui::dialogOptChosen) {
// Accept
case 1:
- if ( !(player->inv->takeItem( trade[currTrade].item[1], trade[currTrade].quantity[1])) )
+ if (!(player->inv->takeItem(trade[currTrade].item[1], trade[currTrade].quantity[1])))
player->inv->addItem(trade[currTrade].item[0],trade[currTrade].quantity[0]);
break;
}
// handle merchant-specific dialog options
- switch ( ui::merchOptChosen ) {
+ switch (ui::merchOptChosen) {
// left arrow
case 1:
- if ( currTrade )
+ if (currTrade)
currTrade--;
ui::dontTypeOut();
interact(); // TODO should we nest like this?
// right arrow
case 2:
- if ( currTrade < trade.size() - 1 )
+ if (currTrade < trade.size() - 1)
currTrade++;
ui::dontTypeOut();
interact();
void Object::interact(void){
std::thread([this]{
if(questObject && alive){
- ui::dialogBox( player->name, ":Yes:No", false, pickupDialog.c_str());
+ ui::dialogBox(player->name, ":Yes:No", false, pickupDialog.c_str());
ui::waitForDialog();
if(ui::dialogOptChosen == 1){
- player->inv->addItem( iname, 1 );
+ player->inv->addItem(iname, 1);
alive = false;
}
}else{
}).detach();
}
-void Entity::
-follow( Entity *e )
-{
+bool Entity::isInside(vec2 coord) const {
+ return coord.x >= loc.x &&
+ coord.x <= loc.x + width &&
+ coord.y >= loc.y &&
+ coord.y <= loc.y + height;
+}
+
+void Entity::follow(Entity *e){
followee = e;
}
//unsigned int tempN = (getRand() % 5 + 2);
- if ( textureLoc.empty() )
- textureLoc = inWorld->sTexLoc[sub];
+ if (textureLoc.empty())
+ textureLoc = inWorld->getSTextureLocation(sub);
switch(sub){
case STALL_MARKET:
tex = new Texturec({ textureLoc });
- dim = Texture::imageDim( textureLoc );
+ dim = Texture::imageDim(textureLoc);
width = dim.x;
height = dim.y;
break;
default:
tex = new Texturec({ textureLoc });
- dim = Texture::imageDim( textureLoc );
+ dim = Texture::imageDim(textureLoc);
width = dim.x;
height = dim.y;
inv = NULL;
static unsigned int heya=0,hi=0;
static bool YAYA = false;
- if ( forcedMove )
+ if (forcedMove)
return;
- if ( followee ) {
- if ( loc.x < followee->loc.x - 40 )
+ if (followee) {
+ if (loc.x < followee->loc.x - 40)
direction = 1;
- else if ( loc.x > followee->loc.x + 40 )
+ else if (loc.x > followee->loc.x + 40)
direction = -1;
else
direction = 0;
if(aggressive && !YAYA &&
player->loc.x + (width / 2) > loc.x && player->loc.x + (width / 2) < loc.x + width &&
- player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height ){
- if ( !ui::dialogBoxExists ) {
+ player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height){
+ if (!ui::dialogBoxExists) {
Arena *a = new Arena(currentWorld,player,this);
a->setStyle("");
- a->setBackground( WorldBGType::Forest );
+ a->setBackground(WorldBGType::Forest);
a->setBGM("assets/music/embark.wav");
ui::toggleWhiteFast();
break;
case MS_TRIGGER:
if(player->loc.x + player->width / 2 > loc.x &&
- player->loc.x + player->width / 2 < loc.x + width )
+ player->loc.x + player->width / 2 < loc.x + width)
std::thread([this]{hey(this);}).detach();
//hey(this);
break;
if((oxml = exml->FirstChildElement("quest"))){
std::string qname;
- while ( oxml ) {
- if ( !(qname = oxml->StrAttribute("assign")).empty() )
+ while (oxml) {
+ if (!(qname = oxml->StrAttribute("assign")).empty())
player->qh.assign(qname,"None",(std::string)oxml->GetText());
- else if( !(qname = oxml->StrAttribute("check")).empty() ){
+ else if(!(qname = oxml->StrAttribute("check")).empty()){
if(player->qh.hasQuest(qname) && player->qh.finish(qname)){
goto CONT;
}else{
* Handle 'go to' thingy
*/
- if ( (oxml = exml->FirstChildElement("gotox")) )
+ if ((oxml = exml->FirstChildElement("gotox")))
speaker->targetx = atoi(oxml->GetText());
/*
return 0;
}
-void commonPageFunc( Mob *callee ){
- ui::drawPage( callee->heyid );
+void commonPageFunc(Mob *callee){
+ ui::drawPage(callee->heyid);
ui::waitForDialog();
callee->health = 0;
}
* Read the XML directory into an array.
*/
- if ( getdir( std::string("./" + xmlFolder).c_str(), xmlFiles ) )
+ if (getdir(std::string("./" + xmlFolder).c_str(), xmlFiles))
UserError("Error reading XML files!!!");
/*
optionsMenu.items.push_back(ui::menu::createSlider({-200,000}, {512,50}, {0.0f, 0.0f, 0.0f}, 0, 100, "SFX", &VOLUME_SFX));
optionsMenu.child = NULL;
optionsMenu.parent = &pauseMenu;
- // optionsMenu.push_back(ui::menu::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"), );
+ // optionsMenu.push_back(ui::menu::createButton({-256/2,-200},{256,75},{0.0f,0.0f,0.0f}, (const char*)("Save and Quit"),);
/*
* Spawn the player and begin the game.
return 0;
}
}
- items.push_back( item_t { count, i });
+ items.push_back(item_t { count, i });
return 0;
}
}
}
GLuint getItemTexture(std::string name){
- for ( int i = itemMap.size(); i--; ) {
- if ( itemMap[i]->name == name )
+ for (int i = itemMap.size(); i--;) {
+ if (itemMap[i]->name == name)
return itemtex[i];
}
- DEBUG_printf("Failed to find texture for item %s!", name.c_str() );
+ DEBUG_printf("Failed to find texture for item %s!", name.c_str());
return 0;
}
}
void Inventory::setSelectionUp(){
- if ( !sel-- )
+ if (!sel--)
sel++;
}
void Inventory::setSelectionDown(){
- if ( ++sel >= numSlot )
+ if (++sel >= numSlot)
sel = numSlot - 1;
}
static vec2 mouseStart = {0,0};
C("End define");
- for ( auto &r : iray ) {
+ for (auto &r : iray) {
r.start.x = player->loc.x + (player->width / 2);
r.start.y = player->loc.y + (player->height / 2);
curCoord[a++] = r.start;
} a = 0;
- for ( auto &cr : curRay ) {
+ for (auto &cr : curRay) {
cr.start.x = (offset.x + SCREEN_WIDTH / 2);
cr.start.y = offset.y - (a * itemWide * 1.5f);
curCurCoord[a++] = cr.start;
} a = 0;
- for ( int r = 0; r < 4; r++ ) {
- for ( int c = 0; c < 8; c++ ) {
- massRay[a ].x = ((offset.x - SCREEN_WIDTH / 2) + itemWide ) + c * itemWide * 1.5f;
+ for (int r = 0; r < 4; r++) {
+ for (int c = 0; c < 8; c++) {
+ massRay[a ].x = ((offset.x - SCREEN_WIDTH / 2) + itemWide) + c * itemWide * 1.5f;
massRay[a++].y = ((offset.y + SCREEN_HEIGHT / 2) - itemWide * 1.5f) - r * itemWide * 1.5f;
}
} a = 0;
ui::fontTransInv = 255 * (averagef(dfp) / range);
- if ( ui::fontTransInv > 255 )
+ if (ui::fontTransInv > 255)
ui::fontTransInv = 255;
- else if ( ui::fontTransInv < 0 )
+ else if (ui::fontTransInv < 0)
ui::fontTransInv = 0;
- if ( invOpening ) {
- for ( auto &d : dfp ) {
- if ( !a || dfp[a - 1] > 50 )
+ if (invOpening) {
+ for (auto &d : dfp) {
+ if (!a || dfp[a - 1] > 50)
d += 1.65f * deltaTime;
- if ( d > range )
+ if (d > range)
d = range;
a++;
} a = 0;
- for ( auto &cd : curdfp ) {
- if ( !a || curdfp[a - 1] > 90 )
+ for (auto &cd : curdfp) {
+ if (!a || curdfp[a - 1] > 90)
cd += 1.5f * deltaTime;
- if ( cd > curRange )
+ if (cd > curRange)
cd = curRange;
a++;
} a = 0;
- while ( ++a < massOrder.size() ) {
- if ( !a || massDfp[ massOrder[a - 1] ] > massRange * 0.75f )
+ while (++a < massOrder.size()) {
+ if (!a || massDfp[ massOrder[a - 1] ] > massRange * 0.75f)
massDfp[ massOrder[a] ] += 5.0f * deltaTime;
- if ( massDfp[ massOrder[a] ] > massRange )
+ if (massDfp[ massOrder[a] ] > massRange)
massDfp[ massOrder[a] ] = massRange;
} a = 0;
- if ( numSlot > 0 )
+ if (numSlot > 0)
invOpen = true;
} else {
- for ( auto &d : dfp ) {
- if ( d > 0 )
+ for (auto &d : dfp) {
+ if (d > 0)
d -= 1.65f * deltaTime;
}
- for ( auto &cd : curdfp ) {
- if ( cd > 0 )
+ for (auto &cd : curdfp) {
+ if (cd > 0)
cd -= 1.0f * deltaTime;
}
a = 0;
- while ( ++a < massRay.size() ) {
- if ( !a || massDfp[ massOrderClosing[a - 1] ] <= 0 )
+ while (++a < massRay.size()) {
+ if (!a || massDfp[ massOrderClosing[a - 1] ] <= 0)
massDfp[ massOrderClosing[a] ] -= 10.0f * deltaTime;
- if ( massDfp[ massOrderClosing[a - 1] ] < 0 )
+ if (massDfp[ massOrderClosing[a - 1] ] < 0)
massDfp[ massOrderClosing[a - 1] ] = 0;
} a = 0;
- if ( std::all_of( std::begin(massDfp), std::end(massDfp), [](auto d){ return d <= 0; } ) ) {
+ if (std::all_of(std::begin(massDfp), std::end(massDfp), [](auto d){ return d <= 0; })) {
invOpen = false;
- for ( auto &md : massDfp ) {
- if ( md < 0 )
+ for (auto &md : massDfp) {
+ if (md < 0)
md = 0;
}
}
} else
hangle = 0;
- if ( p->inv->usingi )
+ if (p->inv->usingi)
inc = 10;
- if ( inc ) {
+ if (inc) {
inc--;
p->inv->useItem();
}
glUseProgram(0);
}
-int Inventory::useItem( void )
+int Inventory::useItem(void)
{
static bool up = false;
- if ( !invHover ) {
- if ( itemMap[items[sel].id]->type == "Sword" ) {
- if ( swing ) {
+ if (!invHover) {
+ if (itemMap[items[sel].id]->type == "Sword") {
+ if (swing) {
int dir = player->left ? 1 : -1;
- if ( hangle == 15 * dir ) {
+ if (hangle == 15 * dir) {
up = true;
- Mix_PlayChannel( 2, swordSwing, 0 );
+ Mix_PlayChannel(2, swordSwing, 0);
}
- if ( up )
+ if (up)
hangle += 0.325f * dir * deltaTime;
- if ( !player->left ) {
- if ( hangle <= -90 )
+ if (!player->left) {
+ if (hangle <= -90)
hangle = -14;
- } else if ( hangle >= 90 )
+ } else if (hangle >= 90)
hangle = 14;
} else {
swing = true;
- Mix_PlayChannel( 2, swordSwing, 0 );
+ Mix_PlayChannel(2, swordSwing, 0);
}
}else if(itemMap[items[sel].id]->type == "Cooked Food"){
player->health += itemMap[items[sel].id]->attribValue;
tmp.title = title;\r
tmp.desc = desc;\r
\r
- tok = strtok( &req[0], "\n\r\t," );\r
- tmp.need.emplace_back( "", 0 );\r
+ tok = strtok(&req[0], "\n\r\t,");\r
+ tmp.need.emplace_back("", 0);\r
\r
- while ( tok ) {\r
- if ( !tmp.need.back().first.empty() ) {\r
- tmp.need.back().second = atoi( tok );\r
- tmp.need.emplace_back( "", 0 );\r
+ while (tok) {\r
+ if (!tmp.need.back().first.empty()) {\r
+ tmp.need.back().second = atoi(tok);\r
+ tmp.need.emplace_back("", 0);\r
} else\r
tmp.need.back().first = tok;\r
\r
- tok = strtok( NULL, "\n\r\t," );\r
+ tok = strtok(NULL, "\n\r\t,");\r
}\r
\r
tmp.need.pop_back();\r
- current.push_back( tmp );\r
+ current.push_back(tmp);\r
\r
return 0;\r
}\r
\r
int QuestHandler::drop(std::string title){\r
- current.erase( std::remove_if( current.begin(),\r
+ current.erase(std::remove_if(current.begin(),\r
current.end(),\r
[&](Quest q){ return q.title == title; }),\r
- current.end() );\r
+ current.end());\r
\r
return 0;\r
}\r
\r
int QuestHandler::finish(std::string t){\r
- for ( auto c = current.begin(); c != current.end(); c++ ) {\r
- if ( (*c).title == t ) {\r
- for ( auto &n : (*c).need ) {\r
- if ( player->inv->hasItem( n.first ) < n.second )\r
+ for (auto c = current.begin(); c != current.end(); c++) {\r
+ if ((*c).title == t) {\r
+ for (auto &n : (*c).need) {\r
+ if (player->inv->hasItem(n.first) < n.second)\r
return 0;\r
}\r
\r
- for ( auto &n : (*c).need )\r
- player->inv->takeItem( n.first, n.second );\r
- current.erase( c );\r
+ for (auto &n : (*c).need)\r
+ player->inv->takeItem(n.first, n.second);\r
+ current.erase(c);\r
return 1;\r
}\r
}\r
}\r
\r
bool QuestHandler::hasQuest(std::string t){\r
- for ( auto &c : current ) {\r
- if ( c.title == t )\r
+ for (auto &c : current) {\r
+ if (c.title == t)\r
return true;\r
}\r
\r
GL_RGBA,
GL_UNSIGNED_BYTE,
image->pixels
- );
+ );
// add texture to LoadedTexture
LoadedTexture.push_back(texture_t{fileName,object,{image->w,image->h}});
texState = 0;
va_start(fNames, amt);
for(unsigned int i = 0; i < amt; i++)
- image.push_back( Texture::loadTexture(va_arg(fNames, char *)) );
+ image.push_back(Texture::loadTexture(va_arg(fNames, char *)));
va_end(fNames);
}
-Texturec::Texturec( std::initializer_list<std::string> l )
+Texturec::Texturec(std::initializer_list<std::string> l)
{
texState = 0;
- std::for_each( l.begin(), l.end(), [&](std::string s){ image.push_back( Texture::loadTexture( s ) ); });
+ std::for_each(l.begin(), l.end(), [&](std::string s){ image.push_back(Texture::loadTexture(s)); });
}
Texturec::Texturec(std::vector<std::string>v){
texState = 0;
- std::for_each( v.begin(), v.end(), [&](std::string s){ image.push_back( Texture::loadTexture( s ) ); });
+ std::for_each(v.begin(), v.end(), [&](std::string s){ image.push_back(Texture::loadTexture(s)); });
}
Texturec::Texturec(uint amt,const char **paths){
texState = 0;
for(unsigned int i = 0; i < amt; i++)
- image.push_back( Texture::loadTexture(paths[i]) );
+ image.push_back(Texture::loadTexture(paths[i]));
}
Texturec::~Texturec(){
# include <cstdarg>\r
#endif\r
\r
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)\r
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && (!defined WINCE)\r
// Microsoft Visual Studio, version 2005 and higher. Not WinCE.\r
/*int _snprintf_s(\r
char *buffer,\r
const char *format [,\r
argument] ...\r
);*/\r
- static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )\r
+ static inline int TIXML_SNPRINTF(char* buffer, size_t size, const char* format, ...)\r
{\r
va_list va;\r
- va_start( va, format );\r
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );\r
- va_end( va );\r
+ va_start(va, format);\r
+ int result = vsnprintf_s(buffer, size, _TRUNCATE, format, va);\r
+ va_end(va);\r
return result;\r
}\r
\r
- static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )\r
+ static inline int TIXML_VSNPRINTF(char* buffer, size_t size, const char* format, va_list va)\r
{\r
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );\r
+ int result = vsnprintf_s(buffer, size, _TRUNCATE, format, va);\r
return result;\r
}\r
\r
#define TIXML_SNPRINTF _snprintf\r
#define TIXML_VSNPRINTF _vsnprintf\r
#define TIXML_SSCANF sscanf\r
- #if (_MSC_VER < 1400 ) && (!defined WINCE)\r
+ #if (_MSC_VER < 1400) && (!defined WINCE)\r
// Microsoft Visual Studio 2003 and not WinCE.\r
#define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.\r
#else\r
// Microsoft Visual Studio 2003 and earlier or WinCE.\r
- static inline int TIXML_VSCPRINTF( const char* format, va_list va )\r
+ static inline int TIXML_VSCPRINTF(const char* format, va_list va)\r
{\r
int len = 512;\r
for (;;) {\r
char* str = new char[len]();\r
const int required = _vsnprintf(str, len, format, va);\r
delete[] str;\r
- if ( required != -1 ) {\r
- TIXMLASSERT( required >= 0 );\r
+ if (required != -1) {\r
+ TIXMLASSERT(required >= 0);\r
len = required;\r
break;\r
}\r
}\r
- TIXMLASSERT( len >= 0 );\r
+ TIXMLASSERT(len >= 0);\r
return len;\r
}\r
#endif\r
#else\r
// GCC version 3 and higher\r
- //#warning( "Using sn* functions." )\r
+ //#warning("Using sn* functions.")\r
#define TIXML_SNPRINTF snprintf\r
#define TIXML_VSNPRINTF vsnprintf\r
- static inline int TIXML_VSCPRINTF( const char* format, va_list va )\r
+ static inline int TIXML_VSCPRINTF(const char* format, va_list va)\r
{\r
- int len = vsnprintf( 0, 0, format, va );\r
- TIXMLASSERT( len >= 0 );\r
+ int len = vsnprintf(0, 0, format, va);\r
+ TIXMLASSERT(len >= 0);\r
return len;\r
}\r
#define TIXML_SSCANF sscanf\r
}\r
\r
\r
-void StrPair::TransferTo( StrPair* other )\r
+void StrPair::TransferTo(StrPair* other)\r
{\r
- if ( this == other ) {\r
+ if (this == other) {\r
return;\r
}\r
// This in effect implements the assignment operator by "moving"\r
// ownership (as in auto_ptr).\r
\r
- TIXMLASSERT( other->_flags == 0 );\r
- TIXMLASSERT( other->_start == 0 );\r
- TIXMLASSERT( other->_end == 0 );\r
+ TIXMLASSERT(other->_flags == 0);\r
+ TIXMLASSERT(other->_start == 0);\r
+ TIXMLASSERT(other->_end == 0);\r
\r
other->Reset();\r
\r
\r
void StrPair::Reset()\r
{\r
- if ( _flags & NEEDS_DELETE ) {\r
+ if (_flags & NEEDS_DELETE) {\r
delete [] _start;\r
}\r
_flags = 0;\r
}\r
\r
\r
-void StrPair::SetStr( const char* str, int flags )\r
+void StrPair::SetStr(const char* str, int flags)\r
{\r
- TIXMLASSERT( str );\r
+ TIXMLASSERT(str);\r
Reset();\r
- size_t len = strlen( str );\r
- TIXMLASSERT( _start == 0 );\r
+ size_t len = strlen(str);\r
+ TIXMLASSERT(_start == 0);\r
_start = new char[ len+1 ];\r
- memcpy( _start, str, len+1 );\r
+ memcpy(_start, str, len+1);\r
_end = _start + len;\r
_flags = flags | NEEDS_DELETE;\r
}\r
\r
\r
-char* StrPair::ParseText( char* p, const char* endTag, int strFlags )\r
+char* StrPair::ParseText(char* p, const char* endTag, int strFlags)\r
{\r
- TIXMLASSERT( endTag && *endTag );\r
+ TIXMLASSERT(endTag && *endTag);\r
\r
char* start = p;\r
char endChar = *endTag;\r
- size_t length = strlen( endTag );\r
+ size_t length = strlen(endTag);\r
\r
// Inner loop of text parsing.\r
- while ( *p ) {\r
- if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {\r
- Set( start, p, strFlags );\r
+ while (*p) {\r
+ if (*p == endChar && strncmp(p, endTag, length) == 0) {\r
+ Set(start, p, strFlags);\r
return p + length;\r
}\r
++p;\r
}\r
\r
\r
-char* StrPair::ParseName( char* p )\r
+char* StrPair::ParseName(char* p)\r
{\r
- if ( !p || !(*p) ) {\r
+ if (!p || !(*p)) {\r
return 0;\r
}\r
- if ( !XMLUtil::IsNameStartChar( *p ) ) {\r
+ if (!XMLUtil::IsNameStartChar(*p)) {\r
return 0;\r
}\r
\r
char* const start = p;\r
++p;\r
- while ( *p && XMLUtil::IsNameChar( *p ) ) {\r
+ while (*p && XMLUtil::IsNameChar(*p)) {\r
++p;\r
}\r
\r
- Set( start, p, 0 );\r
+ Set(start, p, 0);\r
return p;\r
}\r
\r
void StrPair::CollapseWhitespace()\r
{\r
// Adjusting _start would cause undefined behavior on delete[]\r
- TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 );\r
+ TIXMLASSERT((_flags & NEEDS_DELETE) == 0);\r
// Trim leading space.\r
- _start = XMLUtil::SkipWhiteSpace( _start );\r
+ _start = XMLUtil::SkipWhiteSpace(_start);\r
\r
- if ( *_start ) {\r
+ if (*_start) {\r
char* p = _start; // the read pointer\r
char* q = _start; // the write pointer\r
\r
- while( *p ) {\r
- if ( XMLUtil::IsWhiteSpace( *p )) {\r
- p = XMLUtil::SkipWhiteSpace( p );\r
- if ( *p == 0 ) {\r
+ while(*p) {\r
+ if (XMLUtil::IsWhiteSpace(*p)) {\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
+ if (*p == 0) {\r
break; // don't write to q; this trims the trailing space.\r
}\r
*q = ' ';\r
\r
const char* StrPair::GetStr()\r
{\r
- TIXMLASSERT( _start );\r
- TIXMLASSERT( _end );\r
- if ( _flags & NEEDS_FLUSH ) {\r
+ TIXMLASSERT(_start);\r
+ TIXMLASSERT(_end);\r
+ if (_flags & NEEDS_FLUSH) {\r
*_end = 0;\r
_flags ^= NEEDS_FLUSH;\r
\r
- if ( _flags ) {\r
+ if (_flags) {\r
char* p = _start; // the read pointer\r
char* q = _start; // the write pointer\r
\r
- while( p < _end ) {\r
- if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {\r
+ while(p < _end) {\r
+ if ((_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR) {\r
// CR-LF pair becomes LF\r
// CR alone becomes LF\r
// LF-CR becomes LF\r
- if ( *(p+1) == LF ) {\r
+ if (*(p+1) == LF) {\r
p += 2;\r
}\r
else {\r
}\r
*q++ = LF;\r
}\r
- else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {\r
- if ( *(p+1) == CR ) {\r
+ else if ((_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF) {\r
+ if (*(p+1) == CR) {\r
p += 2;\r
}\r
else {\r
}\r
*q++ = LF;\r
}\r
- else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {\r
+ else if ((_flags & NEEDS_ENTITY_PROCESSING) && *p == '&') {\r
// Entities handled by tinyXML2:\r
// - special entities in the entity table [in/out]\r
// - numeric character reference [in]\r
// 中 or 中\r
\r
- if ( *(p+1) == '#' ) {\r
+ if (*(p+1) == '#') {\r
const int buflen = 10;\r
char buf[buflen] = { 0 };\r
int len = 0;\r
- char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );\r
- if ( adjusted == 0 ) {\r
+ char* adjusted = const_cast<char*>(XMLUtil::GetCharacterRef(p, buf, &len));\r
+ if (adjusted == 0) {\r
*q = *p;\r
++p;\r
++q;\r
}\r
else {\r
- TIXMLASSERT( 0 <= len && len <= buflen );\r
- TIXMLASSERT( q + len <= adjusted );\r
+ TIXMLASSERT(0 <= len && len <= buflen);\r
+ TIXMLASSERT(q + len <= adjusted);\r
p = adjusted;\r
- memcpy( q, buf, len );\r
+ memcpy(q, buf, len);\r
q += len;\r
}\r
}\r
else {\r
bool entityFound = false;\r
- for( int i = 0; i < NUM_ENTITIES; ++i ) {\r
+ for(int i = 0; i < NUM_ENTITIES; ++i) {\r
const Entity& entity = entities[i];\r
- if ( strncmp( p + 1, entity.pattern, entity.length ) == 0\r
- && *( p + entity.length + 1 ) == ';' ) {\r
+ if (strncmp(p + 1, entity.pattern, entity.length) == 0\r
+ && *(p + entity.length + 1) == ';') {\r
// Found an entity - convert.\r
*q = entity.value;\r
++q;\r
break;\r
}\r
}\r
- if ( !entityFound ) {\r
+ if (!entityFound) {\r
// fixme: treat as error?\r
++p;\r
++q;\r
}\r
// The loop below has plenty going on, and this\r
// is a less useful mode. Break it out.\r
- if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) {\r
+ if (_flags & NEEDS_WHITESPACE_COLLAPSING) {\r
CollapseWhitespace();\r
}\r
_flags = (_flags & NEEDS_DELETE);\r
}\r
- TIXMLASSERT( _start );\r
+ TIXMLASSERT(_start);\r
return _start;\r
}\r
\r
\r
// --------- XMLUtil ----------- //\r
\r
-const char* XMLUtil::ReadBOM( const char* p, bool* bom )\r
+const char* XMLUtil::ReadBOM(const char* p, bool* bom)\r
{\r
- TIXMLASSERT( p );\r
- TIXMLASSERT( bom );\r
+ TIXMLASSERT(p);\r
+ TIXMLASSERT(bom);\r
*bom = false;\r
const unsigned char* pu = reinterpret_cast<const unsigned char*>(p);\r
// Check for BOM:\r
- if ( *(pu+0) == TIXML_UTF_LEAD_0\r
+ if (*(pu+0) == TIXML_UTF_LEAD_0\r
&& *(pu+1) == TIXML_UTF_LEAD_1\r
- && *(pu+2) == TIXML_UTF_LEAD_2 ) {\r
+ && *(pu+2) == TIXML_UTF_LEAD_2) {\r
*bom = true;\r
p += 3;\r
}\r
- TIXMLASSERT( p );\r
+ TIXMLASSERT(p);\r
return p;\r
}\r
\r
\r
-void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )\r
+void XMLUtil::ConvertUTF32ToUTF8(unsigned long input, char* output, int* length)\r
{\r
const unsigned long BYTE_MASK = 0xBF;\r
const unsigned long BYTE_MARK = 0x80;\r
if (input < 0x80) {\r
*length = 1;\r
}\r
- else if ( input < 0x800 ) {\r
+ else if (input < 0x800) {\r
*length = 2;\r
}\r
- else if ( input < 0x10000 ) {\r
+ else if (input < 0x10000) {\r
*length = 3;\r
}\r
- else if ( input < 0x200000 ) {\r
+ else if (input < 0x200000) {\r
*length = 4;\r
}\r
else {\r
*output = (char)(input | FIRST_BYTE_MARK[*length]);\r
break;\r
default:\r
- TIXMLASSERT( false );\r
+ TIXMLASSERT(false);\r
}\r
}\r
\r
\r
-const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )\r
+const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length)\r
{\r
// Presume an entity, and pull it out.\r
*length = 0;\r
\r
- if ( *(p+1) == '#' && *(p+2) ) {\r
+ if (*(p+1) == '#' && *(p+2)) {\r
unsigned long ucs = 0;\r
- TIXMLASSERT( sizeof( ucs ) >= 4 );\r
+ TIXMLASSERT(sizeof(ucs) >= 4);\r
ptrdiff_t delta = 0;\r
unsigned mult = 1;\r
static const char SEMICOLON = ';';\r
\r
- if ( *(p+2) == 'x' ) {\r
+ if (*(p+2) == 'x') {\r
// Hexadecimal.\r
const char* q = p+3;\r
- if ( !(*q) ) {\r
+ if (!(*q)) {\r
return 0;\r
}\r
\r
- q = strchr( q, SEMICOLON );\r
+ q = strchr(q, SEMICOLON);\r
\r
- if ( !q ) {\r
+ if (!q) {\r
return 0;\r
}\r
- TIXMLASSERT( *q == SEMICOLON );\r
+ TIXMLASSERT(*q == SEMICOLON);\r
\r
delta = q-p;\r
--q;\r
\r
- while ( *q != 'x' ) {\r
+ while (*q != 'x') {\r
unsigned int digit = 0;\r
\r
- if ( *q >= '0' && *q <= '9' ) {\r
+ if (*q >= '0' && *q <= '9') {\r
digit = *q - '0';\r
}\r
- else if ( *q >= 'a' && *q <= 'f' ) {\r
+ else if (*q >= 'a' && *q <= 'f') {\r
digit = *q - 'a' + 10;\r
}\r
- else if ( *q >= 'A' && *q <= 'F' ) {\r
+ else if (*q >= 'A' && *q <= 'F') {\r
digit = *q - 'A' + 10;\r
}\r
else {\r
return 0;\r
}\r
- TIXMLASSERT( digit >= 0 && digit < 16);\r
- TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );\r
+ TIXMLASSERT(digit >= 0 && digit < 16);\r
+ TIXMLASSERT(digit == 0 || mult <= UINT_MAX / digit);\r
const unsigned int digitScaled = mult * digit;\r
- TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );\r
+ TIXMLASSERT(ucs <= ULONG_MAX - digitScaled);\r
ucs += digitScaled;\r
- TIXMLASSERT( mult <= UINT_MAX / 16 );\r
+ TIXMLASSERT(mult <= UINT_MAX / 16);\r
mult *= 16;\r
--q;\r
}\r
else {\r
// Decimal.\r
const char* q = p+2;\r
- if ( !(*q) ) {\r
+ if (!(*q)) {\r
return 0;\r
}\r
\r
- q = strchr( q, SEMICOLON );\r
+ q = strchr(q, SEMICOLON);\r
\r
- if ( !q ) {\r
+ if (!q) {\r
return 0;\r
}\r
- TIXMLASSERT( *q == SEMICOLON );\r
+ TIXMLASSERT(*q == SEMICOLON);\r
\r
delta = q-p;\r
--q;\r
\r
- while ( *q != '#' ) {\r
- if ( *q >= '0' && *q <= '9' ) {\r
+ while (*q != '#') {\r
+ if (*q >= '0' && *q <= '9') {\r
const unsigned int digit = *q - '0';\r
- TIXMLASSERT( digit >= 0 && digit < 10);\r
- TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );\r
+ TIXMLASSERT(digit >= 0 && digit < 10);\r
+ TIXMLASSERT(digit == 0 || mult <= UINT_MAX / digit);\r
const unsigned int digitScaled = mult * digit;\r
- TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );\r
+ TIXMLASSERT(ucs <= ULONG_MAX - digitScaled);\r
ucs += digitScaled;\r
}\r
else {\r
return 0;\r
}\r
- TIXMLASSERT( mult <= UINT_MAX / 10 );\r
+ TIXMLASSERT(mult <= UINT_MAX / 10);\r
mult *= 10;\r
--q;\r
}\r
}\r
// convert the UCS to UTF-8\r
- ConvertUTF32ToUTF8( ucs, value, length );\r
+ ConvertUTF32ToUTF8(ucs, value, length);\r
return p + delta + 1;\r
}\r
return p+1;\r
}\r
\r
\r
-void XMLUtil::ToStr( int v, char* buffer, int bufferSize )\r
+void XMLUtil::ToStr(int v, char* buffer, int bufferSize)\r
{\r
- TIXML_SNPRINTF( buffer, bufferSize, "%d", v );\r
+ TIXML_SNPRINTF(buffer, bufferSize, "%d", v);\r
}\r
\r
\r
-void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize )\r
+void XMLUtil::ToStr(unsigned v, char* buffer, int bufferSize)\r
{\r
- TIXML_SNPRINTF( buffer, bufferSize, "%u", v );\r
+ TIXML_SNPRINTF(buffer, bufferSize, "%u", v);\r
}\r
\r
\r
-void XMLUtil::ToStr( bool v, char* buffer, int bufferSize )\r
+void XMLUtil::ToStr(bool v, char* buffer, int bufferSize)\r
{\r
- TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 );\r
+ TIXML_SNPRINTF(buffer, bufferSize, "%d", v ? 1 : 0);\r
}\r
\r
/*\r
ToStr() of a number is a very tricky topic.\r
https://github.com/leethomason/tinyxml2/issues/106\r
*/\r
-void XMLUtil::ToStr( float v, char* buffer, int bufferSize )\r
+void XMLUtil::ToStr(float v, char* buffer, int bufferSize)\r
{\r
- TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v );\r
+ TIXML_SNPRINTF(buffer, bufferSize, "%.8g", v);\r
}\r
\r
\r
-void XMLUtil::ToStr( double v, char* buffer, int bufferSize )\r
+void XMLUtil::ToStr(double v, char* buffer, int bufferSize)\r
{\r
- TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v );\r
+ TIXML_SNPRINTF(buffer, bufferSize, "%.17g", v);\r
}\r
\r
\r
-bool XMLUtil::ToInt( const char* str, int* value )\r
+bool XMLUtil::ToInt(const char* str, int* value)\r
{\r
- if ( TIXML_SSCANF( str, "%d", value ) == 1 ) {\r
+ if (TIXML_SSCANF(str, "%d", value) == 1) {\r
return true;\r
}\r
return false;\r
}\r
\r
-bool XMLUtil::ToUnsigned( const char* str, unsigned *value )\r
+bool XMLUtil::ToUnsigned(const char* str, unsigned *value)\r
{\r
- if ( TIXML_SSCANF( str, "%u", value ) == 1 ) {\r
+ if (TIXML_SSCANF(str, "%u", value) == 1) {\r
return true;\r
}\r
return false;\r
}\r
\r
-bool XMLUtil::ToBool( const char* str, bool* value )\r
+bool XMLUtil::ToBool(const char* str, bool* value)\r
{\r
int ival = 0;\r
- if ( ToInt( str, &ival )) {\r
+ if (ToInt(str, &ival)) {\r
*value = (ival==0) ? false : true;\r
return true;\r
}\r
- if ( StringEqual( str, "true" ) ) {\r
+ if (StringEqual(str, "true")) {\r
*value = true;\r
return true;\r
}\r
- else if ( StringEqual( str, "false" ) ) {\r
+ else if (StringEqual(str, "false")) {\r
*value = false;\r
return true;\r
}\r
}\r
\r
\r
-bool XMLUtil::ToFloat( const char* str, float* value )\r
+bool XMLUtil::ToFloat(const char* str, float* value)\r
{\r
- if ( TIXML_SSCANF( str, "%f", value ) == 1 ) {\r
+ if (TIXML_SSCANF(str, "%f", value) == 1) {\r
return true;\r
}\r
return false;\r
}\r
\r
-bool XMLUtil::ToDouble( const char* str, double* value )\r
+bool XMLUtil::ToDouble(const char* str, double* value)\r
{\r
- if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) {\r
+ if (TIXML_SSCANF(str, "%lf", value) == 1) {\r
return true;\r
}\r
return false;\r
}\r
\r
\r
-char* XMLDocument::Identify( char* p, XMLNode** node )\r
+char* XMLDocument::Identify(char* p, XMLNode** node)\r
{\r
- TIXMLASSERT( node );\r
- TIXMLASSERT( p );\r
+ TIXMLASSERT(node);\r
+ TIXMLASSERT(p);\r
char* const start = p;\r
- p = XMLUtil::SkipWhiteSpace( p );\r
- if( !*p ) {\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
+ if(!*p) {\r
*node = 0;\r
- TIXMLASSERT( p );\r
+ TIXMLASSERT(p);\r
return p;\r
}\r
\r
static const int dtdHeaderLen = 2;\r
static const int elementHeaderLen = 1;\r
\r
- TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool\r
- TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool\r
+ TIXMLASSERT(sizeof(XMLComment) == sizeof(XMLUnknown)); // use same memory pool\r
+ TIXMLASSERT(sizeof(XMLComment) == sizeof(XMLDeclaration)); // use same memory pool\r
XMLNode* returnNode = 0;\r
- if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {\r
- TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() );\r
- returnNode = new (_commentPool.Alloc()) XMLDeclaration( this );\r
+ if (XMLUtil::StringEqual(p, xmlHeader, xmlHeaderLen)) {\r
+ TIXMLASSERT(sizeof(XMLDeclaration) == _commentPool.ItemSize());\r
+ returnNode = new (_commentPool.Alloc()) XMLDeclaration(this);\r
returnNode->_memPool = &_commentPool;\r
p += xmlHeaderLen;\r
}\r
- else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) {\r
- TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() );\r
- returnNode = new (_commentPool.Alloc()) XMLComment( this );\r
+ else if (XMLUtil::StringEqual(p, commentHeader, commentHeaderLen)) {\r
+ TIXMLASSERT(sizeof(XMLComment) == _commentPool.ItemSize());\r
+ returnNode = new (_commentPool.Alloc()) XMLComment(this);\r
returnNode->_memPool = &_commentPool;\r
p += commentHeaderLen;\r
}\r
- else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) {\r
- TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() );\r
- XMLText* text = new (_textPool.Alloc()) XMLText( this );\r
+ else if (XMLUtil::StringEqual(p, cdataHeader, cdataHeaderLen)) {\r
+ TIXMLASSERT(sizeof(XMLText) == _textPool.ItemSize());\r
+ XMLText* text = new (_textPool.Alloc()) XMLText(this);\r
returnNode = text;\r
returnNode->_memPool = &_textPool;\r
p += cdataHeaderLen;\r
- text->SetCData( true );\r
+ text->SetCData(true);\r
}\r
- else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) {\r
- TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() );\r
- returnNode = new (_commentPool.Alloc()) XMLUnknown( this );\r
+ else if (XMLUtil::StringEqual(p, dtdHeader, dtdHeaderLen)) {\r
+ TIXMLASSERT(sizeof(XMLUnknown) == _commentPool.ItemSize());\r
+ returnNode = new (_commentPool.Alloc()) XMLUnknown(this);\r
returnNode->_memPool = &_commentPool;\r
p += dtdHeaderLen;\r
}\r
- else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) {\r
- TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() );\r
- returnNode = new (_elementPool.Alloc()) XMLElement( this );\r
+ else if (XMLUtil::StringEqual(p, elementHeader, elementHeaderLen)) {\r
+ TIXMLASSERT(sizeof(XMLElement) == _elementPool.ItemSize());\r
+ returnNode = new (_elementPool.Alloc()) XMLElement(this);\r
returnNode->_memPool = &_elementPool;\r
p += elementHeaderLen;\r
}\r
else {\r
- TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() );\r
- returnNode = new (_textPool.Alloc()) XMLText( this );\r
+ TIXMLASSERT(sizeof(XMLText) == _textPool.ItemSize());\r
+ returnNode = new (_textPool.Alloc()) XMLText(this);\r
returnNode->_memPool = &_textPool;\r
p = start; // Back it up, all the text counts.\r
}\r
\r
- TIXMLASSERT( returnNode );\r
- TIXMLASSERT( p );\r
+ TIXMLASSERT(returnNode);\r
+ TIXMLASSERT(p);\r
*node = returnNode;\r
return p;\r
}\r
\r
\r
-bool XMLDocument::Accept( XMLVisitor* visitor ) const\r
+bool XMLDocument::Accept(XMLVisitor* visitor) const\r
{\r
- TIXMLASSERT( visitor );\r
- if ( visitor->VisitEnter( *this ) ) {\r
- for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) {\r
- if ( !node->Accept( visitor ) ) {\r
+ TIXMLASSERT(visitor);\r
+ if (visitor->VisitEnter(*this)) {\r
+ for (const XMLNode* node=FirstChild(); node; node=node->NextSibling()) {\r
+ if (!node->Accept(visitor)) {\r
break;\r
}\r
}\r
}\r
- return visitor->VisitExit( *this );\r
+ return visitor->VisitExit(*this);\r
}\r
\r
\r
// --------- XMLNode ----------- //\r
\r
-XMLNode::XMLNode( XMLDocument* doc ) :\r
- _document( doc ),\r
- _parent( 0 ),\r
- _firstChild( 0 ), _lastChild( 0 ),\r
- _prev( 0 ), _next( 0 ),\r
- _memPool( 0 )\r
+XMLNode::XMLNode(XMLDocument* doc) :\r
+ _document(doc),\r
+ _parent(0),\r
+ _firstChild(0), _lastChild(0),\r
+ _prev(0), _next(0),\r
+ _memPool(0)\r
{\r
}\r
\r
XMLNode::~XMLNode()\r
{\r
DeleteChildren();\r
- if ( _parent ) {\r
- _parent->Unlink( this );\r
+ if (_parent) {\r
+ _parent->Unlink(this);\r
}\r
}\r
\r
const char* XMLNode::Value() const \r
{\r
// Catch an edge case: XMLDocuments don't have a a Value. Carefully return nullptr.\r
- if ( this->ToDocument() )\r
+ if (this->ToDocument())\r
return 0;\r
return _value.GetStr();\r
}\r
\r
-void XMLNode::SetValue( const char* str, bool staticMem )\r
+void XMLNode::SetValue(const char* str, bool staticMem)\r
{\r
- if ( staticMem ) {\r
- _value.SetInternedStr( str );\r
+ if (staticMem) {\r
+ _value.SetInternedStr(str);\r
}\r
else {\r
- _value.SetStr( str );\r
+ _value.SetStr(str);\r
}\r
}\r
\r
\r
void XMLNode::DeleteChildren()\r
{\r
- while( _firstChild ) {\r
- TIXMLASSERT( _lastChild );\r
- TIXMLASSERT( _firstChild->_document == _document );\r
+ while(_firstChild) {\r
+ TIXMLASSERT(_lastChild);\r
+ TIXMLASSERT(_firstChild->_document == _document);\r
XMLNode* node = _firstChild;\r
- Unlink( node );\r
+ Unlink(node);\r
\r
- DeleteNode( node );\r
+ DeleteNode(node);\r
}\r
_firstChild = _lastChild = 0;\r
}\r
\r
\r
-void XMLNode::Unlink( XMLNode* child )\r
+void XMLNode::Unlink(XMLNode* child)\r
{\r
- TIXMLASSERT( child );\r
- TIXMLASSERT( child->_document == _document );\r
- TIXMLASSERT( child->_parent == this );\r
- if ( child == _firstChild ) {\r
+ TIXMLASSERT(child);\r
+ TIXMLASSERT(child->_document == _document);\r
+ TIXMLASSERT(child->_parent == this);\r
+ if (child == _firstChild) {\r
_firstChild = _firstChild->_next;\r
}\r
- if ( child == _lastChild ) {\r
+ if (child == _lastChild) {\r
_lastChild = _lastChild->_prev;\r
}\r
\r
- if ( child->_prev ) {\r
+ if (child->_prev) {\r
child->_prev->_next = child->_next;\r
}\r
- if ( child->_next ) {\r
+ if (child->_next) {\r
child->_next->_prev = child->_prev;\r
}\r
child->_parent = 0;\r
}\r
\r
\r
-void XMLNode::DeleteChild( XMLNode* node )\r
+void XMLNode::DeleteChild(XMLNode* node)\r
{\r
- TIXMLASSERT( node );\r
- TIXMLASSERT( node->_document == _document );\r
- TIXMLASSERT( node->_parent == this );\r
- Unlink( node );\r
- DeleteNode( node );\r
+ TIXMLASSERT(node);\r
+ TIXMLASSERT(node->_document == _document);\r
+ TIXMLASSERT(node->_parent == this);\r
+ Unlink(node);\r
+ DeleteNode(node);\r
}\r
\r
\r
-XMLNode* XMLNode::InsertEndChild( XMLNode* addThis )\r
+XMLNode* XMLNode::InsertEndChild(XMLNode* addThis)\r
{\r
- TIXMLASSERT( addThis );\r
- if ( addThis->_document != _document ) {\r
- TIXMLASSERT( false );\r
+ TIXMLASSERT(addThis);\r
+ if (addThis->_document != _document) {\r
+ TIXMLASSERT(false);\r
return 0;\r
}\r
- InsertChildPreamble( addThis );\r
+ InsertChildPreamble(addThis);\r
\r
- if ( _lastChild ) {\r
- TIXMLASSERT( _firstChild );\r
- TIXMLASSERT( _lastChild->_next == 0 );\r
+ if (_lastChild) {\r
+ TIXMLASSERT(_firstChild);\r
+ TIXMLASSERT(_lastChild->_next == 0);\r
_lastChild->_next = addThis;\r
addThis->_prev = _lastChild;\r
_lastChild = addThis;\r
addThis->_next = 0;\r
}\r
else {\r
- TIXMLASSERT( _firstChild == 0 );\r
+ TIXMLASSERT(_firstChild == 0);\r
_firstChild = _lastChild = addThis;\r
\r
addThis->_prev = 0;\r
}\r
\r
\r
-XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )\r
+XMLNode* XMLNode::InsertFirstChild(XMLNode* addThis)\r
{\r
- TIXMLASSERT( addThis );\r
- if ( addThis->_document != _document ) {\r
- TIXMLASSERT( false );\r
+ TIXMLASSERT(addThis);\r
+ if (addThis->_document != _document) {\r
+ TIXMLASSERT(false);\r
return 0;\r
}\r
- InsertChildPreamble( addThis );\r
+ InsertChildPreamble(addThis);\r
\r
- if ( _firstChild ) {\r
- TIXMLASSERT( _lastChild );\r
- TIXMLASSERT( _firstChild->_prev == 0 );\r
+ if (_firstChild) {\r
+ TIXMLASSERT(_lastChild);\r
+ TIXMLASSERT(_firstChild->_prev == 0);\r
\r
_firstChild->_prev = addThis;\r
addThis->_next = _firstChild;\r
addThis->_prev = 0;\r
}\r
else {\r
- TIXMLASSERT( _lastChild == 0 );\r
+ TIXMLASSERT(_lastChild == 0);\r
_firstChild = _lastChild = addThis;\r
\r
addThis->_prev = 0;\r
}\r
\r
\r
-XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )\r
+XMLNode* XMLNode::InsertAfterChild(XMLNode* afterThis, XMLNode* addThis)\r
{\r
- TIXMLASSERT( addThis );\r
- if ( addThis->_document != _document ) {\r
- TIXMLASSERT( false );\r
+ TIXMLASSERT(addThis);\r
+ if (addThis->_document != _document) {\r
+ TIXMLASSERT(false);\r
return 0;\r
}\r
\r
- TIXMLASSERT( afterThis );\r
+ TIXMLASSERT(afterThis);\r
\r
- if ( afterThis->_parent != this ) {\r
- TIXMLASSERT( false );\r
+ if (afterThis->_parent != this) {\r
+ TIXMLASSERT(false);\r
return 0;\r
}\r
\r
- if ( afterThis->_next == 0 ) {\r
+ if (afterThis->_next == 0) {\r
// The last node or the only node.\r
- return InsertEndChild( addThis );\r
+ return InsertEndChild(addThis);\r
}\r
- InsertChildPreamble( addThis );\r
+ InsertChildPreamble(addThis);\r
addThis->_prev = afterThis;\r
addThis->_next = afterThis->_next;\r
afterThis->_next->_prev = addThis;\r
\r
\r
\r
-const XMLElement* XMLNode::FirstChildElement( const char* name ) const\r
+const XMLElement* XMLNode::FirstChildElement(const char* name) const\r
{\r
- for( const XMLNode* node = _firstChild; node; node = node->_next ) {\r
+ for(const XMLNode* node = _firstChild; node; node = node->_next) {\r
const XMLElement* element = node->ToElement();\r
- if ( element ) {\r
- if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) {\r
+ if (element) {\r
+ if (!name || XMLUtil::StringEqual(element->Name(), name)) {\r
return element;\r
}\r
}\r
}\r
\r
\r
-const XMLElement* XMLNode::LastChildElement( const char* name ) const\r
+const XMLElement* XMLNode::LastChildElement(const char* name) const\r
{\r
- for( const XMLNode* node = _lastChild; node; node = node->_prev ) {\r
+ for(const XMLNode* node = _lastChild; node; node = node->_prev) {\r
const XMLElement* element = node->ToElement();\r
- if ( element ) {\r
- if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) {\r
+ if (element) {\r
+ if (!name || XMLUtil::StringEqual(element->Name(), name)) {\r
return element;\r
}\r
}\r
}\r
\r
\r
-const XMLElement* XMLNode::NextSiblingElement( const char* name ) const\r
+const XMLElement* XMLNode::NextSiblingElement(const char* name) const\r
{\r
- for( const XMLNode* node = _next; node; node = node->_next ) {\r
+ for(const XMLNode* node = _next; node; node = node->_next) {\r
const XMLElement* element = node->ToElement();\r
- if ( element\r
- && (!name || XMLUtil::StringEqual( name, element->Name() ))) {\r
+ if (element\r
+ && (!name || XMLUtil::StringEqual(name, element->Name()))) {\r
return element;\r
}\r
}\r
}\r
\r
\r
-const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const\r
+const XMLElement* XMLNode::PreviousSiblingElement(const char* name) const\r
{\r
- for( const XMLNode* node = _prev; node; node = node->_prev ) {\r
+ for(const XMLNode* node = _prev; node; node = node->_prev) {\r
const XMLElement* element = node->ToElement();\r
- if ( element\r
- && (!name || XMLUtil::StringEqual( name, element->Name() ))) {\r
+ if (element\r
+ && (!name || XMLUtil::StringEqual(name, element->Name()))) {\r
return element;\r
}\r
}\r
}\r
\r
\r
-char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )\r
+char* XMLNode::ParseDeep(char* p, StrPair* parentEnd)\r
{\r
// This is a recursive method, but thinking about it "at the current level"\r
// it is a pretty simple flat list:\r
// 'endTag' is the end tag for this node, it is returned by a call to a child.\r
// 'parentEnd' is the end tag for the parent, which is filled in and returned.\r
\r
- while( p && *p ) {\r
+ while(p && *p) {\r
XMLNode* node = 0;\r
\r
- p = _document->Identify( p, &node );\r
- if ( node == 0 ) {\r
+ p = _document->Identify(p, &node);\r
+ if (node == 0) {\r
break;\r
}\r
\r
StrPair endTag;\r
- p = node->ParseDeep( p, &endTag );\r
- if ( !p ) {\r
- DeleteNode( node );\r
- if ( !_document->Error() ) {\r
- _document->SetError( XML_ERROR_PARSING, 0, 0 );\r
+ p = node->ParseDeep(p, &endTag);\r
+ if (!p) {\r
+ DeleteNode(node);\r
+ if (!_document->Error()) {\r
+ _document->SetError(XML_ERROR_PARSING, 0, 0);\r
}\r
break;\r
}\r
\r
XMLDeclaration* decl = node->ToDeclaration();\r
- if ( decl ) {\r
+ if (decl) {\r
// A declaration can only be the first child of a document.\r
// Set error, if document already has children.\r
- if ( !_document->NoChildren() ) {\r
- _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0);\r
- DeleteNode( decl );\r
+ if (!_document->NoChildren()) {\r
+ _document->SetError(XML_ERROR_PARSING_DECLARATION, decl->Value(), 0);\r
+ DeleteNode(decl);\r
break;\r
}\r
}\r
\r
XMLElement* ele = node->ToElement();\r
- if ( ele ) {\r
+ if (ele) {\r
// We read the end tag. Return it to the parent.\r
- if ( ele->ClosingType() == XMLElement::CLOSING ) {\r
- if ( parentEnd ) {\r
- ele->_value.TransferTo( parentEnd );\r
+ if (ele->ClosingType() == XMLElement::CLOSING) {\r
+ if (parentEnd) {\r
+ ele->_value.TransferTo(parentEnd);\r
}\r
node->_memPool->SetTracked(); // created and then immediately deleted.\r
- DeleteNode( node );\r
+ DeleteNode(node);\r
return p;\r
}\r
\r
// Handle an end tag returned to this level.\r
// And handle a bunch of annoying errors.\r
bool mismatch = false;\r
- if ( endTag.Empty() ) {\r
- if ( ele->ClosingType() == XMLElement::OPEN ) {\r
+ if (endTag.Empty()) {\r
+ if (ele->ClosingType() == XMLElement::OPEN) {\r
mismatch = true;\r
}\r
}\r
else {\r
- if ( ele->ClosingType() != XMLElement::OPEN ) {\r
+ if (ele->ClosingType() != XMLElement::OPEN) {\r
mismatch = true;\r
}\r
- else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) {\r
+ else if (!XMLUtil::StringEqual(endTag.GetStr(), ele->Name())) {\r
mismatch = true;\r
}\r
}\r
- if ( mismatch ) {\r
- _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0 );\r
- DeleteNode( node );\r
+ if (mismatch) {\r
+ _document->SetError(XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0);\r
+ DeleteNode(node);\r
break;\r
}\r
}\r
- InsertEndChild( node );\r
+ InsertEndChild(node);\r
}\r
return 0;\r
}\r
\r
-void XMLNode::DeleteNode( XMLNode* node )\r
+void XMLNode::DeleteNode(XMLNode* node)\r
{\r
- if ( node == 0 ) {\r
+ if (node == 0) {\r
return;\r
}\r
MemPool* pool = node->_memPool;\r
node->~XMLNode();\r
- pool->Free( node );\r
+ pool->Free(node);\r
}\r
\r
-void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const\r
+void XMLNode::InsertChildPreamble(XMLNode* insertThis) const\r
{\r
- TIXMLASSERT( insertThis );\r
- TIXMLASSERT( insertThis->_document == _document );\r
+ TIXMLASSERT(insertThis);\r
+ TIXMLASSERT(insertThis->_document == _document);\r
\r
- if ( insertThis->_parent )\r
- insertThis->_parent->Unlink( insertThis );\r
+ if (insertThis->_parent)\r
+ insertThis->_parent->Unlink(insertThis);\r
else\r
insertThis->_memPool->SetTracked();\r
}\r
\r
// --------- XMLText ---------- //\r
-char* XMLText::ParseDeep( char* p, StrPair* )\r
+char* XMLText::ParseDeep(char* p, StrPair*)\r
{\r
const char* start = p;\r
- if ( this->CData() ) {\r
- p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION );\r
- if ( !p ) {\r
- _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 );\r
+ if (this->CData()) {\r
+ p = _value.ParseText(p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION);\r
+ if (!p) {\r
+ _document->SetError(XML_ERROR_PARSING_CDATA, start, 0);\r
}\r
return p;\r
}\r
else {\r
int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES;\r
- if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) {\r
+ if (_document->WhitespaceMode() == COLLAPSE_WHITESPACE) {\r
flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING;\r
}\r
\r
- p = _value.ParseText( p, "<", flags );\r
- if ( p && *p ) {\r
+ p = _value.ParseText(p, "<", flags);\r
+ if (p && *p) {\r
return p-1;\r
}\r
- if ( !p ) {\r
- _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 );\r
+ if (!p) {\r
+ _document->SetError(XML_ERROR_PARSING_TEXT, start, 0);\r
}\r
}\r
return 0;\r
}\r
\r
\r
-XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const\r
+XMLNode* XMLText::ShallowClone(XMLDocument* doc) const\r
{\r
- if ( !doc ) {\r
+ if (!doc) {\r
doc = _document;\r
}\r
- XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern?\r
- text->SetCData( this->CData() );\r
+ XMLText* text = doc->NewText(Value()); // fixme: this will always allocate memory. Intern?\r
+ text->SetCData(this->CData());\r
return text;\r
}\r
\r
\r
-bool XMLText::ShallowEqual( const XMLNode* compare ) const\r
+bool XMLText::ShallowEqual(const XMLNode* compare) const\r
{\r
const XMLText* text = compare->ToText();\r
- return ( text && XMLUtil::StringEqual( text->Value(), Value() ) );\r
+ return (text && XMLUtil::StringEqual(text->Value(), Value()));\r
}\r
\r
\r
-bool XMLText::Accept( XMLVisitor* visitor ) const\r
+bool XMLText::Accept(XMLVisitor* visitor) const\r
{\r
- TIXMLASSERT( visitor );\r
- return visitor->Visit( *this );\r
+ TIXMLASSERT(visitor);\r
+ return visitor->Visit(*this);\r
}\r
\r
\r
// --------- XMLComment ---------- //\r
\r
-XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc )\r
+XMLComment::XMLComment(XMLDocument* doc) : XMLNode(doc)\r
{\r
}\r
\r
}\r
\r
\r
-char* XMLComment::ParseDeep( char* p, StrPair* )\r
+char* XMLComment::ParseDeep(char* p, StrPair*)\r
{\r
// Comment parses as text.\r
const char* start = p;\r
- p = _value.ParseText( p, "-->", StrPair::COMMENT );\r
- if ( p == 0 ) {\r
- _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 );\r
+ p = _value.ParseText(p, "-->", StrPair::COMMENT);\r
+ if (p == 0) {\r
+ _document->SetError(XML_ERROR_PARSING_COMMENT, start, 0);\r
}\r
return p;\r
}\r
\r
\r
-XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const\r
+XMLNode* XMLComment::ShallowClone(XMLDocument* doc) const\r
{\r
- if ( !doc ) {\r
+ if (!doc) {\r
doc = _document;\r
}\r
- XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern?\r
+ XMLComment* comment = doc->NewComment(Value()); // fixme: this will always allocate memory. Intern?\r
return comment;\r
}\r
\r
\r
-bool XMLComment::ShallowEqual( const XMLNode* compare ) const\r
+bool XMLComment::ShallowEqual(const XMLNode* compare) const\r
{\r
- TIXMLASSERT( compare );\r
+ TIXMLASSERT(compare);\r
const XMLComment* comment = compare->ToComment();\r
- return ( comment && XMLUtil::StringEqual( comment->Value(), Value() ));\r
+ return (comment && XMLUtil::StringEqual(comment->Value(), Value()));\r
}\r
\r
\r
-bool XMLComment::Accept( XMLVisitor* visitor ) const\r
+bool XMLComment::Accept(XMLVisitor* visitor) const\r
{\r
- TIXMLASSERT( visitor );\r
- return visitor->Visit( *this );\r
+ TIXMLASSERT(visitor);\r
+ return visitor->Visit(*this);\r
}\r
\r
\r
// --------- XMLDeclaration ---------- //\r
\r
-XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc )\r
+XMLDeclaration::XMLDeclaration(XMLDocument* doc) : XMLNode(doc)\r
{\r
}\r
\r
\r
XMLDeclaration::~XMLDeclaration()\r
{\r
- //printf( "~XMLDeclaration\n" );\r
+ //printf("~XMLDeclaration\n");\r
}\r
\r
\r
-char* XMLDeclaration::ParseDeep( char* p, StrPair* )\r
+char* XMLDeclaration::ParseDeep(char* p, StrPair*)\r
{\r
// Declaration parses as text.\r
const char* start = p;\r
- p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION );\r
- if ( p == 0 ) {\r
- _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 );\r
+ p = _value.ParseText(p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION);\r
+ if (p == 0) {\r
+ _document->SetError(XML_ERROR_PARSING_DECLARATION, start, 0);\r
}\r
return p;\r
}\r
\r
\r
-XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const\r
+XMLNode* XMLDeclaration::ShallowClone(XMLDocument* doc) const\r
{\r
- if ( !doc ) {\r
+ if (!doc) {\r
doc = _document;\r
}\r
- XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern?\r
+ XMLDeclaration* dec = doc->NewDeclaration(Value()); // fixme: this will always allocate memory. Intern?\r
return dec;\r
}\r
\r
\r
-bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const\r
+bool XMLDeclaration::ShallowEqual(const XMLNode* compare) const\r
{\r
- TIXMLASSERT( compare );\r
+ TIXMLASSERT(compare);\r
const XMLDeclaration* declaration = compare->ToDeclaration();\r
- return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() ));\r
+ return (declaration && XMLUtil::StringEqual(declaration->Value(), Value()));\r
}\r
\r
\r
\r
-bool XMLDeclaration::Accept( XMLVisitor* visitor ) const\r
+bool XMLDeclaration::Accept(XMLVisitor* visitor) const\r
{\r
- TIXMLASSERT( visitor );\r
- return visitor->Visit( *this );\r
+ TIXMLASSERT(visitor);\r
+ return visitor->Visit(*this);\r
}\r
\r
// --------- XMLUnknown ---------- //\r
\r
-XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc )\r
+XMLUnknown::XMLUnknown(XMLDocument* doc) : XMLNode(doc)\r
{\r
}\r
\r
}\r
\r
\r
-char* XMLUnknown::ParseDeep( char* p, StrPair* )\r
+char* XMLUnknown::ParseDeep(char* p, StrPair*)\r
{\r
// Unknown parses as text.\r
const char* start = p;\r
\r
- p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION );\r
- if ( !p ) {\r
- _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 );\r
+ p = _value.ParseText(p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION);\r
+ if (!p) {\r
+ _document->SetError(XML_ERROR_PARSING_UNKNOWN, start, 0);\r
}\r
return p;\r
}\r
\r
\r
-XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const\r
+XMLNode* XMLUnknown::ShallowClone(XMLDocument* doc) const\r
{\r
- if ( !doc ) {\r
+ if (!doc) {\r
doc = _document;\r
}\r
- XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern?\r
+ XMLUnknown* text = doc->NewUnknown(Value()); // fixme: this will always allocate memory. Intern?\r
return text;\r
}\r
\r
\r
-bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const\r
+bool XMLUnknown::ShallowEqual(const XMLNode* compare) const\r
{\r
- TIXMLASSERT( compare );\r
+ TIXMLASSERT(compare);\r
const XMLUnknown* unknown = compare->ToUnknown();\r
- return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() ));\r
+ return (unknown && XMLUtil::StringEqual(unknown->Value(), Value()));\r
}\r
\r
\r
-bool XMLUnknown::Accept( XMLVisitor* visitor ) const\r
+bool XMLUnknown::Accept(XMLVisitor* visitor) const\r
{\r
- TIXMLASSERT( visitor );\r
- return visitor->Visit( *this );\r
+ TIXMLASSERT(visitor);\r
+ return visitor->Visit(*this);\r
}\r
\r
// --------- XMLAttribute ---------- //\r
return _value.GetStr();\r
}\r
\r
-char* XMLAttribute::ParseDeep( char* p, bool processEntities )\r
+char* XMLAttribute::ParseDeep(char* p, bool processEntities)\r
{\r
// Parse using the name rules: bug fix, was using ParseText before\r
- p = _name.ParseName( p );\r
- if ( !p || !*p ) {\r
+ p = _name.ParseName(p);\r
+ if (!p || !*p) {\r
return 0;\r
}\r
\r
// Skip white space before =\r
- p = XMLUtil::SkipWhiteSpace( p );\r
- if ( *p != '=' ) {\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
+ if (*p != '=') {\r
return 0;\r
}\r
\r
++p; // move up to opening quote\r
- p = XMLUtil::SkipWhiteSpace( p );\r
- if ( *p != '\"' && *p != '\'' ) {\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
+ if (*p != '\"' && *p != '\'') {\r
return 0;\r
}\r
\r
char endTag[2] = { *p, 0 };\r
++p; // move past opening quote\r
\r
- p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES );\r
+ p = _value.ParseText(p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES);\r
return p;\r
}\r
\r
\r
-void XMLAttribute::SetName( const char* n )\r
+void XMLAttribute::SetName(const char* n)\r
{\r
- _name.SetStr( n );\r
+ _name.SetStr(n);\r
}\r
\r
\r
-XMLError XMLAttribute::QueryIntValue( int* value ) const\r
+XMLError XMLAttribute::QueryIntValue(int* value) const\r
{\r
- if ( XMLUtil::ToInt( Value(), value )) {\r
+ if (XMLUtil::ToInt(Value(), value)) {\r
return XML_NO_ERROR;\r
}\r
return XML_WRONG_ATTRIBUTE_TYPE;\r
}\r
\r
\r
-XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const\r
+XMLError XMLAttribute::QueryUnsignedValue(unsigned int* value) const\r
{\r
- if ( XMLUtil::ToUnsigned( Value(), value )) {\r
+ if (XMLUtil::ToUnsigned(Value(), value)) {\r
return XML_NO_ERROR;\r
}\r
return XML_WRONG_ATTRIBUTE_TYPE;\r
}\r
\r
\r
-XMLError XMLAttribute::QueryBoolValue( bool* value ) const\r
+XMLError XMLAttribute::QueryBoolValue(bool* value) const\r
{\r
- if ( XMLUtil::ToBool( Value(), value )) {\r
+ if (XMLUtil::ToBool(Value(), value)) {\r
return XML_NO_ERROR;\r
}\r
return XML_WRONG_ATTRIBUTE_TYPE;\r
}\r
\r
\r
-XMLError XMLAttribute::QueryFloatValue( float* value ) const\r
+XMLError XMLAttribute::QueryFloatValue(float* value) const\r
{\r
- if ( XMLUtil::ToFloat( Value(), value )) {\r
+ if (XMLUtil::ToFloat(Value(), value)) {\r
return XML_NO_ERROR;\r
}\r
return XML_WRONG_ATTRIBUTE_TYPE;\r
}\r
\r
\r
-XMLError XMLAttribute::QueryDoubleValue( double* value ) const\r
+XMLError XMLAttribute::QueryDoubleValue(double* value) const\r
{\r
- if ( XMLUtil::ToDouble( Value(), value )) {\r
+ if (XMLUtil::ToDouble(Value(), value)) {\r
return XML_NO_ERROR;\r
}\r
return XML_WRONG_ATTRIBUTE_TYPE;\r
}\r
\r
\r
-void XMLAttribute::SetAttribute( const char* v )\r
+void XMLAttribute::SetAttribute(const char* v)\r
{\r
- _value.SetStr( v );\r
+ _value.SetStr(v);\r
}\r
\r
\r
-void XMLAttribute::SetAttribute( int v )\r
+void XMLAttribute::SetAttribute(int v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- _value.SetStr( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ _value.SetStr(buf);\r
}\r
\r
\r
-void XMLAttribute::SetAttribute( unsigned v )\r
+void XMLAttribute::SetAttribute(unsigned v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- _value.SetStr( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ _value.SetStr(buf);\r
}\r
\r
\r
-void XMLAttribute::SetAttribute( bool v )\r
+void XMLAttribute::SetAttribute(bool v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- _value.SetStr( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ _value.SetStr(buf);\r
}\r
\r
-void XMLAttribute::SetAttribute( double v )\r
+void XMLAttribute::SetAttribute(double v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- _value.SetStr( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ _value.SetStr(buf);\r
}\r
\r
-void XMLAttribute::SetAttribute( float v )\r
+void XMLAttribute::SetAttribute(float v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- _value.SetStr( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ _value.SetStr(buf);\r
}\r
\r
\r
// --------- XMLElement ---------- //\r
-XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),\r
- _closingType( 0 ),\r
- _rootAttribute( 0 )\r
+XMLElement::XMLElement(XMLDocument* doc) : XMLNode(doc),\r
+ _closingType(0),\r
+ _rootAttribute(0)\r
{\r
}\r
\r
\r
XMLElement::~XMLElement()\r
{\r
- while( _rootAttribute ) {\r
+ while(_rootAttribute) {\r
XMLAttribute* next = _rootAttribute->_next;\r
- DeleteAttribute( _rootAttribute );\r
+ DeleteAttribute(_rootAttribute);\r
_rootAttribute = next;\r
}\r
}\r
\r
\r
-const XMLAttribute* XMLElement::FindAttribute( const char* name ) const\r
+const XMLAttribute* XMLElement::FindAttribute(const char* name) const\r
{\r
- for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) {\r
- if ( XMLUtil::StringEqual( a->Name(), name ) ) {\r
+ for(XMLAttribute* a = _rootAttribute; a; a = a->_next) {\r
+ if (XMLUtil::StringEqual(a->Name(), name)) {\r
return a;\r
}\r
}\r
return 0;\r
}\r
\r
-std::string XMLElement::StrAttribute( const char* name, const char* value ) const\r
+std::string XMLElement::StrAttribute(const char* name, const char* value) const\r
{\r
std::string str;\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( a ) {\r
- if ( !value || XMLUtil::StringEqual( a->Value(), value )) {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (a) {\r
+ if (!value || XMLUtil::StringEqual(a->Value(), value)) {\r
str = a->Value();\r
return str;\r
}\r
return str;\r
}\r
\r
-const char* XMLElement::Attribute( const char* name, const char* value ) const\r
+const char* XMLElement::Attribute(const char* name, const char* value) const\r
{\r
- const XMLAttribute* a = FindAttribute( name );\r
- if ( !a ) {\r
+ const XMLAttribute* a = FindAttribute(name);\r
+ if (!a) {\r
return 0;\r
}\r
- if ( !value || XMLUtil::StringEqual( a->Value(), value )) {\r
+ if (!value || XMLUtil::StringEqual(a->Value(), value)) {\r
return a->Value();\r
}\r
return 0;\r
\r
const char* XMLElement::GetText() const\r
{\r
- if ( FirstChild() && FirstChild()->ToText() ) {\r
+ if (FirstChild() && FirstChild()->ToText()) {\r
return FirstChild()->Value();\r
}\r
return 0;\r
}\r
\r
\r
-void XMLElement::SetText( const char* inText )\r
+void XMLElement::SetText(const char* inText)\r
{\r
- if ( FirstChild() && FirstChild()->ToText() )\r
- FirstChild()->SetValue( inText );\r
+ if (FirstChild() && FirstChild()->ToText())\r
+ FirstChild()->SetValue(inText);\r
else {\r
- XMLText* theText = GetDocument()->NewText( inText );\r
- InsertFirstChild( theText );\r
+ XMLText* theText = GetDocument()->NewText(inText);\r
+ InsertFirstChild(theText);\r
}\r
}\r
\r
\r
-void XMLElement::SetText( int v ) \r
+void XMLElement::SetText(int v) \r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- SetText( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ SetText(buf);\r
}\r
\r
\r
-void XMLElement::SetText( unsigned v ) \r
+void XMLElement::SetText(unsigned v) \r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- SetText( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ SetText(buf);\r
}\r
\r
\r
-void XMLElement::SetText( bool v ) \r
+void XMLElement::SetText(bool v) \r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- SetText( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ SetText(buf);\r
}\r
\r
\r
-void XMLElement::SetText( float v ) \r
+void XMLElement::SetText(float v) \r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- SetText( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ SetText(buf);\r
}\r
\r
\r
-void XMLElement::SetText( double v ) \r
+void XMLElement::SetText(double v) \r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- SetText( buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ SetText(buf);\r
}\r
\r
\r
-XMLError XMLElement::QueryIntText( int* ival ) const\r
+XMLError XMLElement::QueryIntText(int* ival) const\r
{\r
- if ( FirstChild() && FirstChild()->ToText() ) {\r
+ if (FirstChild() && FirstChild()->ToText()) {\r
const char* t = FirstChild()->Value();\r
- if ( XMLUtil::ToInt( t, ival ) ) {\r
+ if (XMLUtil::ToInt(t, ival)) {\r
return XML_SUCCESS;\r
}\r
return XML_CAN_NOT_CONVERT_TEXT;\r
}\r
\r
\r
-XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const\r
+XMLError XMLElement::QueryUnsignedText(unsigned* uval) const\r
{\r
- if ( FirstChild() && FirstChild()->ToText() ) {\r
+ if (FirstChild() && FirstChild()->ToText()) {\r
const char* t = FirstChild()->Value();\r
- if ( XMLUtil::ToUnsigned( t, uval ) ) {\r
+ if (XMLUtil::ToUnsigned(t, uval)) {\r
return XML_SUCCESS;\r
}\r
return XML_CAN_NOT_CONVERT_TEXT;\r
}\r
\r
\r
-XMLError XMLElement::QueryBoolText( bool* bval ) const\r
+XMLError XMLElement::QueryBoolText(bool* bval) const\r
{\r
- if ( FirstChild() && FirstChild()->ToText() ) {\r
+ if (FirstChild() && FirstChild()->ToText()) {\r
const char* t = FirstChild()->Value();\r
- if ( XMLUtil::ToBool( t, bval ) ) {\r
+ if (XMLUtil::ToBool(t, bval)) {\r
return XML_SUCCESS;\r
}\r
return XML_CAN_NOT_CONVERT_TEXT;\r
}\r
\r
\r
-XMLError XMLElement::QueryDoubleText( double* dval ) const\r
+XMLError XMLElement::QueryDoubleText(double* dval) const\r
{\r
- if ( FirstChild() && FirstChild()->ToText() ) {\r
+ if (FirstChild() && FirstChild()->ToText()) {\r
const char* t = FirstChild()->Value();\r
- if ( XMLUtil::ToDouble( t, dval ) ) {\r
+ if (XMLUtil::ToDouble(t, dval)) {\r
return XML_SUCCESS;\r
}\r
return XML_CAN_NOT_CONVERT_TEXT;\r
}\r
\r
\r
-XMLError XMLElement::QueryFloatText( float* fval ) const\r
+XMLError XMLElement::QueryFloatText(float* fval) const\r
{\r
- if ( FirstChild() && FirstChild()->ToText() ) {\r
+ if (FirstChild() && FirstChild()->ToText()) {\r
const char* t = FirstChild()->Value();\r
- if ( XMLUtil::ToFloat( t, fval ) ) {\r
+ if (XMLUtil::ToFloat(t, fval)) {\r
return XML_SUCCESS;\r
}\r
return XML_CAN_NOT_CONVERT_TEXT;\r
\r
\r
\r
-XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )\r
+XMLAttribute* XMLElement::FindOrCreateAttribute(const char* name)\r
{\r
XMLAttribute* last = 0;\r
XMLAttribute* attrib = 0;\r
- for( attrib = _rootAttribute;\r
+ for(attrib = _rootAttribute;\r
attrib;\r
- last = attrib, attrib = attrib->_next ) {\r
- if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {\r
+ last = attrib, attrib = attrib->_next) {\r
+ if (XMLUtil::StringEqual(attrib->Name(), name)) {\r
break;\r
}\r
}\r
- if ( !attrib ) {\r
- TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );\r
- attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();\r
+ if (!attrib) {\r
+ TIXMLASSERT(sizeof(XMLAttribute) == _document->_attributePool.ItemSize());\r
+ attrib = new (_document->_attributePool.Alloc()) XMLAttribute();\r
attrib->_memPool = &_document->_attributePool;\r
- if ( last ) {\r
+ if (last) {\r
last->_next = attrib;\r
}\r
else {\r
_rootAttribute = attrib;\r
}\r
- attrib->SetName( name );\r
+ attrib->SetName(name);\r
attrib->_memPool->SetTracked(); // always created and linked.\r
}\r
return attrib;\r
}\r
\r
\r
-void XMLElement::DeleteAttribute( const char* name )\r
+void XMLElement::DeleteAttribute(const char* name)\r
{\r
XMLAttribute* prev = 0;\r
- for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) {\r
- if ( XMLUtil::StringEqual( name, a->Name() ) ) {\r
- if ( prev ) {\r
+ for(XMLAttribute* a=_rootAttribute; a; a=a->_next) {\r
+ if (XMLUtil::StringEqual(name, a->Name())) {\r
+ if (prev) {\r
prev->_next = a->_next;\r
}\r
else {\r
_rootAttribute = a->_next;\r
}\r
- DeleteAttribute( a );\r
+ DeleteAttribute(a);\r
break;\r
}\r
prev = a;\r
}\r
\r
\r
-char* XMLElement::ParseAttributes( char* p )\r
+char* XMLElement::ParseAttributes(char* p)\r
{\r
const char* start = p;\r
XMLAttribute* prevAttribute = 0;\r
\r
// Read the attributes.\r
- while( p ) {\r
- p = XMLUtil::SkipWhiteSpace( p );\r
- if ( !(*p) ) {\r
- _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );\r
+ while(p) {\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
+ if (!(*p)) {\r
+ _document->SetError(XML_ERROR_PARSING_ELEMENT, start, Name());\r
return 0;\r
}\r
\r
// attribute.\r
- if (XMLUtil::IsNameStartChar( *p ) ) {\r
- TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );\r
- XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();\r
+ if (XMLUtil::IsNameStartChar(*p)) {\r
+ TIXMLASSERT(sizeof(XMLAttribute) == _document->_attributePool.ItemSize());\r
+ XMLAttribute* attrib = new (_document->_attributePool.Alloc()) XMLAttribute();\r
attrib->_memPool = &_document->_attributePool;\r
attrib->_memPool->SetTracked();\r
\r
- p = attrib->ParseDeep( p, _document->ProcessEntities() );\r
- if ( !p || Attribute( attrib->Name() ) ) {\r
- DeleteAttribute( attrib );\r
- _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );\r
+ p = attrib->ParseDeep(p, _document->ProcessEntities());\r
+ if (!p || Attribute(attrib->Name())) {\r
+ DeleteAttribute(attrib);\r
+ _document->SetError(XML_ERROR_PARSING_ATTRIBUTE, start, p);\r
return 0;\r
}\r
// There is a minor bug here: if the attribute in the source xml\r
// attribute will be doubly added. However, tracking the 'prevAttribute'\r
// avoids re-scanning the attribute list. Preferring performance for\r
// now, may reconsider in the future.\r
- if ( prevAttribute ) {\r
+ if (prevAttribute) {\r
prevAttribute->_next = attrib;\r
}\r
else {\r
prevAttribute = attrib;\r
}\r
// end of the tag\r
- else if ( *p == '>' ) {\r
+ else if (*p == '>') {\r
++p;\r
break;\r
}\r
// end of the tag\r
- else if ( *p == '/' && *(p+1) == '>' ) {\r
+ else if (*p == '/' && *(p+1) == '>') {\r
_closingType = CLOSED;\r
return p+2; // done; sealed element.\r
}\r
else {\r
- _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );\r
+ _document->SetError(XML_ERROR_PARSING_ELEMENT, start, p);\r
return 0;\r
}\r
}\r
return p;\r
}\r
\r
-void XMLElement::DeleteAttribute( XMLAttribute* attribute )\r
+void XMLElement::DeleteAttribute(XMLAttribute* attribute)\r
{\r
- if ( attribute == 0 ) {\r
+ if (attribute == 0) {\r
return;\r
}\r
MemPool* pool = attribute->_memPool;\r
attribute->~XMLAttribute();\r
- pool->Free( attribute );\r
+ pool->Free(attribute);\r
}\r
\r
//\r
// <ele></ele>\r
// <ele>foo<b>bar</b></ele>\r
//\r
-char* XMLElement::ParseDeep( char* p, StrPair* strPair )\r
+char* XMLElement::ParseDeep(char* p, StrPair* strPair)\r
{\r
// Read the element name.\r
- p = XMLUtil::SkipWhiteSpace( p );\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
\r
// The closing element is the </element> form. It is\r
// parsed just like a regular element then deleted from\r
// the DOM.\r
- if ( *p == '/' ) {\r
+ if (*p == '/') {\r
_closingType = CLOSING;\r
++p;\r
}\r
\r
- p = _value.ParseName( p );\r
- if ( _value.Empty() ) {\r
+ p = _value.ParseName(p);\r
+ if (_value.Empty()) {\r
return 0;\r
}\r
\r
- p = ParseAttributes( p );\r
- if ( !p || !*p || _closingType ) {\r
+ p = ParseAttributes(p);\r
+ if (!p || !*p || _closingType) {\r
return p;\r
}\r
\r
- p = XMLNode::ParseDeep( p, strPair );\r
+ p = XMLNode::ParseDeep(p, strPair);\r
return p;\r
}\r
\r
\r
\r
-XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const\r
+XMLNode* XMLElement::ShallowClone(XMLDocument* doc) const\r
{\r
- if ( !doc ) {\r
+ if (!doc) {\r
doc = _document;\r
}\r
- XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern?\r
- for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) {\r
- element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern?\r
+ XMLElement* element = doc->NewElement(Value()); // fixme: this will always allocate memory. Intern?\r
+ for(const XMLAttribute* a=FirstAttribute(); a; a=a->Next()) {\r
+ element->SetAttribute(a->Name(), a->Value()); // fixme: this will always allocate memory. Intern?\r
}\r
return element;\r
}\r
\r
\r
-bool XMLElement::ShallowEqual( const XMLNode* compare ) const\r
+bool XMLElement::ShallowEqual(const XMLNode* compare) const\r
{\r
- TIXMLASSERT( compare );\r
+ TIXMLASSERT(compare);\r
const XMLElement* other = compare->ToElement();\r
- if ( other && XMLUtil::StringEqual( other->Name(), Name() )) {\r
+ if (other && XMLUtil::StringEqual(other->Name(), Name())) {\r
\r
const XMLAttribute* a=FirstAttribute();\r
const XMLAttribute* b=other->FirstAttribute();\r
\r
- while ( a && b ) {\r
- if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) {\r
+ while (a && b) {\r
+ if (!XMLUtil::StringEqual(a->Value(), b->Value())) {\r
return false;\r
}\r
a = a->Next();\r
b = b->Next();\r
}\r
- if ( a || b ) {\r
+ if (a || b) {\r
// different count\r
return false;\r
}\r
}\r
\r
\r
-bool XMLElement::Accept( XMLVisitor* visitor ) const\r
+bool XMLElement::Accept(XMLVisitor* visitor) const\r
{\r
- TIXMLASSERT( visitor );\r
- if ( visitor->VisitEnter( *this, _rootAttribute ) ) {\r
- for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) {\r
- if ( !node->Accept( visitor ) ) {\r
+ TIXMLASSERT(visitor);\r
+ if (visitor->VisitEnter(*this, _rootAttribute)) {\r
+ for (const XMLNode* node=FirstChild(); node; node=node->NextSibling()) {\r
+ if (!node->Accept(visitor)) {\r
break;\r
}\r
}\r
}\r
- return visitor->VisitExit( *this );\r
+ return visitor->VisitExit(*this);\r
}\r
\r
\r
};\r
\r
\r
-XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) :\r
- XMLNode( 0 ),\r
- _writeBOM( false ),\r
- _processEntities( processEntities ),\r
- _errorID( XML_NO_ERROR ),\r
- _whitespace( whitespace ),\r
- _errorStr1( 0 ),\r
- _errorStr2( 0 ),\r
- _charBuffer( 0 )\r
+XMLDocument::XMLDocument(bool processEntities, Whitespace whitespace) :\r
+ XMLNode(0),\r
+ _writeBOM(false),\r
+ _processEntities(processEntities),\r
+ _errorID(XML_NO_ERROR),\r
+ _whitespace(whitespace),\r
+ _errorStr1(0),\r
+ _errorStr2(0),\r
+ _charBuffer(0)\r
{\r
// avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+)\r
_document = this;\r
_charBuffer = 0;\r
\r
#if 0\r
- _textPool.Trace( "text" );\r
- _elementPool.Trace( "element" );\r
- _commentPool.Trace( "comment" );\r
- _attributePool.Trace( "attribute" );\r
+ _textPool.Trace("text");\r
+ _elementPool.Trace("element");\r
+ _commentPool.Trace("comment");\r
+ _attributePool.Trace("attribute");\r
#endif\r
\r
#ifdef DEBUG\r
- if ( !hadError ) {\r
- TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );\r
- TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );\r
- TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() );\r
- TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() );\r
+ if (!hadError) {\r
+ TIXMLASSERT(_elementPool.CurrentAllocs() == _elementPool.Untracked());\r
+ TIXMLASSERT(_attributePool.CurrentAllocs() == _attributePool.Untracked());\r
+ TIXMLASSERT(_textPool.CurrentAllocs() == _textPool.Untracked());\r
+ TIXMLASSERT(_commentPool.CurrentAllocs() == _commentPool.Untracked());\r
}\r
#endif\r
}\r
\r
\r
-XMLElement* XMLDocument::NewElement( const char* name )\r
+XMLElement* XMLDocument::NewElement(const char* name)\r
{\r
- TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() );\r
- XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this );\r
+ TIXMLASSERT(sizeof(XMLElement) == _elementPool.ItemSize());\r
+ XMLElement* ele = new (_elementPool.Alloc()) XMLElement(this);\r
ele->_memPool = &_elementPool;\r
- ele->SetName( name );\r
+ ele->SetName(name);\r
return ele;\r
}\r
\r
\r
-XMLComment* XMLDocument::NewComment( const char* str )\r
+XMLComment* XMLDocument::NewComment(const char* str)\r
{\r
- TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() );\r
- XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this );\r
+ TIXMLASSERT(sizeof(XMLComment) == _commentPool.ItemSize());\r
+ XMLComment* comment = new (_commentPool.Alloc()) XMLComment(this);\r
comment->_memPool = &_commentPool;\r
- comment->SetValue( str );\r
+ comment->SetValue(str);\r
return comment;\r
}\r
\r
\r
-XMLText* XMLDocument::NewText( const char* str )\r
+XMLText* XMLDocument::NewText(const char* str)\r
{\r
- TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() );\r
- XMLText* text = new (_textPool.Alloc()) XMLText( this );\r
+ TIXMLASSERT(sizeof(XMLText) == _textPool.ItemSize());\r
+ XMLText* text = new (_textPool.Alloc()) XMLText(this);\r
text->_memPool = &_textPool;\r
- text->SetValue( str );\r
+ text->SetValue(str);\r
return text;\r
}\r
\r
\r
-XMLDeclaration* XMLDocument::NewDeclaration( const char* str )\r
+XMLDeclaration* XMLDocument::NewDeclaration(const char* str)\r
{\r
- TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() );\r
- XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this );\r
+ TIXMLASSERT(sizeof(XMLDeclaration) == _commentPool.ItemSize());\r
+ XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration(this);\r
dec->_memPool = &_commentPool;\r
- dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" );\r
+ dec->SetValue(str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"");\r
return dec;\r
}\r
\r
\r
-XMLUnknown* XMLDocument::NewUnknown( const char* str )\r
+XMLUnknown* XMLDocument::NewUnknown(const char* str)\r
{\r
- TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() );\r
- XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this );\r
+ TIXMLASSERT(sizeof(XMLUnknown) == _commentPool.ItemSize());\r
+ XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown(this);\r
unk->_memPool = &_commentPool;\r
- unk->SetValue( str );\r
+ unk->SetValue(str);\r
return unk;\r
}\r
\r
-static FILE* callfopen( const char* filepath, const char* mode )\r
+static FILE* callfopen(const char* filepath, const char* mode)\r
{\r
- TIXMLASSERT( filepath );\r
- TIXMLASSERT( mode );\r
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)\r
+ TIXMLASSERT(filepath);\r
+ TIXMLASSERT(mode);\r
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && (!defined WINCE)\r
FILE* fp = 0;\r
- errno_t err = fopen_s( &fp, filepath, mode );\r
- if ( err ) {\r
+ errno_t err = fopen_s(&fp, filepath, mode);\r
+ if (err) {\r
return 0;\r
}\r
#else\r
- FILE* fp = fopen( filepath, mode );\r
+ FILE* fp = fopen(filepath, mode);\r
#endif\r
return fp;\r
}\r
\r
-void XMLDocument::DeleteNode( XMLNode* node ) {\r
- TIXMLASSERT( node );\r
- TIXMLASSERT(node->_document == this );\r
+void XMLDocument::DeleteNode(XMLNode* node) {\r
+ TIXMLASSERT(node);\r
+ TIXMLASSERT(node->_document == this);\r
if (node->_parent) {\r
- node->_parent->DeleteChild( node );\r
+ node->_parent->DeleteChild(node);\r
}\r
else {\r
// Isn't in the tree.\r
}\r
\r
\r
-XMLError XMLDocument::LoadFile( const char* filename )\r
+XMLError XMLDocument::LoadFile(const char* filename)\r
{\r
Clear();\r
- FILE* fp = callfopen( filename, "rb" );\r
- if ( !fp ) {\r
- SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 );\r
+ FILE* fp = callfopen(filename, "rb");\r
+ if (!fp) {\r
+ SetError(XML_ERROR_FILE_NOT_FOUND, filename, 0);\r
return _errorID;\r
}\r
- LoadFile( fp );\r
- fclose( fp );\r
+ LoadFile(fp);\r
+ fclose(fp);\r
return _errorID;\r
}\r
\r
template\r
<bool = (sizeof(unsigned long) >= sizeof(size_t))>\r
struct LongFitsIntoSizeTMinusOne {\r
- static bool Fits( unsigned long value )\r
+ static bool Fits(unsigned long value)\r
{\r
return value < (size_t)-1;\r
}\r
};\r
\r
template <>\r
-bool LongFitsIntoSizeTMinusOne<false>::Fits( unsigned long /*value*/ )\r
+bool LongFitsIntoSizeTMinusOne<false>::Fits(unsigned long /*value*/)\r
{\r
return true;\r
}\r
\r
-XMLError XMLDocument::LoadFile( FILE* fp )\r
+XMLError XMLDocument::LoadFile(FILE* fp)\r
{\r
Clear();\r
\r
- fseek( fp, 0, SEEK_SET );\r
- if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {\r
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r
+ fseek(fp, 0, SEEK_SET);\r
+ if (fgetc(fp) == EOF && ferror(fp) != 0) {\r
+ SetError(XML_ERROR_FILE_READ_ERROR, 0, 0);\r
return _errorID;\r
}\r
\r
- fseek( fp, 0, SEEK_END );\r
- const long filelength = ftell( fp );\r
- fseek( fp, 0, SEEK_SET );\r
- if ( filelength == -1L ) {\r
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r
+ fseek(fp, 0, SEEK_END);\r
+ const long filelength = ftell(fp);\r
+ fseek(fp, 0, SEEK_SET);\r
+ if (filelength == -1L) {\r
+ SetError(XML_ERROR_FILE_READ_ERROR, 0, 0);\r
return _errorID;\r
}\r
\r
- if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) {\r
+ if (!LongFitsIntoSizeTMinusOne<>::Fits(filelength)) {\r
// Cannot handle files which won't fit in buffer together with null terminator\r
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r
+ SetError(XML_ERROR_FILE_READ_ERROR, 0, 0);\r
return _errorID;\r
}\r
\r
- if ( filelength == 0 ) {\r
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );\r
+ if (filelength == 0) {\r
+ SetError(XML_ERROR_EMPTY_DOCUMENT, 0, 0);\r
return _errorID;\r
}\r
\r
const size_t size = filelength;\r
- TIXMLASSERT( _charBuffer == 0 );\r
+ TIXMLASSERT(_charBuffer == 0);\r
_charBuffer = new char[size+1];\r
- size_t read = fread( _charBuffer, 1, size, fp );\r
- if ( read != size ) {\r
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r
+ size_t read = fread(_charBuffer, 1, size, fp);\r
+ if (read != size) {\r
+ SetError(XML_ERROR_FILE_READ_ERROR, 0, 0);\r
return _errorID;\r
}\r
\r
}\r
\r
\r
-XMLError XMLDocument::SaveFile( const char* filename, bool compact )\r
+XMLError XMLDocument::SaveFile(const char* filename, bool compact)\r
{\r
- FILE* fp = callfopen( filename, "w" );\r
- if ( !fp ) {\r
- SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 );\r
+ FILE* fp = callfopen(filename, "w");\r
+ if (!fp) {\r
+ SetError(XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0);\r
return _errorID;\r
}\r
SaveFile(fp, compact);\r
- fclose( fp );\r
+ fclose(fp);\r
return _errorID;\r
}\r
\r
\r
-XMLError XMLDocument::SaveFile( FILE* fp, bool compact )\r
+XMLError XMLDocument::SaveFile(FILE* fp, bool compact)\r
{\r
// Clear any error from the last save, otherwise it will get reported\r
// for *this* call.\r
- SetError( XML_NO_ERROR, 0, 0 );\r
- XMLPrinter stream( fp, compact );\r
- Print( &stream );\r
+ SetError(XML_NO_ERROR, 0, 0);\r
+ XMLPrinter stream(fp, compact);\r
+ Print(&stream);\r
return _errorID;\r
}\r
\r
\r
-XMLError XMLDocument::Parse( const char* p, size_t len )\r
+XMLError XMLDocument::Parse(const char* p, size_t len)\r
{\r
Clear();\r
\r
- if ( len == 0 || !p || !*p ) {\r
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );\r
+ if (len == 0 || !p || !*p) {\r
+ SetError(XML_ERROR_EMPTY_DOCUMENT, 0, 0);\r
return _errorID;\r
}\r
- if ( len == (size_t)(-1) ) {\r
- len = strlen( p );\r
+ if (len == (size_t)(-1)) {\r
+ len = strlen(p);\r
}\r
- TIXMLASSERT( _charBuffer == 0 );\r
+ TIXMLASSERT(_charBuffer == 0);\r
_charBuffer = new char[ len+1 ];\r
- memcpy( _charBuffer, p, len );\r
+ memcpy(_charBuffer, p, len);\r
_charBuffer[len] = 0;\r
\r
Parse();\r
- if ( Error() ) {\r
+ if (Error()) {\r
// clean up now essentially dangling memory.\r
// and the parse fail can put objects in the\r
// pools that are dead and inaccessible.\r
}\r
\r
\r
-void XMLDocument::Print( XMLPrinter* streamer ) const\r
+void XMLDocument::Print(XMLPrinter* streamer) const\r
{\r
- if ( streamer ) {\r
- Accept( streamer );\r
+ if (streamer) {\r
+ Accept(streamer);\r
}\r
else {\r
- XMLPrinter stdoutStreamer( stdout );\r
- Accept( &stdoutStreamer );\r
+ XMLPrinter stdoutStreamer(stdout);\r
+ Accept(&stdoutStreamer);\r
}\r
}\r
\r
\r
-void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 )\r
+void XMLDocument::SetError(XMLError error, const char* str1, const char* str2)\r
{\r
- TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT );\r
+ TIXMLASSERT(error >= 0 && error < XML_ERROR_COUNT);\r
_errorID = error;\r
_errorStr1 = str1;\r
_errorStr2 = str2;\r
\r
const char* XMLDocument::ErrorName() const\r
{\r
- TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT );\r
+ TIXMLASSERT(_errorID >= 0 && _errorID < XML_ERROR_COUNT);\r
const char* errorName = _errorNames[_errorID];\r
- TIXMLASSERT( errorName && errorName[0] );\r
+ TIXMLASSERT(errorName && errorName[0]);\r
return errorName;\r
}\r
\r
void XMLDocument::PrintError() const\r
{\r
- if ( Error() ) {\r
+ if (Error()) {\r
static const int LEN = 20;\r
char buf1[LEN] = { 0 };\r
char buf2[LEN] = { 0 };\r
\r
- if ( _errorStr1 ) {\r
- TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 );\r
+ if (_errorStr1) {\r
+ TIXML_SNPRINTF(buf1, LEN, "%s", _errorStr1);\r
}\r
- if ( _errorStr2 ) {\r
- TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 );\r
+ if (_errorStr2) {\r
+ TIXML_SNPRINTF(buf2, LEN, "%s", _errorStr2);\r
}\r
\r
// Should check INT_MIN <= _errorID && _errorId <= INT_MAX, but that\r
// causes a clang "always true" -Wtautological-constant-out-of-range-compare warning\r
- TIXMLASSERT( 0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX );\r
- printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n",\r
- static_cast<int>( _errorID ), ErrorName(), buf1, buf2 );\r
+ TIXMLASSERT(0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX);\r
+ printf("XMLDocument error id=%d '%s' str1=%s str2=%s\n",\r
+ static_cast<int>(_errorID), ErrorName(), buf1, buf2);\r
}\r
}\r
\r
void XMLDocument::Parse()\r
{\r
- TIXMLASSERT( NoChildren() ); // Clear() must have been called previously\r
- TIXMLASSERT( _charBuffer );\r
+ TIXMLASSERT(NoChildren()); // Clear() must have been called previously\r
+ TIXMLASSERT(_charBuffer);\r
char* p = _charBuffer;\r
- p = XMLUtil::SkipWhiteSpace( p );\r
- p = const_cast<char*>( XMLUtil::ReadBOM( p, &_writeBOM ) );\r
- if ( !*p ) {\r
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );\r
+ p = XMLUtil::SkipWhiteSpace(p);\r
+ p = const_cast<char*>(XMLUtil::ReadBOM(p, &_writeBOM));\r
+ if (!*p) {\r
+ SetError(XML_ERROR_EMPTY_DOCUMENT, 0, 0);\r
return;\r
}\r
- ParseDeep(p, 0 );\r
+ ParseDeep(p, 0);\r
}\r
\r
-XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :\r
- _elementJustOpened( false ),\r
- _firstElement( true ),\r
- _fp( file ),\r
- _depth( depth ),\r
- _textDepth( -1 ),\r
- _processEntities( true ),\r
- _compactMode( compact )\r
+XMLPrinter::XMLPrinter(FILE* file, bool compact, int depth) :\r
+ _elementJustOpened(false),\r
+ _firstElement(true),\r
+ _fp(file),\r
+ _depth(depth),\r
+ _textDepth(-1),\r
+ _processEntities(true),\r
+ _compactMode(compact)\r
{\r
- for( int i=0; i<ENTITY_RANGE; ++i ) {\r
+ for(int i=0; i<ENTITY_RANGE; ++i) {\r
_entityFlag[i] = false;\r
_restrictedEntityFlag[i] = false;\r
}\r
- for( int i=0; i<NUM_ENTITIES; ++i ) {\r
+ for(int i=0; i<NUM_ENTITIES; ++i) {\r
const char entityValue = entities[i].value;\r
- TIXMLASSERT( 0 <= entityValue && entityValue < ENTITY_RANGE );\r
+ TIXMLASSERT(0 <= entityValue && entityValue < ENTITY_RANGE);\r
_entityFlag[ (unsigned char)entityValue ] = true;\r
}\r
_restrictedEntityFlag[(unsigned char)'&'] = true;\r
_restrictedEntityFlag[(unsigned char)'<'] = true;\r
_restrictedEntityFlag[(unsigned char)'>'] = true; // not required, but consistency is nice\r
- _buffer.Push( 0 );\r
+ _buffer.Push(0);\r
}\r
\r
\r
-void XMLPrinter::Print( const char* format, ... )\r
+void XMLPrinter::Print(const char* format, ...)\r
{\r
va_list va;\r
- va_start( va, format );\r
+ va_start(va, format);\r
\r
- if ( _fp ) {\r
- vfprintf( _fp, format, va );\r
+ if (_fp) {\r
+ vfprintf(_fp, format, va);\r
}\r
else {\r
- const int len = TIXML_VSCPRINTF( format, va );\r
+ const int len = TIXML_VSCPRINTF(format, va);\r
// Close out and re-start the va-args\r
- va_end( va );\r
- TIXMLASSERT( len >= 0 );\r
- va_start( va, format );\r
- TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 );\r
- char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.\r
- TIXML_VSNPRINTF( p, len+1, format, va );\r
+ va_end(va);\r
+ TIXMLASSERT(len >= 0);\r
+ va_start(va, format);\r
+ TIXMLASSERT(_buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0);\r
+ char* p = _buffer.PushArr(len) - 1; // back up over the null terminator.\r
+ TIXML_VSNPRINTF(p, len+1, format, va);\r
}\r
- va_end( va );\r
+ va_end(va);\r
}\r
\r
\r
-void XMLPrinter::PrintSpace( int depth )\r
+void XMLPrinter::PrintSpace(int depth)\r
{\r
- for( int i=0; i<depth; ++i ) {\r
- Print( " " );\r
+ for(int i=0; i<depth; ++i) {\r
+ Print(" ");\r
}\r
}\r
\r
\r
-void XMLPrinter::PrintString( const char* p, bool restricted )\r
+void XMLPrinter::PrintString(const char* p, bool restricted)\r
{\r
// Look for runs of bytes between entities to print.\r
const char* q = p;\r
\r
- if ( _processEntities ) {\r
+ if (_processEntities) {\r
const bool* flag = restricted ? _restrictedEntityFlag : _entityFlag;\r
- while ( *q ) {\r
- TIXMLASSERT( p <= q );\r
+ while (*q) {\r
+ TIXMLASSERT(p <= q);\r
// Remember, char is sometimes signed. (How many times has that bitten me?)\r
- if ( *q > 0 && *q < ENTITY_RANGE ) {\r
+ if (*q > 0 && *q < ENTITY_RANGE) {\r
// Check for entities. If one is found, flush\r
// the stream up until the entity, write the\r
// entity, and keep looking.\r
- if ( flag[(unsigned char)(*q)] ) {\r
- while ( p < q ) {\r
+ if (flag[(unsigned char)(*q)]) {\r
+ while (p < q) {\r
const size_t delta = q - p;\r
// %.*s accepts type int as "precision"\r
- const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;\r
- Print( "%.*s", toPrint, p );\r
+ const int toPrint = (INT_MAX < delta) ? INT_MAX : (int)delta;\r
+ Print("%.*s", toPrint, p);\r
p += toPrint;\r
}\r
bool entityPatternPrinted = false;\r
- for( int i=0; i<NUM_ENTITIES; ++i ) {\r
- if ( entities[i].value == *q ) {\r
- Print( "&%s;", entities[i].pattern );\r
+ for(int i=0; i<NUM_ENTITIES; ++i) {\r
+ if (entities[i].value == *q) {\r
+ Print("&%s;", entities[i].pattern);\r
entityPatternPrinted = true;\r
break;\r
}\r
}\r
- if ( !entityPatternPrinted ) {\r
- // TIXMLASSERT( entityPatternPrinted ) causes gcc -Wunused-but-set-variable in release\r
- TIXMLASSERT( false );\r
+ if (!entityPatternPrinted) {\r
+ // TIXMLASSERT(entityPatternPrinted) causes gcc -Wunused-but-set-variable in release\r
+ TIXMLASSERT(false);\r
}\r
++p;\r
}\r
}\r
++q;\r
- TIXMLASSERT( p <= q );\r
+ TIXMLASSERT(p <= q);\r
}\r
}\r
// Flush the remaining string. This will be the entire\r
// string if an entity wasn't found.\r
- TIXMLASSERT( p <= q );\r
- if ( !_processEntities || ( p < q ) ) {\r
- Print( "%s", p );\r
+ TIXMLASSERT(p <= q);\r
+ if (!_processEntities || (p < q)) {\r
+ Print("%s", p);\r
}\r
}\r
\r
\r
-void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )\r
+void XMLPrinter::PushHeader(bool writeBOM, bool writeDec)\r
{\r
- if ( writeBOM ) {\r
+ if (writeBOM) {\r
static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };\r
- Print( "%s", bom );\r
+ Print("%s", bom);\r
}\r
- if ( writeDec ) {\r
- PushDeclaration( "xml version=\"1.0\"" );\r
+ if (writeDec) {\r
+ PushDeclaration("xml version=\"1.0\"");\r
}\r
}\r
\r
\r
-void XMLPrinter::OpenElement( const char* name, bool compactMode )\r
+void XMLPrinter::OpenElement(const char* name, bool compactMode)\r
{\r
SealElementIfJustOpened();\r
- _stack.Push( name );\r
+ _stack.Push(name);\r
\r
- if ( _textDepth < 0 && !_firstElement && !compactMode ) {\r
- Print( "\n" );\r
+ if (_textDepth < 0 && !_firstElement && !compactMode) {\r
+ Print("\n");\r
}\r
- if ( !compactMode ) {\r
- PrintSpace( _depth );\r
+ if (!compactMode) {\r
+ PrintSpace(_depth);\r
}\r
\r
- Print( "<%s", name );\r
+ Print("<%s", name);\r
_elementJustOpened = true;\r
_firstElement = false;\r
++_depth;\r
}\r
\r
\r
-void XMLPrinter::PushAttribute( const char* name, const char* value )\r
+void XMLPrinter::PushAttribute(const char* name, const char* value)\r
{\r
- TIXMLASSERT( _elementJustOpened );\r
- Print( " %s=\"", name );\r
- PrintString( value, false );\r
- Print( "\"" );\r
+ TIXMLASSERT(_elementJustOpened);\r
+ Print(" %s=\"", name);\r
+ PrintString(value, false);\r
+ Print("\"");\r
}\r
\r
\r
-void XMLPrinter::PushAttribute( const char* name, int v )\r
+void XMLPrinter::PushAttribute(const char* name, int v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- PushAttribute( name, buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ PushAttribute(name, buf);\r
}\r
\r
\r
-void XMLPrinter::PushAttribute( const char* name, unsigned v )\r
+void XMLPrinter::PushAttribute(const char* name, unsigned v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- PushAttribute( name, buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ PushAttribute(name, buf);\r
}\r
\r
\r
-void XMLPrinter::PushAttribute( const char* name, bool v )\r
+void XMLPrinter::PushAttribute(const char* name, bool v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- PushAttribute( name, buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ PushAttribute(name, buf);\r
}\r
\r
\r
-void XMLPrinter::PushAttribute( const char* name, double v )\r
+void XMLPrinter::PushAttribute(const char* name, double v)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( v, buf, BUF_SIZE );\r
- PushAttribute( name, buf );\r
+ XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+ PushAttribute(name, buf);\r
}\r
\r
\r
-void XMLPrinter::CloseElement( bool compactMode )\r
+void XMLPrinter::CloseElement(bool compactMode)\r
{\r
--_depth;\r
const char* name = _stack.Pop();\r
\r
- if ( _elementJustOpened ) {\r
- Print( "/>" );\r
+ if (_elementJustOpened) {\r
+ Print("/>");\r
}\r
else {\r
- if ( _textDepth < 0 && !compactMode) {\r
- Print( "\n" );\r
- PrintSpace( _depth );\r
+ if (_textDepth < 0 && !compactMode) {\r
+ Print("\n");\r
+ PrintSpace(_depth);\r
}\r
- Print( "</%s>", name );\r
+ Print("</%s>", name);\r
}\r
\r
- if ( _textDepth == _depth ) {\r
+ if (_textDepth == _depth) {\r
_textDepth = -1;\r
}\r
- if ( _depth == 0 && !compactMode) {\r
- Print( "\n" );\r
+ if (_depth == 0 && !compactMode) {\r
+ Print("\n");\r
}\r
_elementJustOpened = false;\r
}\r
\r
void XMLPrinter::SealElementIfJustOpened()\r
{\r
- if ( !_elementJustOpened ) {\r
+ if (!_elementJustOpened) {\r
return;\r
}\r
_elementJustOpened = false;\r
- Print( ">" );\r
+ Print(">");\r
}\r
\r
\r
-void XMLPrinter::PushText( const char* text, bool cdata )\r
+void XMLPrinter::PushText(const char* text, bool cdata)\r
{\r
_textDepth = _depth-1;\r
\r
SealElementIfJustOpened();\r
- if ( cdata ) {\r
- Print( "<![CDATA[%s]]>", text );\r
+ if (cdata) {\r
+ Print("<![CDATA[%s]]>", text);\r
}\r
else {\r
- PrintString( text, true );\r
+ PrintString(text, true);\r
}\r
}\r
\r
-void XMLPrinter::PushText( int value )\r
+void XMLPrinter::PushText(int value)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( value, buf, BUF_SIZE );\r
- PushText( buf, false );\r
+ XMLUtil::ToStr(value, buf, BUF_SIZE);\r
+ PushText(buf, false);\r
}\r
\r
\r
-void XMLPrinter::PushText( unsigned value )\r
+void XMLPrinter::PushText(unsigned value)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( value, buf, BUF_SIZE );\r
- PushText( buf, false );\r
+ XMLUtil::ToStr(value, buf, BUF_SIZE);\r
+ PushText(buf, false);\r
}\r
\r
\r
-void XMLPrinter::PushText( bool value )\r
+void XMLPrinter::PushText(bool value)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( value, buf, BUF_SIZE );\r
- PushText( buf, false );\r
+ XMLUtil::ToStr(value, buf, BUF_SIZE);\r
+ PushText(buf, false);\r
}\r
\r
\r
-void XMLPrinter::PushText( float value )\r
+void XMLPrinter::PushText(float value)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( value, buf, BUF_SIZE );\r
- PushText( buf, false );\r
+ XMLUtil::ToStr(value, buf, BUF_SIZE);\r
+ PushText(buf, false);\r
}\r
\r
\r
-void XMLPrinter::PushText( double value )\r
+void XMLPrinter::PushText(double value)\r
{\r
char buf[BUF_SIZE];\r
- XMLUtil::ToStr( value, buf, BUF_SIZE );\r
- PushText( buf, false );\r
+ XMLUtil::ToStr(value, buf, BUF_SIZE);\r
+ PushText(buf, false);\r
}\r
\r
\r
-void XMLPrinter::PushComment( const char* comment )\r
+void XMLPrinter::PushComment(const char* comment)\r
{\r
SealElementIfJustOpened();\r
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {\r
- Print( "\n" );\r
- PrintSpace( _depth );\r
+ if (_textDepth < 0 && !_firstElement && !_compactMode) {\r
+ Print("\n");\r
+ PrintSpace(_depth);\r
}\r
_firstElement = false;\r
- Print( "<!--%s-->", comment );\r
+ Print("<!--%s-->", comment);\r
}\r
\r
\r
-void XMLPrinter::PushDeclaration( const char* value )\r
+void XMLPrinter::PushDeclaration(const char* value)\r
{\r
SealElementIfJustOpened();\r
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {\r
- Print( "\n" );\r
- PrintSpace( _depth );\r
+ if (_textDepth < 0 && !_firstElement && !_compactMode) {\r
+ Print("\n");\r
+ PrintSpace(_depth);\r
}\r
_firstElement = false;\r
- Print( "<?%s?>", value );\r
+ Print("<?%s?>", value);\r
}\r
\r
\r
-void XMLPrinter::PushUnknown( const char* value )\r
+void XMLPrinter::PushUnknown(const char* value)\r
{\r
SealElementIfJustOpened();\r
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {\r
- Print( "\n" );\r
- PrintSpace( _depth );\r
+ if (_textDepth < 0 && !_firstElement && !_compactMode) {\r
+ Print("\n");\r
+ PrintSpace(_depth);\r
}\r
_firstElement = false;\r
- Print( "<!%s>", value );\r
+ Print("<!%s>", value);\r
}\r
\r
\r
-bool XMLPrinter::VisitEnter( const XMLDocument& doc )\r
+bool XMLPrinter::VisitEnter(const XMLDocument& doc)\r
{\r
_processEntities = doc.ProcessEntities();\r
- if ( doc.HasBOM() ) {\r
- PushHeader( true, false );\r
+ if (doc.HasBOM()) {\r
+ PushHeader(true, false);\r
}\r
return true;\r
}\r
\r
\r
-bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )\r
+bool XMLPrinter::VisitEnter(const XMLElement& element, const XMLAttribute* attribute)\r
{\r
const XMLElement* parentElem = 0;\r
- if ( element.Parent() ) {\r
+ if (element.Parent()) {\r
parentElem = element.Parent()->ToElement();\r
}\r
- const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode;\r
- OpenElement( element.Name(), compactMode );\r
- while ( attribute ) {\r
- PushAttribute( attribute->Name(), attribute->Value() );\r
+ const bool compactMode = parentElem ? CompactMode(*parentElem) : _compactMode;\r
+ OpenElement(element.Name(), compactMode);\r
+ while (attribute) {\r
+ PushAttribute(attribute->Name(), attribute->Value());\r
attribute = attribute->Next();\r
}\r
return true;\r
}\r
\r
\r
-bool XMLPrinter::VisitExit( const XMLElement& element )\r
+bool XMLPrinter::VisitExit(const XMLElement& element)\r
{\r
- CloseElement( CompactMode(element) );\r
+ CloseElement(CompactMode(element));\r
return true;\r
}\r
\r
\r
-bool XMLPrinter::Visit( const XMLText& text )\r
+bool XMLPrinter::Visit(const XMLText& text)\r
{\r
- PushText( text.Value(), text.CData() );\r
+ PushText(text.Value(), text.CData());\r
return true;\r
}\r
\r
\r
-bool XMLPrinter::Visit( const XMLComment& comment )\r
+bool XMLPrinter::Visit(const XMLComment& comment)\r
{\r
- PushComment( comment.Value() );\r
+ PushComment(comment.Value());\r
return true;\r
}\r
\r
-bool XMLPrinter::Visit( const XMLDeclaration& declaration )\r
+bool XMLPrinter::Visit(const XMLDeclaration& declaration)\r
{\r
- PushDeclaration( declaration.Value() );\r
+ PushDeclaration(declaration.Value());\r
return true;\r
}\r
\r
\r
-bool XMLPrinter::Visit( const XMLUnknown& unknown )\r
+bool XMLPrinter::Visit(const XMLUnknown& unknown)\r
{\r
- PushUnknown( unknown.Value() );\r
+ PushUnknown(unknown.Value());\r
return true;\r
}\r
\r
extern Player *player;
extern World *currentWorld;
+extern World *currentWorldToLeft;
+extern World *currentWorldToRight;
extern WorldWeather weather;
/*
vec2 ad;
} FT_Info;
-static std::vector<FT_Info> ftdat16 ( 93, { { 0, 0 }, { 0, 0 }, { 0, 0 } } );
-static std::vector<GLuint> ftex16 ( 93, 0 );
+static std::vector<FT_Info> ftdat16 (93, { { 0, 0 }, { 0, 0 }, { 0, 0 } });
+static std::vector<GLuint> ftex16 (93, 0);
static bool ft16loaded = false;
-static std::vector<FT_Info> ftdat24 ( 93, { { 0, 0 }, { 0, 0 }, { 0, 0 } } );
-static std::vector<GLuint> ftex24 ( 93, 0 );
+static std::vector<FT_Info> ftdat24 (93, { { 0, 0 }, { 0, 0 }, { 0, 0 } });
+static std::vector<GLuint> ftex24 (93, 0);
static bool ft24loaded = false;
static auto *ftdat = &ftdat16;
static std::vector<std::pair<std::string,vec3>> dialogOptText;
static std::string dialogBoxText;
-static std::vector<vec3> merchArrowLoc ( 2, vec3 { 0, 0, 0 } );
+static std::vector<vec3> merchArrowLoc (2, vec3 { 0, 0, 0 });
static bool typeOutDone = true;
static bool typeOutSustain = false;
static GLuint pageTex = 0;
static bool pageTexReady = false;
-void loadFontSize( unsigned int size, std::vector<GLuint> &tex, std::vector<FT_Info> &dat )
+void loadFontSize(unsigned int size, std::vector<GLuint> &tex, std::vector<FT_Info> &dat)
{
FT_Set_Pixel_Sizes(ftf,0,size);
* Pre-render 'all' the characters.
*/
- glDeleteTextures( 93, tex.data() );
- glGenTextures( 93, tex.data() ); // Generate new texture name/locations?
+ glDeleteTextures(93, tex.data());
+ glGenTextures(93, tex.data()); // Generate new texture name/locations?
for(char i=33;i<126;i++){
* Load the character from the font family file.
*/
- if ( FT_Load_Char ( ftf, i, FT_LOAD_RENDER ) )
- UserError( "Error! Unsupported character " + i );
+ if (FT_Load_Char (ftf, i, FT_LOAD_RENDER))
+ UserError("Error! Unsupported character " + i);
/*
* Transfer the character's bitmap (?) to a texture for rendering.
glBindTexture(GL_TEXTURE_2D,tex[i-33]);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S ,GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T ,GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER ,GL_LINEAR );
- glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER ,GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER ,GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER ,GL_LINEAR );
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
/*
*/
- std::vector<uint32_t> buf ( ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows, 0xFFFFFFFF );
+ std::vector<uint32_t> buf (ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows, 0xFFFFFFFF);
- for( unsigned int j = buf.size(); j--; )
+ for(unsigned int j = buf.size(); j--;)
buf[j] ^= !ftf->glyph->bitmap.buffer[j] ? buf[j] : 0;
dat[i - 33].wh.x = ftf->glyph->bitmap.width;
dat[i - 33].ad.x = ftf->glyph->advance.x >> 6;
dat[i - 33].ad.y = ftf->glyph->advance.y >> 6;
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, ftf->glyph->bitmap.width, ftf->glyph->bitmap.rows,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.data() );
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ftf->glyph->bitmap.width, ftf->glyph->bitmap.rows,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.data());
}
}
*/
void initFonts(void){
- if ( FT_Init_FreeType(&ftl) )
+ if (FT_Init_FreeType(&ftl))
UserError("Couldn't initialize freetype.");
#ifdef DEBUG
*/
void setFontFace(const char *ttf){
- if ( FT_New_Face( ftl, ttf, 0, &ftf ) )
+ if (FT_New_Face(ftl, ttf, 0, &ftf))
UserError("Error! Couldn't open " + (std::string)ttf + ".");
#ifdef DEBUG
*/
void setFontSize(unsigned int size){
- if ( size == 16 ) {
- if( !ft16loaded ) {
- loadFontSize( fontSize = size, ftex16, ftdat16 );
+ if (size == 16) {
+ if(!ft16loaded) {
+ loadFontSize(fontSize = size, ftex16, ftdat16);
ft16loaded = true;
}
ftex = &ftex16;
ftdat = &ftdat16;
fontSize = 16;
- } else if ( size == 24 ) {
- if ( !ft24loaded ) {
- loadFontSize( fontSize = size, ftex24, ftdat24 );
+ } else if (size == 24) {
+ if (!ft24loaded) {
+ loadFontSize(fontSize = size, ftex24, ftdat24);
ft24loaded = true;
}
ftex = &ftex24;
* Draw a string at the specified coordinates.
*/
- float putString( const float x, const float y, std::string s ) {
+ float putString(const float x, const float y, std::string s) {
unsigned int i=0;
vec2 add, o = {x, y};
i++;
}
- switch ( s[i] ) {
+ switch (s[i]) {
case '\n':
o.y -= fontSize * 1.05f;
o.x = x;
o.x += fontSize / 2;
break;
default:
- add = putChar( floor(o.x), floor(o.y), s[i] );
+ add = putChar(floor(o.x), floor(o.y), s[i]);
o.x += add.x;
o.y += add.y;
break;
return o.x; // i.e. the string width
}
- float putStringCentered( const float x, const float y, std::string s ) {
+ float putStringCentered(const float x, const float y, std::string s) {
unsigned int i = 0;
float width = 0;
do {
- switch ( s[i] ) {
+ switch (s[i]) {
case '\n':
// TODO
break;
* Prevents typeOut from typing the next string it's given.
*/
- void dontTypeOut( void ) {
+ void dontTypeOut(void) {
typeOutSustain = true;
}
*/
std::string ret;
- std::string typeOut( std::string str ) {
+ std::string typeOut(std::string str) {
static unsigned int tadv = TICKS_PER_SEC / 12;
static unsigned int tickk,
linc=0, // Contains the number of letters that should be drawn.
size=0; // Contains the full size of the current string.
// reset values if a new string is being passed.
- if ( !linc || ret.substr( 0, linc ) != str.substr( 0, linc ) ) {
+ if (!linc || ret.substr(0, linc) != str.substr(0, linc)) {
tickk = tickCount + tadv;
- ret = str.substr( 0, 1 );
+ ret = str.substr(0, 1);
size = str.size(); // Set the new target string size
linc = 1; // Reset the incrementers
- if ( (typeOutDone = typeOutSustain) )
+ if ((typeOutDone = typeOutSustain))
typeOutSustain = false;
}
- if ( typeOutDone )
+ if (typeOutDone)
return str;
// Draw the next letter if necessary.
- else if ( tickk <= tickCount ) {
+ else if (tickk <= tickCount) {
tickk = tickCount + tadv;
ret += str[linc];
- if ( linc < size )
+ if (linc < size)
linc++;
else
typeOutDone = true;
* Draw a formatted string to the specified coordinates.
*/
- float putText( const float x, const float y, const char *str, ... ) {
+ float putText(const float x, const float y, const char *str, ...) {
va_list args;
std::unique_ptr<char[]> buf (new char[512]);
va_end(args);
// draw the string and return the width
- return putString( x, y, buf.get() );
+ return putString(x, y, buf.get());
}
- void dialogBox( const char *name, const char *opt, bool passive, const char *text, ... ) {
+ void dialogBox(const char *name, const char *opt, bool passive, const char *text, ...) {
va_list dialogArgs;
std::unique_ptr<char[]> printfbuf (new char[512]);
dialogOptChosen = 0;
- if ( opt ) {
+ if (opt) {
std::string soptbuf = opt;
char *sopt = strtok(&soptbuf[0], ":");
// cycle through options
while(sopt){
- dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0}) );
+ dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0}));
sopt = strtok(NULL,":");
}
}
// cycle through options
while(sopt){
- dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0}) );
+ dialogOptText.push_back(std::make_pair((std::string)sopt, vec3 {0,0,0}));
sopt = strtok(NULL,":");
}
}
* Wait for a dialog box to be dismissed.
*/
- void waitForDialog ( void ) {
- while ( dialogBoxExists );
+ void waitForDialog (void) {
+ while (dialogBoxExists);
}
- void waitForCover ( void ) {
- while ( fadeIntensity < 255 )
+ void waitForCover (void) {
+ while (fadeIntensity < 255)
mainLoop();
fadeIntensity = 255;
}
- void waitForNothing ( unsigned int ms ) {
+ void waitForNothing (unsigned int ms) {
unsigned int target = millis() + ms;
- while ( millis() < target );
+ while (millis() < target);
}
void importantText(const char *text,...){
}
- void drawPage( std::string path ) {
- pageTex = Texture::loadTexture( path );
+ void drawPage(std::string path) {
+ pageTex = Texture::loadTexture(path);
pageTexReady = true;
}
float x,y,tmp;
std::string rtext;
- if ( pageTexReady ) {
- glEnable( GL_TEXTURE_2D );
- glBindTexture( GL_TEXTURE_2D, pageTex );
- glBegin( GL_QUADS );
- glTexCoord2i( 0, 0 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 100 );
- glTexCoord2i( 1, 0 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 100 );
- glTexCoord2i( 1, 1 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 600 );
- glTexCoord2i( 0, 1 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 600 );
+ if (pageTexReady) {
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, pageTex);
+ glBegin(GL_QUADS);
+ glTexCoord2i(0, 0); glVertex2i(offset.x - 300, SCREEN_HEIGHT - 100);
+ glTexCoord2i(1, 0); glVertex2i(offset.x + 300, SCREEN_HEIGHT - 100);
+ glTexCoord2i(1, 1); glVertex2i(offset.x + 300, SCREEN_HEIGHT - 600);
+ glTexCoord2i(0, 1); glVertex2i(offset.x - 300, SCREEN_HEIGHT - 600);
glEnd();
- glDisable( GL_TEXTURE_2D );
+ glDisable(GL_TEXTURE_2D);
} else if (dialogBoxExists) {
putStringCentered(offset.x,offset.y,rtext.c_str());
setFontSize(16);
}
- }else if ( dialogMerchant ) {
+ }else if (dialogMerchant) {
x=offset.x-SCREEN_WIDTH/6;
y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8;
for(i = 0; i < 2; i++){
if(((merchArrowLoc[i].x < merchArrowLoc[i].z) ?
(mouse.x > merchArrowLoc[i].x && mouse.x < merchArrowLoc[i].z) :
- (mouse.x < merchArrowLoc[i].x && mouse.x > merchArrowLoc[i].z) ) &&
- mouse.y > merchArrowLoc[i].y - 8 && mouse.y < merchArrowLoc[i].y + 8 ) {
+ (mouse.x < merchArrowLoc[i].x && mouse.x > merchArrowLoc[i].z)) &&
+ mouse.y > merchArrowLoc[i].y - 8 && mouse.y < merchArrowLoc[i].y + 8) {
glColor3ub(255,255, 0);
}else{
glColor3ub(255,255,255);
// make text yellow if the mouse hovers over the text
if(mouse.x > dialogOptText[i].second.x && mouse.x < dialogOptText[i].second.z &&
- mouse.y > dialogOptText[i].second.y && mouse.y < dialogOptText[i].second.y + 16 ){
+ mouse.y > dialogOptText[i].second.y && mouse.y < dialogOptText[i].second.y + 16){
setFontColor(255, 255, 0);
putStringCentered(offset.x, dialogOptText[i].second.y, dialogOptText[i].first);
}
if(mouse.x > dialogOptText[i].second.x &&
mouse.x < dialogOptText[i].second.z &&
mouse.y > dialogOptText[i].second.y &&
- mouse.y < dialogOptText[i].second.y + 16 ){ // fontSize
+ mouse.y < dialogOptText[i].second.y + 16){ // fontSize
setFontColor(255,255,0);
putStringCentered(offset.x,dialogOptText[i].second.y,dialogOptText[i].first);
}
}
static unsigned int rtext_oldsize = 0;
- if ( rtext_oldsize != rtext.size() ) {
- if ( !isspace( rtext[(rtext_oldsize = rtext.size()) - 1] ) )
- Mix_PlayChannel( 1, dialogClick, 0 );
+ if (rtext_oldsize != rtext.size()) {
+ if (!isspace(rtext[(rtext_oldsize = rtext.size()) - 1]))
+ Mix_PlayChannel(1, dialogClick, 0);
}
}if(!fadeIntensity){
void dialogAdvance(void){
unsigned char i;
- if ( pageTex ) {
- glDeleteTextures( 1, &pageTex );
+ if (pageTex) {
+ glDeleteTextures(1, &pageTex);
pageTex = 0;
pageTexReady = false;
return;
if(mouse.x > dialogOptText[i].second.x &&
mouse.x < dialogOptText[i].second.z &&
mouse.y > dialogOptText[i].second.y &&
- mouse.y < dialogOptText[i].second.y + 16 ){ // fontSize
+ mouse.y < dialogOptText[i].second.y + 16){ // fontSize
dialogOptChosen = i + 1;
goto EXIT;
}
}
- if ( dialogMerchant ) {
- for ( i = 0; i < merchArrowLoc.size(); i++ ) {
+ if (dialogMerchant) {
+ for (i = 0; i < merchArrowLoc.size(); i++) {
// TODO neaten this if statement
SDL_Event e;
// update mouse coords
- mouse.x = premouse.x + offset.x - ( SCREEN_WIDTH / 2 );
- mouse.y = ( offset.y + SCREEN_HEIGHT / 2 ) - premouse.y;
+ mouse.x = premouse.x + offset.x - (SCREEN_WIDTH / 2);
+ mouse.y = (offset.y + SCREEN_HEIGHT / 2) - premouse.y;
static vec2 fr;
static Entity *ig;
break;
case SDL_MOUSEBUTTONUP:
- if ( ig ) {
+ if (ig) {
ig->vel.x = (fr.x - mouse.x) / 50.0f;
ig->vel.y = (fr.y - mouse.y) / 50.0f;
//ig->forcedMove = true; // kills vel.x too quickly
case SDL_MOUSEBUTTONDOWN:
// right click advances dialog
- if ( ( e.button.button & SDL_BUTTON_RIGHT ) && (dialogBoxExists | pageTexReady) )
+ if ((e.button.button & SDL_BUTTON_RIGHT) && (dialogBoxExists | pageTexReady))
dialogAdvance();
// left click uses item
- if ( ( e.button.button & SDL_BUTTON_LEFT ) && !dialogBoxExists )
+ if ((e.button.button & SDL_BUTTON_LEFT) && !dialogBoxExists)
player->inv->usingi = true;
- if( mouse.x > player->loc.x && mouse.x < player->loc.x + player->width &&
- mouse.y > player->loc.y && mouse.y < player->loc.y + player->height ) {
+ if(mouse.x > player->loc.x && mouse.x < player->loc.x + player->width &&
+ mouse.y > player->loc.y && mouse.y < player->loc.y + player->height) {
player->vel.y = .05;
fr = mouse;
ig = player;
} else {
- for ( auto &e : currentWorld->entity ) {
- if( mouse.x > e->loc.x && mouse.x < e->loc.x + e->width &&
- mouse.y > e->loc.y && mouse.y < e->loc.y + e->height ) {
+ for (auto &e : currentWorld->entity) {
+ if(mouse.x > e->loc.x && mouse.x < e->loc.x + e->width &&
+ mouse.y > e->loc.y && mouse.y < e->loc.y + e->height) {
e->vel.y = .05;
fr = mouse;
ig = e;
case SDL_KEYDOWN:
// space - make player jump
- if ( SDL_KEY == SDLK_SPACE ) {
- if ( player->ground ) {
+ if (SDL_KEY == SDLK_SPACE) {
+ if (player->ground) {
player->loc.y += HLINE * 2;
player->vel.y = .4;
player->ground = false;
break;
// only let other keys be handled if dialog allows it
- } else if ( !dialogBoxExists || dialogPassive ) {
+ } else if (!dialogBoxExists || dialogPassive) {
tmp = currentWorld;
switch(SDL_KEY){
case SDLK_t:
player->vel.x = -PLAYER_SPEED_CONSTANT;
player->left = left = true;
player->right = right = false;
- if ( !currentWorld->toLeft.empty() ) {
+ if (currentWorldToLeft) {
oldpos = player->loc;
if((tmp = currentWorld->goWorldLeft(player)) != currentWorld){
tmppos = player->loc;
player->vel.x = PLAYER_SPEED_CONSTANT;
player->right = right = true;
player->left = left = false;
- if ( !currentWorld->toRight.empty() ) {
+ if (currentWorldToRight) {
oldpos = player->loc;
if((tmp = currentWorld->goWorldRight(player)) != currentWorld){
tmppos = player->loc;
case SDLK_s:
break;
case SDLK_w:
- if ( inBattle ) {
+ if (inBattle) {
tmp = currentWorld;
- currentWorld = ((Arena *)currentWorld)->exitArena( player );
- if ( tmp != currentWorld )
+ currentWorld = ((Arena *)currentWorld)->exitArena(player);
+ if (tmp != currentWorld)
toggleBlackFast();
- } else if ( (tmp = currentWorld->goInsideStructure( player )) != currentWorld )
+ } else if ((tmp = currentWorld->goInsideStructure(player)) != currentWorld)
currentWorld = tmp;
break;
case SDLK_LSHIFT:
*/
case SDL_KEYUP:
- if ( SDL_KEY == SDLK_ESCAPE ) {
+ if (SDL_KEY == SDLK_ESCAPE) {
currentMenu = &pauseMenu;
player->save();
return;
}
- switch ( SDL_KEY ) {
+ switch (SDL_KEY) {
case SDLK_F3:
debug ^= true;
break;
weather = WorldWeather::Rain;
break;
case SDLK_i:
- if ( isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorAbove( player ) ) {
+ if (isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorAbove(player)) {
player->loc.y += getIndoorWorldFloorHeight();
player->ground = false;
}
break;
case SDLK_k:
- if ( isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorBelow( player ) ) {
+ if (isCurrentWorldIndoors() && Indoorp(currentWorld)->isFloorBelow(player)) {
player->loc.y -= getIndoorWorldFloorHeight();
player->ground = false;
}
break;
case SDLK_l:
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
- currentWorld->light.back().follow(player);
- currentWorld->light.back().makeFlame();
+ currentWorld->getLastLight()->follow(player);
+ currentWorld->getLastLight()->makeFlame();
break;
case SDLK_f:
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
break;
case SDLK_b:
- if ( debug )
+ if (debug)
posFlag ^= true;
else {
currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, "", "");
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
- currentWorld->light.back().follow(currentWorld->build.back());
- currentWorld->light.back().makeFlame();
+ currentWorld->getLastLight()->follow(currentWorld->build.back());
+ currentWorld->getLastLight()->makeFlame();
}
break;
case SDLK_F12:
}
// Flush preloaded AI functions if necessary
- if ( !dialogBoxExists && AIpreaddr.size() ) {
- while ( !AIpreaddr.empty() ) {
- AIpreaddr.front()->addAIFunc( AIpreload.front(), false );
- AIpreaddr.erase( AIpreaddr.begin() );
- AIpreload.erase( AIpreload.begin() );
+ if (!dialogBoxExists && AIpreaddr.size()) {
+ while (!AIpreaddr.empty()) {
+ AIpreaddr.front()->addAIFunc(AIpreload.front(), false);
+ AIpreaddr.erase(AIpreaddr.begin());
+ AIpreload.erase(AIpreload.begin());
}
}
}
fadeWhite = true;
fadeFast = true;
- Mix_PlayChannel( 1, battleStart, 0 );
+ Mix_PlayChannel(1, battleStart, 0);
}
-
+
void takeScreenshot(GLubyte* pixels){
std::vector<GLubyte> bgr (SCREEN_WIDTH * SCREEN_HEIGHT * 3, 0);
extern Menu pauseMenu;
void Menu::
-gotoParent( void )
+gotoParent(void)
{
- if ( !parent ) {
+ if (!parent) {
currentMenu = NULL;
config::update();
} else
}
void Menu::
-gotoChild( void )
+gotoChild(void)
{
currentMenu = child;
}
return temp;
}
- void draw( void ) {
+ void draw(void) {
SDL_Event e;
setFontSize(24);
*/
void World::
-setBackground( WorldBGType bgt )
+setBackground(WorldBGType bgt)
{
// load textures with a limit check
- switch ( (bgType = bgt) ) {
+ switch ((bgType = bgt)) {
case WorldBGType::Forest:
- bgTex = new Texturec( bgFiles );
+ bgTex = new Texturec(bgFiles);
break;
case WorldBGType::WoodHouse:
- bgTex = new Texturec( bgFilesIndoors );
+ bgTex = new Texturec(bgFilesIndoors);
break;
default:
- UserError( "Invalid world background type" );
+ UserError("Invalid world background type");
break;
}
}
*/
void World::
-setStyle( std::string pre )
+setStyle(std::string pre)
{
unsigned int i;
// get folder prefix
std::string prefix = pre.empty() ? "assets/style/classic/" : pre;
- for ( i = 0; i < arrAmt(buildPaths); i++ )
- sTexLoc.push_back( prefix + buildPaths[i] );
+ for (i = 0; i < arrAmt(buildPaths); i++)
+ sTexLoc.push_back(prefix + buildPaths[i]);
prefix += "bg/";
- for ( i = 0; i < arrAmt(bgPaths[0]); i++ )
- bgFiles.push_back( prefix + bgPaths[0][i] );
+ for (i = 0; i < arrAmt(bgPaths[0]); i++)
+ bgFiles.push_back(prefix + bgPaths[0][i]);
- for ( i = 0; i < arrAmt(bgPaths[1]); i++ )
- bgFilesIndoors.push_back( prefix + bgPaths[1][i] );
+ for (i = 0; i < arrAmt(bgPaths[1]); i++)
+ bgFilesIndoors.push_back(prefix + bgPaths[1][i]);
}
/**
*/
World::
-World( void )
+World(void)
{
bgmObj = NULL;
}
*/
void World::
-deleteEntities( void )
+deleteEntities(void)
{
// free mobs
- while ( !mob.empty() ) {
- delete mob.back();
- mob.pop_back();
- }
+ mob.clear();
merchant.clear();
while(!npc.empty()){
}
// free structures
- while ( !build.empty() ) {
+ while (!build.empty()) {
delete build.back();
build.pop_back();
}
// free objects
- while ( !object.empty() ) {
- delete object.back();
- object.pop_back();
- }
+ object.clear();
// clear entity array
entity.clear();
light.clear();
// free villages
- while ( !village.empty() ) {
- delete village.back();
- village.pop_back();
- }
+ village.clear();
}
/**
*/
World::
-~World( void )
+~World(void)
{
// sdl2_mixer's object
if(bgmObj)
*/
void World::
-generate( unsigned int width )
+generate(unsigned int width)
{
// iterator for `for` loops
std::vector<WorldData>::iterator wditer;
float geninc = 0;
// check for valid width
- if ( (int)width <= 0 )
+ if ((int)width <= 0)
UserError("Invalid world dimensions");
// allocate space for world
// create slopes from the points that were just defined, populate the rest of the WorldData structure
for(wditer = worldData.begin() + 1; wditer != worldData.end(); wditer++){
- if ( (*wditer).groundHeight && wditer + GROUND_HILLINESS < worldData.end() )
+ if ((*wditer).groundHeight && wditer + GROUND_HILLINESS < worldData.end())
// wditer + GROUND_HILLINESS can go out of bounds (invalid read)
- geninc = ( (*(wditer + GROUND_HILLINESS)).groundHeight - (*wditer).groundHeight ) / (float)GROUND_HILLINESS;
+ geninc = ((*(wditer + GROUND_HILLINESS)).groundHeight - (*wditer).groundHeight) / (float)GROUND_HILLINESS;
else
(*wditer).groundHeight = (*(wditer - 1)).groundHeight + geninc;
(*wditer).grassHeight[1] = (randGet() % 16) / 3 + 2;
// bound checks
- if ( (*wditer).groundHeight < GROUND_HEIGHT_MINIMUM )
+ if ((*wditer).groundHeight < GROUND_HEIGHT_MINIMUM)
(*wditer).groundHeight = GROUND_HEIGHT_MINIMUM;
- else if ( (*wditer).groundHeight > GROUND_HEIGHT_MAXIMUM )
+ else if ((*wditer).groundHeight > GROUND_HEIGHT_MAXIMUM)
(*wditer).groundHeight = GROUND_HEIGHT_MAXIMUM;
- if( (*wditer).groundHeight <= 0 )
+ if((*wditer).groundHeight <= 0)
(*wditer).groundHeight = GROUND_HEIGHT_MINIMUM;
}
worldStart = (width - GROUND_HILLINESS) * HLINE / 2 * -1;
// create empty star array, should be filled here as well...
- star = std::vector<vec2> (100, vec2 { 0, 400 } );
- for ( auto &s : star ) {
+ star = std::vector<vec2> (100, vec2 { 0, 400 });
+ for (auto &s : star) {
s.x = (getRand() % (-worldStart * 2)) + worldStart;
s.y = (getRand() % SCREEN_HEIGHT) + 100.0f;
}
*/
void World::
-update( Player *p, unsigned int delta )
+update(Player *p, unsigned int delta)
{
// update player coords
p->loc.y += p->vel.y * delta;
p->loc.x +=(p->vel.x * p->speed) * delta;
- if ( p->loc.y > 5000 )
+ if (p->loc.y > 5000)
UserError("Too high for me m8.");
// update entity coords
- for ( auto &e : entity ) {
+ for (auto &e : entity) {
// dont let structures move?
- if ( e->type != STRUCTURET && e->canMove ) {
+ if (e->type != STRUCTURET && e->canMove) {
e->loc.x += e->vel.x * delta;
e->loc.y += e->vel.y * delta;
// update boolean directions
- if ( e->vel.x < 0 )
+ if (e->vel.x < 0)
e->left = true;
- else if ( e->vel.x > 0 )
+ else if (e->vel.x > 0)
e->left = false;
- } else if ( e->vel.y < 0 )
+ } else if (e->vel.y < 0)
e->loc.y += e->vel.y * delta;
}
// iterate through particles
- particles.erase( std::remove_if( particles.begin(), particles.end(), [&delta](Particles &part){return part.kill(delta);}), particles.end());
- for ( auto part = particles.begin(); part != particles.end(); part++ ) {
- if ( (*part).canMove ) {
+ particles.erase(std::remove_if(particles.begin(), particles.end(), [&delta](Particles &part){return part.kill(delta);}), particles.end());
+ for (auto part = particles.begin(); part != particles.end(); part++) {
+ if ((*part).canMove) {
(*part).loc.y += (*part).vel.y * delta;
(*part).loc.x += (*part).vel.x * delta;
- for ( auto &b : build ) {
- if ( b->bsubtype == FOUNTAIN ) {
- if ( (*part).loc.x >= b->loc.x && (*part).loc.x <= b->loc.x + b->width ) {
- if ( (*part).loc.y <= b->loc.y + b->height * .25)
- particles.erase( part );
+ for (auto &b : build) {
+ if (b->bsubtype == FOUNTAIN) {
+ if ((*part).loc.x >= b->loc.x && (*part).loc.x <= b->loc.x + b->width) {
+ if ((*part).loc.y <= b->loc.y + b->height * .25)
+ particles.erase(part);
}
}
}
// handle music fades
- if ( ui::dialogImportant ) {
+ if (ui::dialogImportant) {
//Mix_FadeOutMusic(2000);
- } else if( !Mix_PlayingMusic() )
+ } else if(!Mix_PlayingMusic())
Mix_FadeInMusic(bgmObj,-1,2000);
}
*/
void World::
-setBGM( std::string path )
+setBGM(std::string path)
{
- if( !path.empty() )
- bgmObj = Mix_LoadMUS( (bgm = path).c_str() );
+ if(!path.empty())
+ bgmObj = Mix_LoadMUS((bgm = path).c_str());
}
/**
*/
void World::
-bgmPlay( World *prev ) const
+bgmPlay(World *prev) const
{
- if ( prev ) {
- if ( bgm != prev->bgm ) {
+ if (prev) {
+ if (bgm != prev->bgm) {
// new world, new music
- Mix_FadeOutMusic( 800 );
- Mix_PlayMusic( bgmObj, -1 );
+ Mix_FadeOutMusic(800);
+ Mix_PlayMusic(bgmObj, -1);
}
} else {
// first call
- Mix_FadeOutMusic( 800 );
- Mix_PlayMusic( bgmObj, -1 );
+ Mix_FadeOutMusic(800);
+ Mix_PlayMusic(bgmObj, -1);
}
}
// shade value for GLSL
float shadeAmbient = -worldShade / 50.0f + 0.5f; // -0.5f to 1.5f
- if ( shadeAmbient < 0 )
+ if (shadeAmbient < 0)
shadeAmbient = 0;
- else if ( shadeAmbient > 0.9f )
+ else if (shadeAmbient > 0.9f)
shadeAmbient = 1;
/*
* Draw background images.
*/
- glEnable( GL_TEXTURE_2D );
+ glEnable(GL_TEXTURE_2D);
// the sunny wallpaper is faded with the night depending on tickCount
- bgTex->bind( 0 );
+ bgTex->bind(0);
int alpha;
- switch( weather ) {
+ switch(weather) {
case WorldWeather::Snowy:
alpha = 150;
break;
alpha = 255 - worldShade * 4;
break;
}
- safeSetColorA( 255, 255, 255, alpha );
+ safeSetColorA(255, 255, 255, alpha);
- glBegin( GL_QUADS );
- glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2 );
- glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2 );
- glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2 );
- glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2 );
+ glBegin(GL_QUADS);
+ glTexCoord2i(0, 0); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2);
+ glTexCoord2i(1, 0); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2);
+ glTexCoord2i(1, 1); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2);
+ glTexCoord2i(0, 1); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2);
glEnd();
bgTex->bindNext();
- safeSetColorA( 255, 255, 255, !alpha ? 255 : worldShade * 4);
+ safeSetColorA(255, 255, 255, !alpha ? 255 : worldShade * 4);
- glBegin( GL_QUADS );
- glTexCoord2i( 0, 0 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2 );
- glTexCoord2i( 1, 0 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2 );
- glTexCoord2i( 1, 1 ); glVertex2i( offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2 );
- glTexCoord2i( 0, 1 ); glVertex2i( offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2 );
+ glBegin(GL_QUADS);
+ glTexCoord2i(0, 0); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y + SCREEN_HEIGHT/2);
+ glTexCoord2i(1, 0); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y + SCREEN_HEIGHT/2);
+ glTexCoord2i(1, 1); glVertex2i(offset.x + SCREEN_WIDTH/2+5, offset.y - SCREEN_HEIGHT/2);
+ glTexCoord2i(0, 1); glVertex2i(offset.x - SCREEN_WIDTH/2-5, offset.y - SCREEN_HEIGHT/2);
glEnd();
- glDisable( GL_TEXTURE_2D );
+ glDisable(GL_TEXTURE_2D);
// draw the stars if the time deems it appropriate
- //if (((( weather == WorldWeather::Dark ) & ( tickCount % DAY_CYCLE )) < DAY_CYCLE / 2) ||
- // ((( weather == WorldWeather::Sunny ) & ( tickCount % DAY_CYCLE )) > DAY_CYCLE * .75) ){
- if ( worldShade > 0 ) {
+ //if ((((weather == WorldWeather::Dark) & (tickCount % DAY_CYCLE)) < DAY_CYCLE / 2) ||
+ // (((weather == WorldWeather::Sunny) & (tickCount % DAY_CYCLE)) > DAY_CYCLE * .75)){
+ if (worldShade > 0) {
- safeSetColorA( 255, 255, 255, 255 - (getRand() % 30 - 15) );
+ safeSetColorA(255, 255, 255, 255 - (getRand() % 30 - 15));
- for ( i = 0; i < 100; i++ ) {
+ for (i = 0; i < 100; i++) {
glRectf(star[i].x + offset.x * .9,
star[i].y,
star[i].x + offset.x * .9 + HLINE,
// draw remaining background items
- glEnable( GL_TEXTURE_2D );
+ glEnable(GL_TEXTURE_2D);
bgTex->bindNext();
- safeSetColorA( 150 + shadeBackground * 2, 150 + shadeBackground * 2, 150 + shadeBackground * 2, 255 );
-
- glBegin( GL_QUADS );
- for ( i = 0; i <= (int)(worldData.size() * HLINE / 1920); i++ ) {
- glTexCoord2i( 0, 1 ); glVertex2i( width / 2 * -1 + (1920 * i ) + offset.x * .85, GROUND_HEIGHT_MINIMUM );
- glTexCoord2i( 1, 1 ); glVertex2i( width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM );
- glTexCoord2i( 1, 0 ); glVertex2i( width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080 );
- glTexCoord2i( 0, 0 ); glVertex2i( width / 2 * -1 + (1920 * i ) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080 );
+ safeSetColorA(150 + shadeBackground * 2, 150 + shadeBackground * 2, 150 + shadeBackground * 2, 255);
+
+ glBegin(GL_QUADS);
+ for (i = 0; i <= (int)(worldData.size() * HLINE / 1920); i++) {
+ glTexCoord2i(0, 1); glVertex2i(width / 2 * -1 + (1920 * i) + offset.x * .85, GROUND_HEIGHT_MINIMUM);
+ glTexCoord2i(1, 1); glVertex2i(width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM);
+ glTexCoord2i(1, 0); glVertex2i(width / 2 * -1 + (1920 * (i + 1)) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080);
+ glTexCoord2i(0, 0); glVertex2i(width / 2 * -1 + (1920 * i) + offset.x * .85, GROUND_HEIGHT_MINIMUM + 1080);
}
glEnd();
- for ( i = 0; i < 4; i++ ) {
+ for (i = 0; i < 4; i++) {
bgTex->bindNext();
- safeSetColorA( bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][1] );
-
- glBegin( GL_QUADS );
- for( int j = worldStart; j <= -worldStart; j += 600 ){
- glTexCoord2i( 0, 1 ); glVertex2i( j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM );
- glTexCoord2i( 1, 1 ); glVertex2i( (j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM );
- glTexCoord2i( 1, 0 ); glVertex2i( (j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400 );
- glTexCoord2i( 0, 0 ); glVertex2i( j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400 );
+ safeSetColorA(bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][0] + shadeBackground * 2, bgDraw[i][1]);
+
+ glBegin(GL_QUADS);
+ for(int j = worldStart; j <= -worldStart; j += 600){
+ glTexCoord2i(0, 1); glVertex2i(j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM);
+ glTexCoord2i(1, 1); glVertex2i((j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM);
+ glTexCoord2i(1, 0); glVertex2i((j + 600) + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400);
+ glTexCoord2i(0, 0); glVertex2i(j + offset.x * bgDraw[i][2], GROUND_HEIGHT_MINIMUM + 400);
}
glEnd();
}
- glDisable( GL_TEXTURE_2D );
+ glDisable(GL_TEXTURE_2D);
// draw black under backgrounds
- glColor3ub( 0, 0, 0 );
- glRectf( worldStart, GROUND_HEIGHT_MINIMUM, -worldStart, 0 );
+ glColor3ub(0, 0, 0);
+ glRectf(worldStart, GROUND_HEIGHT_MINIMUM, -worldStart, 0);
pOffset = (offset.x + p->width / 2 - worldStart) / HLINE;
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glUseProgram(shaderProgram);
- std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( part.behind ) part.draw(); });
+ std::for_each(particles.begin(), particles.end(), [](Particles part) { if (part.behind) part.draw(); });
glUseProgram(0);
- for ( auto &b : build ) {
- if ( b->bsubtype == STALL_MARKET ) {
- for ( auto &n : npc ) {
- if ( n->type == MERCHT && ((Merchant *)n)->inside == b ) {
+ for (auto &b : build) {
+ if (b->bsubtype == STALL_MARKET) {
+ for (auto &n : npc) {
+ if (n->type == MERCHT && ((Merchant *)n)->inside == b) {
n->draw();
break;
}
// draw light elements?
- glEnable( GL_TEXTURE_2D );
+ glEnable(GL_TEXTURE_2D);
- glActiveTexture( GL_TEXTURE0 );
+ glActiveTexture(GL_TEXTURE0);
bgTex->bindNext();
for(auto &l : light){
}
}
- for ( uint i = 0; i < light.size(); i++ )
+ for (uint i = 0; i < light.size(); i++)
flameArray[i] = light[i].fireFlicker;
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glUseProgram( shaderProgram );
- glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0 );
- glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), shadeAmbient );
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
+ glUniform1f(glGetUniformLocation(shaderProgram, "amb"), shadeAmbient);
- if ( light.size() == 0)
- glUniform1i( glGetUniformLocation( shaderProgram, "numLight"), 0);
+ if (light.size() == 0)
+ glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0);
else {
- glUniform1i ( glGetUniformLocation( shaderProgram, "numLight" ), light.size());
- glUniform2fv( glGetUniformLocation( shaderProgram, "lightLocation"), light.size(), pointArray );
- glUniform3f ( glGetUniformLocation( shaderProgram, "lightColor" ), 1.0f, 1.0f, 1.0f );
+ glUniform1i (glGetUniformLocation(shaderProgram, "numLight"), light.size());
+ glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size(), pointArray);
+ glUniform3f (glGetUniformLocation(shaderProgram, "lightColor"), 1.0f, 1.0f, 1.0f);
glUniform1fv(glGetUniformLocation(shaderProgram,"fireFlicker"), light.size(),flameArray);
}
* Draw the dirt.
*/
- glBegin( GL_QUADS );
+ glBegin(GL_QUADS);
// faulty
/*glTexCoord2i(0 ,0);glVertex2i(pOffset - (SCREEN_WIDTH / 1.5),0);
glTexCoord2i(64,1);glVertex2i(pOffset + (SCREEN_WIDTH / 1.5),GROUND_HEIGHT_MINIMUM);
glTexCoord2i(0 ,1);glVertex2i(pOffset - (SCREEN_WIDTH / 1.5),GROUND_HEIGHT_MINIMUM);*/
- for ( i = iStart; i < iEnd; i++ ) {
- if ( worldData[i].groundHeight <= 0 ) {
+ for (i = iStart; i < iEnd; i++) {
+ if (worldData[i].groundHeight <= 0) {
worldData[i].groundHeight = GROUND_HEIGHT_MINIMUM - 1;
- glColor4ub( 0, 0, 0, 255 );
+ glColor4ub(0, 0, 0, 255);
} else
- safeSetColorA( 150, 150, 150, 255 );
+ safeSetColorA(150, 150, 150, 255);
- glTexCoord2i( 0, 0 ); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT );
- glTexCoord2i( 1, 0 ); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT );
+ glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT);
+ glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT);
- glTexCoord2i( 1, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor ); glVertex2i(worldStart + i * HLINE + HLINE, 0 );
- glTexCoord2i( 0, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor ); glVertex2i(worldStart + i * HLINE , 0 );
+ glTexCoord2i(1, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor); glVertex2i(worldStart + i * HLINE + HLINE, 0);
+ glTexCoord2i(0, (int)(worldData[i].groundHeight / 64) + worldData[i].groundColor); glVertex2i(worldStart + i * HLINE , 0);
- if ( worldData[i].groundHeight == GROUND_HEIGHT_MINIMUM - 1 )
+ if (worldData[i].groundHeight == GROUND_HEIGHT_MINIMUM - 1)
worldData[i].groundHeight = 0;
}
* Draw the grass/the top of the ground.
*/
- glEnable( GL_TEXTURE_2D );
+ glEnable(GL_TEXTURE_2D);
- glActiveTexture( GL_TEXTURE0 );
+ glActiveTexture(GL_TEXTURE0);
bgTex->bindNext();
- glUseProgram( shaderProgram );
- glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0);
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
float cgh[2];
- for ( i = iStart; i < iEnd - GROUND_HILLINESS; i++ ) {
+ for (i = iStart; i < iEnd - GROUND_HILLINESS; i++) {
// load the current line's grass values
- if ( worldData[i].groundHeight )
- memcpy( cgh, worldData[i].grassHeight, 2 * sizeof( float ));
+ if (worldData[i].groundHeight)
+ memcpy(cgh, worldData[i].grassHeight, 2 * sizeof(float));
else
- memset( cgh, 0 , 2 * sizeof( float ));
+ memset(cgh, 0 , 2 * sizeof(float));
// flatten the grass if the player is standing on it.
- if( !worldData[i].grassUnpressed ){
+ if(!worldData[i].grassUnpressed){
cgh[0] /= 4;
cgh[1] /= 4;
}
// actually draw the grass.
- safeSetColorA( 255, 255, 255, 255 );
-
- glBegin( GL_QUADS );
- glTexCoord2i( 0, 0 ); glVertex2i( worldStart + i * HLINE , worldData[i].groundHeight + cgh[0] );
- glTexCoord2i( 1, 0 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[0] );
- glTexCoord2i( 1, 1 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT );
- glTexCoord2i( 0, 1 ); glVertex2i( worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT );
- glTexCoord2i( 0, 0 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[1] );
- glTexCoord2i( 1, 0 ); glVertex2i( worldStart + i * HLINE + HLINE , worldData[i].groundHeight + cgh[1] );
- glTexCoord2i( 1, 1 ); glVertex2i( worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT );
- glTexCoord2i( 0, 1 ); glVertex2i( worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT );
+ safeSetColorA(255, 255, 255, 255);
+
+ glBegin(GL_QUADS);
+ glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight + cgh[0]);
+ glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[0]);
+ glTexCoord2i(1, 1); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT);
+ glTexCoord2i(0, 1); glVertex2i(worldStart + i * HLINE , worldData[i].groundHeight - GRASS_HEIGHT);
+ glTexCoord2i(0, 0); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight + cgh[1]);
+ glTexCoord2i(1, 0); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight + cgh[1]);
+ glTexCoord2i(1, 1); glVertex2i(worldStart + i * HLINE + HLINE , worldData[i].groundHeight - GRASS_HEIGHT);
+ glTexCoord2i(0, 1); glVertex2i(worldStart + i * HLINE + HLINE / 2, worldData[i].groundHeight - GRASS_HEIGHT);
glEnd();
}
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glUseProgram(shaderProgram);
- std::for_each( particles.begin(), particles.end(), [](Particles part) { if ( !part.behind ) part.draw(); });
+ std::for_each(particles.begin(), particles.end(), [](Particles part) { if (!part.behind) part.draw(); });
glUseProgram(0);
- for ( auto &n : npc ) {
- if ( n->type != MERCHT )
+ for (auto &n : npc) {
+ if (n->type != MERCHT)
n->draw();
}
- for ( auto &m : mob )
- m->draw();
+ for (auto &m : mob)
+ m.draw();
- for ( auto &o : object )
- o->draw();
+ for (auto &o : object)
+ o.draw();
/*
* Handle grass-squishing.
*/
// calculate the line that the player is on
- int ph = ( p->loc.x + p->width / 2 - worldStart ) / HLINE;
+ int ph = (p->loc.x + p->width / 2 - worldStart) / HLINE;
// flatten grass under the player if the player is on the ground
- if ( p->ground ) {
- for ( i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++ )
- worldData[i].grassUnpressed = !( i < ph + 6 && i > ph - 6 );
+ if (p->ground) {
+ for (i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++)
+ worldData[i].grassUnpressed = !(i < ph + 6 && i > ph - 6);
} else {
- for ( i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++ )
+ for (i = 0; i < (int)(worldData.size() - GROUND_HILLINESS); i++)
worldData[i].grassUnpressed = true;
}
*/
void World::
-singleDetect( Entity *e )
+singleDetect(Entity *e)
{
std::string killed;
unsigned int i,j;
* Kill any dead entities.
*/
- if ( e->alive && e->health <= 0 ) {
+ if (e->alive && e->health <= 0) {
e->alive = false;
e->health = 0;
- for ( i = 0; i < entity.size(); i++) {
- if ( entity[i] == e ){
- switch ( e->type ) {
+ for (i = 0; i < entity.size(); i++) {
+ if (entity[i] == e){
+ switch (e->type) {
case STRUCTURET:
killed = "structure";
for(j=0;j<build.size();j++){
break;
case OBJECTT:
killed = "object";
- for(j=0;j<object.size();j++){
- if(object[j]==e){
- delete object[j];
- object.erase(object.begin()+j);
- break;
- }
- }
+ for (auto o = std::begin(object); o != std::end(object); o++) {
+ if (&(*o) == e) {
+ object.erase(o);
+ break;
+ }
+ }
break;
default:
break;
}
}
std::cout << "RIP " << e->name << "." << std::endl;
- exit( 0 );
+ exit(0);
}
// handle only living entities
- if ( e->alive ) {
+ if (e->alive) {
// forced movement gravity
- if ( e->forcedMove ) {
- if ( e->vel.x > .0005 || e->vel.x < -.0005 )
+ if (e->forcedMove) {
+ if (e->vel.x > .0005 || e->vel.x < -.0005)
e->vel.x *= .6;
else
e->forcedMove = false;
}
- if ( e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER )
+ if (e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER)
return;
// calculate the line that this entity is currently standing on
l = (e->loc.x + e->width / 2 - worldStart) / HLINE;
- if ( l < 0 )
+ if (l < 0)
l = 0;
i = l;
- if ( i > lineCount - 1 )
+ if (i > lineCount - 1)
i = lineCount - 1;
// if the entity is under the world/line, pop it back to the surface
- if ( e->loc.y < worldData[i].groundHeight ) {
+ if (e->loc.y < worldData[i].groundHeight) {
int dir = e->vel.x < 0 ? -1 : 1;
- if ( i + (dir * 2) < worldData.size() && worldData[i + (dir * 2)].groundHeight - 30 > worldData[i + dir].groundHeight ) {
- e->loc.x -= ( PLAYER_SPEED_CONSTANT + 2.7 ) * e->speed * 2 * dir;
+ if (i + (dir * 2) < worldData.size() && worldData[i + (dir * 2)].groundHeight - 30 > worldData[i + dir].groundHeight) {
+ e->loc.x -= (PLAYER_SPEED_CONSTANT + 2.7) * e->speed * 2 * dir;
e->vel.x = 0;
} else {
e->loc.y = worldData[i].groundHeight - .001 * deltaTime;
// handle gravity if the entity is above the line
else {
- if ( e->type == STRUCTURET ) {
+ if (e->type == STRUCTURET) {
e->loc.y = worldData[i].groundHeight;
e->vel.y = 0;
e->ground = true;
return;
- } else if ( e->vel.y > -2 )
+ } else if (e->vel.y > -2)
e->vel.y -= GRAVITY_CONSTANT * deltaTime;
}
*/
void World::
-detect( Player *p )
+detect(Player *p)
{
int l;
// handle the player
- std::thread( &World::singleDetect, this, p ).detach();
+ std::thread(&World::singleDetect, this, p).detach();
// handle other entities
- for ( auto &e : entity )
- std::thread( &World::singleDetect, this, e ).detach();
+ for (auto &e : entity)
+ std::thread(&World::singleDetect, this, e).detach();
// handle particles
- for ( auto &part : particles ) {
+ for (auto &part : particles) {
// get particle's current world line
l = (part.loc.x + part.width / 2 - worldStart) / HLINE;
- if ( l < 0 )
+ if (l < 0)
l = 0;
- if ( l > (int)(lineCount - 1) )
+ if (l > (int)(lineCount - 1))
l = lineCount - 1;
- part.update( GRAVITY_CONSTANT, worldData[l].groundHeight );
+ part.update(GRAVITY_CONSTANT, worldData[l].groundHeight);
}
// handle particle creation
- for ( auto &b : build ) {
- switch ( b->bsubtype ) {
+ for (auto &b : build) {
+ switch (b->bsubtype) {
case FOUNTAIN:
- for ( unsigned int r = (randGet() % 25) + 11; r--; ) {
+ for (unsigned int r = (randGet() % 25) + 11; r--;) {
addParticle(randGet() % HLINE * 3 + b->loc.x + b->width / 2, // x
b->loc.y + b->height, // y
HLINE * 1.25, // width
break;
case FIRE_PIT:
- for(unsigned int r = (randGet() % 20) + 11; r--; ) {
+ for(unsigned int r = (randGet() % 20) + 11; r--;) {
addParticle(randGet() % (int)(b->width / 2) + b->loc.x + b->width / 4, // x
b->loc.y + 3 * HLINE, // y
HLINE, // width
}
// draws the village welcome message if the player enters the village bounds
- for ( auto &v : village ) {
- if ( p->loc.x > v->start.x && p->loc.x < v->end.x ) {
- if ( !v->in ) {
- ui::passiveImportantText( 5000, "Welcome to %s", v->name.c_str() );
- v->in = true;
+ for (auto &v : village) {
+ if (p->loc.x > v.start.x && p->loc.x < v.end.x) {
+ if (!v.in) {
+ ui::passiveImportantText(5000, "Welcome to %s", v.name.c_str());
+ v.in = true;
}
} else
- v->in = false;
+ v.in = false;
}
}
entity.push_back(build.back());
}
+Village *World::
+addVillage(std::string name, World *world)
+{
+ village.emplace_back(name.c_str(), world);
+ return &village.back();
+}
+
void World::addMob(int t,float x,float y){
- mob.push_back(new Mob(t));
- mob.back()->spawn(x,y);
+ mob.emplace_back(t);
+ mob.back().spawn(x,y);
- entity.push_back(mob.back());
+ entity.push_back(&mob.back());
}
void World::addMob(int t,float x,float y,void (*hey)(Mob *)){
- mob.push_back(new Mob(t));
- mob.back()->spawn(x,y);
- mob.back()->hey = hey;
+ mob.emplace_back(t);
+ mob.back().spawn(x,y);
+ mob.back().hey = hey;
- entity.push_back(mob.back());
+ entity.push_back(&mob.back());
}
void World::addNPC(float x,float y){
entity.push_back(npc.back());
}
-void World::addObject( std::string in, std::string p, float x, float y){
- object.push_back(new Object(in,p));
- object.back()->spawn(x,y);
+void World::addObject(std::string in, std::string p, float x, float y){
+ object.emplace_back(in, p);
+ object.back().spawn(x, y);
- entity.push_back(object.back());
+ entity.push_back(&object.back());
}
void World::
-addParticle( float x, float y, float w, float h, float vx, float vy, Color color, int d )
+addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d)
{
- particles.emplace_back( x, y, w, h, vx, vy, color, d );
+ particles.emplace_back(x, y, w, h, vx, vy, color, d);
particles.back().canMove = true;
}
void World::
-addParticle( float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity )
+addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, unsigned char flags)
{
- particles.emplace_back( x, y, w, h, vx, vy, color, d );
+ particles.emplace_back(x, y, w, h, vx, vy, color, d);
particles.back().canMove = true;
- particles.back().gravity = gravity;
+ particles.back().gravity = flags & (1 << 0);
+ particles.back().bounce = flags & (1 << 1);
}
void World::
-addLight( vec2 loc, Color color )
+addLight(vec2 loc, Color color)
+{
+ if (light.size() < 64)
+ light.push_back(Light(loc, color, 1));
+}
+
+Light *World::
+getLastLight(void)
+{
+ return &light.back();
+}
+
+Mob *World::
+getLastMob(void)
+{
+ return &mob.back();
+}
+
+std::string World::
+getSTextureLocation(unsigned int index) const
{
- if ( light.size() < 64 )
- light.push_back( Light( loc, color, 1 ) );
+ if (index > sTexLoc.size())
+ return "";
+
+ return sTexLoc[ index ];
}
std::string World::
-setToLeft( std::string file )
+setToLeft(std::string file)
{
return (toLeft = file);
}
std::string World::
-setToRight( std::string file )
+setToRight(std::string file)
{
return (toRight = file);
}
+std::string World::
+getToLeft(void) const
+{
+ return toLeft;
+}
+
+std::string World::
+getToRight(void) const
+{
+ return toRight;
+}
+
World *World::
-goWorldLeft( Player *p )
+goWorldLeft(Player *p)
{
World *tmp;
// check if player is at world edge
- if( !toLeft.empty() && p->loc.x < worldStart + HLINE * 15.0f ) {
+ if(!toLeft.empty() && p->loc.x < worldStart + HLINE * 15.0f) {
// load world (`toLeft` conditional confirms existance)
- tmp = loadWorldFromPtr( currentWorldToLeft );
+ tmp = loadWorldFromPtr(currentWorldToLeft);
// adjust player location
p->loc.x = tmp->worldStart + HLINE * 20;
}
bool World::
-goWorldLeft( NPC *e )
+goWorldLeft(NPC *e)
{
// check if entity is at world edge
- if( !toLeft.empty() && e->loc.x < worldStart + HLINE * 15.0f ) {
+ if(!toLeft.empty() && e->loc.x < worldStart + HLINE * 15.0f) {
currentWorldToLeft->addNPC(e->loc.x,e->loc.y);
e->alive = false;
}
World *World::
-goWorldRight( Player *p )
+goWorldRight(Player *p)
{
World *tmp;
- if( !toRight.empty() && p->loc.x + p->width > -worldStart - HLINE * 15 ) {
- tmp = loadWorldFromPtr( currentWorldToRight );
+ if(!toRight.empty() && p->loc.x + p->width > -worldStart - HLINE * 15) {
+ tmp = loadWorldFromPtr(currentWorldToRight);
p->loc.x = tmp->worldStart - HLINE * -15.0f;
p->loc.y = GROUND_HEIGHT_MINIMUM;
}
World *World::
-goInsideStructure( Player *p )
+goInsideStructure(Player *p)
{
World *tmp;
std::string current;
- if ( inside.empty() ) {
- for ( auto &b : build ) {
- if ( p->loc.x > b->loc.x &&
- p->loc.x + p->width < b->loc.x + b->width ) {
+ if (inside.empty()) {
+ for (auto &b : build) {
+ if (p->loc.x > b->loc.x &&
+ p->loc.x + p->width < b->loc.x + b->width) {
- if ( b->inside.empty() )
+ if (b->inside.empty())
return this;
inside.push_back(currentXML.c_str() + xmlFolder.size());
- tmp = loadWorldFromXML( b->inside );
+ tmp = loadWorldFromXML(b->inside);
ui::toggleBlackFast();
ui::waitForCover();
}
} else {
current = currentXML.c_str() + xmlFolder.size();
- tmp = loadWorldFromXML( inside.back() );
- for ( auto &b : tmp->build ) {
- if ( current == b->inside ) {
+ tmp = loadWorldFromXML(inside.back());
+ for (auto &b : tmp->build) {
+ if (current == b->inside) {
inside.pop_back();
ui::toggleBlackFast();
}
void World::
-addHole( unsigned int start, unsigned int end )
+addHole(unsigned int start, unsigned int end)
{
- if ( end > worldData.size() )
+ if (end > worldData.size())
end = worldData.size();
-
- for ( unsigned int i = start; i < end; i++ )
+
+ for (unsigned int i = start; i < end; i++)
worldData[i].groundHeight = 0;
}
void World::
-addHill( const ivec2 peak, const unsigned int width )
+addHill(const ivec2 peak, const unsigned int width)
{
int start = peak.x - width / 2, end = start + width, offset = 0;
const float thing = peak.y - worldData[start].groundHeight;
const float period = PI / width;
- if ( start < 0 ) {
+ if (start < 0) {
offset = -start;
start = 0;
}
- if ( end > (signed)worldData.size() )
+ if (end > (signed)worldData.size())
end = worldData.size();
- for ( int i = start; i < end; i++ ) {
+ for (int i = start; i < end; i++) {
worldData[i].groundHeight += thing * sin((i - start + offset) * period);
- if ( worldData[i].groundHeight > peak.y )
+ if (worldData[i].groundHeight > peak.y)
worldData[i].groundHeight = peak.y;
}
}
int World::
-getTheWidth( void ) const
+getTheWidth(void) const
{
return worldStart * -2;
}
}
for(auto &m : mob){
- data.append(std::to_string((int)m->loc.x) + "\n");
- data.append(std::to_string((int)m->loc.y) + "\n");
- data.append(std::to_string((int)m->alive) + "\n");
+ data.append(std::to_string((int)m.loc.x) + "\n");
+ data.append(std::to_string((int)m.loc.y) + "\n");
+ data.append(std::to_string((int)m.alive) + "\n");
}
data.append("dOnE\0");
for(auto &m : mob){
std::getline(iss,line);
if(line == "dOnE")return;
- m->loc.x = std::stoi(line);
+ m.loc.x = std::stoi(line);
std::getline(iss,line);
if(line == "dOnE")return;
- m->loc.y = std::stoi(line);
+ m.loc.y = std::stoi(line);
std::getline(iss,line);
if(line == "dOnE")return;
- m->alive = std::stoi(line);
+ m.alive = std::stoi(line);
}
while(std::getline(iss,line)){
delete[] filedata;
}
-float getIndoorWorldFloorHeight( void )
+float getIndoorWorldFloorHeight(void)
{
return INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS;
}
-bool isCurrentWorldIndoors( void ) {
+bool isCurrentWorldIndoors(void) {
return !inside.empty();
}
}
void IndoorWorld::
-addFloor( unsigned int width )
+addFloor(unsigned int width)
{
- if ( floor.empty() )
- generate( width );
- floor.emplace_back( width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS );
- fstart.push_back( 0 );
+ if (floor.empty())
+ generate(width);
+ floor.emplace_back(width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS);
+ fstart.push_back(0);
}
void IndoorWorld::
-addFloor( unsigned int width, unsigned int start )
+addFloor(unsigned int width, unsigned int start)
{
- if ( floor.empty() )
- generate( width );
- floor.emplace_back( width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS );
- fstart.push_back( start );
+ if (floor.empty())
+ generate(width);
+ floor.emplace_back(width, floor.size() * INDOOR_FLOOR_HEIGHTT + INDOOR_FLOOR_THICKNESS);
+ fstart.push_back(start);
}
bool IndoorWorld::
-moveToFloor( Entity *e, unsigned int _floor )
+moveToFloor(Entity *e, unsigned int _floor)
{
- if ( _floor > floor.size() )
+ if (_floor > floor.size())
return false;
e->loc.y = floor[_floor - 1][0];
}
bool IndoorWorld::
-isFloorAbove( Entity *e )
+isFloorAbove(Entity *e)
{
- for ( unsigned int i = 0; i < floor.size(); i++ ) {
- if ( floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y )
+ for (unsigned int i = 0; i < floor.size(); i++) {
+ if (floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y)
return (i + 1) != floor.size();
}
return false;
}
bool IndoorWorld::
-isFloorBelow( Entity *e )
+isFloorBelow(Entity *e)
{
- for ( unsigned int i = 0; i < floor.size(); i++ ) {
- if ( floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y )
+ for (unsigned int i = 0; i < floor.size(); i++) {
+ if (floor[i][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y)
return i > 0;
}
return false;
}
void IndoorWorld::
-singleDetect( Entity *e )
+singleDetect(Entity *e)
{
unsigned int floornum = 0;
float start, end;
- if ( !e->alive )
+ if (!e->alive)
return;
- if ( e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER )
+ if (e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER)
return;
- for ( ; floornum < floor.size(); floornum++ ) {
- if ( floor[floornum][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y ) {
- if ( e->loc.y < floor[floornum][0] ) {
+ for (; floornum < floor.size(); floornum++) {
+ if (floor[floornum][0] + INDOOR_FLOOR_HEIGHTT - 100 > e->loc.y) {
+ if (e->loc.y < floor[floornum][0]) {
e->loc.y = floor[floornum][0];
e->vel.y = 0;
e->ground = true;
}
}
- if ( e->vel.y > -2 )
+ if (e->vel.y > -2)
e->vel.y -= GRAVITY_CONSTANT * deltaTime;
- if ( e->ground ) {
- e->loc.y = ceil( e->loc.y );
+ if (e->ground) {
+ e->loc.y = ceil(e->loc.y);
e->vel.y = 0;
}
start = worldStart + fstart[floornum] * HLINE;
end = start + floor[floornum].size() * HLINE;
- if ( e->loc.x < start ) {
+ if (e->loc.x < start) {
e->vel.x = 0;
e->loc.x = start + HLINE / 2;
- } else if ( e->loc.x + e->width + HLINE > end ) {
+ } else if (e->loc.x + e->width + HLINE > end) {
e->vel.x = 0;
e->loc.x = end - e->width - HLINE;
}
}
void IndoorWorld::
-draw( Player *p )
+draw(Player *p)
{
unsigned int i,f;
int x;
// draw lights
- for ( auto &l : light ) {
- if ( l.belongsTo ) {
+ for (auto &l : light) {
+ if (l.belongsTo) {
l.loc.x = l.following->loc.x + SCREEN_WIDTH / 2;
- l.loc.y = ( l.following->loc.y > SCREEN_HEIGHT / 2 ) ? SCREEN_HEIGHT / 2 : l.following->loc.y;
+ l.loc.y = (l.following->loc.y > SCREEN_HEIGHT / 2) ? SCREEN_HEIGHT / 2 : l.following->loc.y;
}
- if ( l.flame ) {
- l.fireFlicker = .9 + ( (rand() % 2) / 10.0f );
+ if (l.flame) {
+ l.fireFlicker = .9 + ((rand() % 2) / 10.0f);
l.fireLoc.x = l.loc.x + (rand() % 2 - 1) * 3;
l.fireLoc.y = l.loc.y + (rand() % 2 - 1) * 3;
} else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glUseProgram( shaderProgram );
+ glUseProgram(shaderProgram);
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
- glUniform1f(glGetUniformLocation(shaderProgram, "amb" ), 0.02f + light.size()/50.0f);
+ glUniform1f(glGetUniformLocation(shaderProgram, "amb"), 0.02f + light.size()/50.0f);
- if ( light.empty() )
+ if (light.empty())
glUniform1i(glGetUniformLocation(shaderProgram, "numLight"), 0);
else {
- glUniform1i (glGetUniformLocation(shaderProgram, "numLight" ), light.size());
+ glUniform1i (glGetUniformLocation(shaderProgram, "numLight"), light.size());
glUniform2fv(glGetUniformLocation(shaderProgram, "lightLocation"), light.size(), pointArray);
- glUniform3f (glGetUniformLocation(shaderProgram, "lightColor" ), 1.0f, 1.0f, 1.0f);
+ glUniform3f (glGetUniformLocation(shaderProgram, "lightColor"), 1.0f, 1.0f, 1.0f);
glUniform1fv(glGetUniformLocation(shaderProgram, "fireFlicker"), light.size(), flameArray);
}
glColor4ub(255,255,255,255);
glBegin(GL_QUADS);
- glTexCoord2i(0,1); glVertex2i( worldStart - SCREEN_WIDTH / 2,0);
+ glTexCoord2i(0,1); glVertex2i(worldStart - SCREEN_WIDTH / 2,0);
glTexCoord2i((-worldStart*2+SCREEN_WIDTH)/512,1);glVertex2i(-worldStart + SCREEN_WIDTH / 2,0);
glTexCoord2i((-worldStart*2+SCREEN_WIDTH)/512,0);glVertex2i(-worldStart + SCREEN_WIDTH / 2,SCREEN_HEIGHT);
- glTexCoord2i(0,0); glVertex2i( worldStart - SCREEN_WIDTH / 2,SCREEN_HEIGHT);
+ glTexCoord2i(0,0); glVertex2i(worldStart - SCREEN_WIDTH / 2,SCREEN_HEIGHT);
glEnd();
glUseProgram(0);
* Draw the ground.
*/
- glUseProgram( shaderProgram );
- glUniform1i( glGetUniformLocation(shaderProgram, "sampler"), 0 );
- glBegin( GL_QUADS );
- safeSetColor( 150, 100, 50 );
- for ( f = 0; f < floor.size(); f++ ) {
+ glUseProgram(shaderProgram);
+ glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
+ glBegin(GL_QUADS);
+ safeSetColor(150, 100, 50);
+ for (f = 0; f < floor.size(); f++) {
i = 0;
- for ( h : floor[f] ) {
+ for (h : floor[f]) {
x = worldStart + fstart[f] * HLINE + (i * HLINE);
- glVertex2i( x , h );
- glVertex2i( x + HLINE, h );
- glVertex2i( x + HLINE, h - INDOOR_FLOOR_THICKNESS );
- glVertex2i( x , h - INDOOR_FLOOR_THICKNESS );
+ glVertex2i(x , h );
+ glVertex2i(x + HLINE, h );
+ glVertex2i(x + HLINE, h - INDOOR_FLOOR_THICKNESS);
+ glVertex2i(x , h - INDOOR_FLOOR_THICKNESS);
i++;
}
}
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
glUseProgram(shaderProgram);
- std::for_each( particles.begin(), particles.end(), [](Particles &part) { part.draw(); });
+ std::for_each(particles.begin(), particles.end(), [](Particles &part) { part.draw(); });
glUseProgram(0);
- /*for ( auto &part : particles )
+ /*for (auto &part : particles)
part.draw();*/
- for ( auto &e : entity )
+ for (auto &e : entity)
e->draw();
p->draw();
mmob = m;
mmob->aggressive = false;
- mob.push_back(m);
- entity.push_back(m);
+ mob.push_back(*m);
+ entity.push_back(&mob.back());
battleNest.push_back(leave);
battleNestLoc.push_back(p->loc);
World *Arena::exitArena(Player *p){
World *tmp;
- if ( !mmob->alive &&
- p->loc.x + p->width / 2 > mob[0]->loc.x &&
- p->loc.x + p->width / 2 < mob[0]->loc.x + HLINE * 12 ) {
+ if (!mmob->alive &&
+ p->loc.x + p->width / 2 > mob[0].loc.x &&
+ p->loc.x + p->width / 2 < mob[0].loc.x + HLINE * 12) {
tmp = battleNest.front();
battleNest.erase(battleNest.begin());
}
}
-std::string getWorldWeatherStr( WorldWeather ww )
+std::string getWorldWeatherStr(WorldWeather ww)
{
- switch ( ww ) {
+ switch (ww) {
case WorldWeather::Sunny:
return "Sunny";
break;
static bool loadedRight = false;
World *loadWorldFromXML(std::string path){
- if ( !currentXML.empty() )
+ if (!currentXML.empty())
currentWorld->save();
return loadWorldFromXMLNoSave(path);
}
-World *loadWorldFromPtr( World *ptr )
+World *loadWorldFromPtr(World *ptr)
{
World *tmp = ptr;
loadedLeft = true;
- currentWorldToLeft = loadWorldFromXML( tmp->toLeft );
+ currentWorldToLeft = loadWorldFromXML(tmp->getToLeft());
loadedLeft = false;
loadedRight = true;
- currentWorldToRight = loadWorldFromXML( tmp->toRight );
+ currentWorldToRight = loadWorldFromXML(tmp->getToRight());
loadedRight = false;
return tmp;
*/
World *
-loadWorldFromXMLNoSave( std::string path ) {
+loadWorldFromXMLNoSave(std::string path) {
XMLDocument xml;
XMLElement *wxml;
XMLElement *vil;
std::string name, sptr;
// no file? -> no world
- if ( path.empty() )
+ if (path.empty())
return NULL;
currentXML = std::string(xmlFolder + path);
- xml.LoadFile( currentXML.c_str() );
+ xml.LoadFile(currentXML.c_str());
// attempt to load a <World> tag
- if ( (wxml = xml.FirstChildElement("World")) ) {
+ if ((wxml = xml.FirstChildElement("World"))) {
wxml = wxml->FirstChildElement();
vil = xml.FirstChildElement("World")->FirstChildElement("village");
tmp = new World();
}
// attempt to load an <IndoorWorld> tag
- else if( (wxml = xml.FirstChildElement("IndoorWorld")) ) {
+ else if((wxml = xml.FirstChildElement("IndoorWorld"))) {
wxml = wxml->FirstChildElement();
vil = NULL;
tmp = new IndoorWorld();
UserError("XML Error: Cannot find a <World> or <IndoorWorld> tag in " + currentXML + "!");
// iterate through world tags
- while ( wxml ) {
+ while (wxml) {
name = wxml->Name();
// world linkage
- if ( name == "link" ) {
+ if (name == "link") {
// links world to the left
- if ( (ptr = wxml->Attribute("left")) ) {
- tmp->setToLeft( ptr );
+ if ((ptr = wxml->Attribute("left"))) {
+ tmp->setToLeft(ptr);
// load the left world if it isn't
- if ( !loadedLeft ) {
+ if (!loadedLeft) {
loadedLeft = true;
- currentWorldToLeft = loadWorldFromXMLNoSave( ptr );
+ currentWorldToLeft = loadWorldFromXMLNoSave(ptr);
loadedLeft = false;
}
}
// links world to the right
- else if ( (ptr = wxml->Attribute("right")) ) {
- tmp->setToRight( ptr );
+ else if ((ptr = wxml->Attribute("right"))) {
+ tmp->setToRight(ptr);
// load the right world if it isn't
- if ( !loadedRight ) {
+ if (!loadedRight) {
loadedRight = true;
- currentWorldToRight = loadWorldFromXMLNoSave( ptr );
+ currentWorldToRight = loadWorldFromXMLNoSave(ptr);
loadedRight = false;
}
}
// tells what world is outside, if in a structure
- else if ( Indoor && (ptr = wxml->Attribute("outside")) )
- inside.push_back( ptr );
+ else if (Indoor && (ptr = wxml->Attribute("outside")))
+ inside.push_back(ptr);
// error, invalid link tag
else
}
// style tags
- else if ( name == "style" ) {
+ else if (name == "style") {
// set style folder
- tmp->setStyle( wxml->StrAttribute("folder") );
+ tmp->setStyle(wxml->StrAttribute("folder"));
// set background folder
- if ( wxml->QueryUnsignedAttribute("background", &flooor) != XML_NO_ERROR )
+ if (wxml->QueryUnsignedAttribute("background", &flooor) != XML_NO_ERROR)
UserError("XML Error: No background given in <style> in " + currentXML + "!");
- tmp->setBackground( (WorldBGType)flooor );
+ tmp->setBackground((WorldBGType)flooor);
// set BGM file
- tmp->setBGM( wxml->StrAttribute("bgm") );
+ tmp->setBGM(wxml->StrAttribute("bgm"));
}
// world generation (for outdoor areas)
- else if ( name == "generation" ) {
+ else if (name == "generation") {
// random gen.
- if ( !Indoor && wxml->StrAttribute("type") == "Random" )
- tmp->generate( wxml->UnsignedAttribute("width") );
+ if (!Indoor && wxml->StrAttribute("type") == "Random")
+ tmp->generate(wxml->UnsignedAttribute("width"));
else {
- if ( Indoor )
+ if (Indoor)
UserError("XML Error: <generation> tags can't be in <IndoorWorld> tags (in " + currentXML + ")!");
else
UserError("XML Error: Invalid <generation> tag in " + currentXML + "!");
}
// mob creation
- else if ( name == "mob" ) {
+ else if (name == "mob") {
// type info
- if ( wxml->QueryUnsignedAttribute("type", &flooor) != XML_NO_ERROR )
+ if (wxml->QueryUnsignedAttribute("type", &flooor) != XML_NO_ERROR)
UserError("XML Error: Invalid type value in <mob> in " + currentXML + "!");
// spawn at coordinate if desired
- if ( wxml->QueryFloatAttribute( "x", &spawnx ) == XML_NO_ERROR )
- tmp->addMob( flooor, spawnx, wxml->FloatAttribute("y"));
+ if (wxml->QueryFloatAttribute("x", &spawnx) == XML_NO_ERROR)
+ tmp->addMob(flooor, spawnx, wxml->FloatAttribute("y"));
else
- tmp->addMob( flooor, 0, 100 );
+ tmp->addMob(flooor, 0, 100);
// aggressive tag
- if ( wxml->QueryBoolAttribute( "aggressive", &dialog ) == XML_NO_ERROR )
- tmp->mob.back()->aggressive = dialog;
+ if (wxml->QueryBoolAttribute("aggressive", &dialog) == XML_NO_ERROR)
+ tmp->getLastMob()->aggressive = dialog;
// indoor spawning floor selection
- if ( Indoor && wxml->QueryUnsignedAttribute( "floor", &flooor ) == XML_NO_ERROR )
- Indoorp(tmp)->moveToFloor( tmp->npc.back(), flooor );
+ if (Indoor && wxml->QueryUnsignedAttribute("floor", &flooor) == XML_NO_ERROR)
+ Indoorp(tmp)->moveToFloor(tmp->npc.back(), flooor);
// custom health value
- if ( wxml->QueryFloatAttribute( "health", &spawnx) == XML_NO_ERROR )
- tmp->mob.back()->health = tmp->mob.back()->maxHealth = spawnx;
+ if (wxml->QueryFloatAttribute("health", &spawnx) == XML_NO_ERROR)
+ tmp->getLastMob()->health = tmp->getLastMob()->maxHealth = spawnx;
}
// npc creation
- else if ( name == "npc" ) {
+ else if (name == "npc") {
const char *npcname;
// spawn at coordinates if desired
- if ( wxml->QueryFloatAttribute( "x", &spawnx ) == XML_NO_ERROR)
- tmp->addNPC( spawnx, 100 );
+ if (wxml->QueryFloatAttribute("x", &spawnx) == XML_NO_ERROR)
+ tmp->addNPC(spawnx, 100);
else
- tmp->addNPC( 0, 100 );
+ tmp->addNPC(0, 100);
// name override
- if ( (npcname = wxml->Attribute("name")) ) {
+ if ((npcname = wxml->Attribute("name"))) {
delete[] tmp->npc.back()->name;
tmp->npc.back()->name = new char[strlen(npcname) + 1];
- strcpy( tmp->npc.back()->name, npcname );
+ strcpy(tmp->npc.back()->name, npcname);
}
// dialog enabling
dialog = false;
- if ( wxml->QueryBoolAttribute( "hasDialog", &dialog ) == XML_NO_ERROR && dialog )
- tmp->npc.back()->addAIFunc( commonAIFunc, false );
+ if (wxml->QueryBoolAttribute("hasDialog", &dialog) == XML_NO_ERROR && dialog)
+ tmp->npc.back()->addAIFunc(commonAIFunc, false);
else
tmp->npc.back()->dialogIndex = 9999;
- if ( Indoor && wxml->QueryUnsignedAttribute( "floor", &flooor ) == XML_NO_ERROR )
- Indoorp(tmp)->moveToFloor( tmp->npc.back(), flooor );
+ if (Indoor && wxml->QueryUnsignedAttribute("floor", &flooor) == XML_NO_ERROR)
+ Indoorp(tmp)->moveToFloor(tmp->npc.back(), flooor);
// custom health value
- if ( wxml->QueryFloatAttribute( "health", &spawnx) == XML_NO_ERROR )
- tmp->mob.back()->health = tmp->mob.back()->maxHealth = spawnx;
+ if (wxml->QueryFloatAttribute("health", &spawnx) == XML_NO_ERROR)
+ tmp->npc.back()->health = tmp->npc.back()->maxHealth = spawnx;
}
// structure creation
- else if ( name == "structure" ) {
- tmp->addStructure( (BUILD_SUB) wxml->UnsignedAttribute("type"),
- wxml->QueryFloatAttribute( "x", &spawnx ) != XML_NO_ERROR ?
+ else if (name == "structure") {
+ tmp->addStructure((BUILD_SUB) wxml->UnsignedAttribute("type"),
+ wxml->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ?
getRand() % tmp->getTheWidth() / 2.0f : spawnx,
100,
wxml->StrAttribute("texture"),
wxml->StrAttribute("inside")
- );
- } else if ( name == "trigger" ) {
- tmp->addMob( MS_TRIGGER, wxml->FloatAttribute("x"), 0, commonTriggerFunc );
- tmp->mob.back()->heyid = wxml->Attribute("id");
- } else if ( name == "page" ) {
- tmp->addMob( MS_PAGE, wxml->FloatAttribute("x"), 0, commonPageFunc );
- tmp->mob.back()->heyid = wxml->Attribute("id");
- } else if ( name == "hill" ) {
- tmp->addHill( ivec2 { wxml->IntAttribute("peakx"), wxml->IntAttribute("peaky") }, wxml->UnsignedAttribute("width") );
- } else if ( name == "time" ) {
- tickCount = std::stoi( wxml->GetText() );
- } else if ( Indoor && name == "floor" ) {
- if ( wxml->QueryFloatAttribute("start",&spawnx) == XML_NO_ERROR )
- Indoorp(tmp)->addFloor( wxml->UnsignedAttribute("width"), spawnx );
+ );
+ } else if (name == "trigger") {
+ tmp->addMob(MS_TRIGGER, wxml->FloatAttribute("x"), 0, commonTriggerFunc);
+ tmp->getLastMob()->heyid = wxml->Attribute("id");
+ } else if (name == "page") {
+ tmp->addMob(MS_PAGE, wxml->FloatAttribute("x"), 0, commonPageFunc);
+ tmp->getLastMob()->heyid = wxml->Attribute("id");
+ } else if (name == "hill") {
+ tmp->addHill(ivec2 { wxml->IntAttribute("peakx"), wxml->IntAttribute("peaky") }, wxml->UnsignedAttribute("width"));
+ } else if (name == "time") {
+ tickCount = std::stoi(wxml->GetText());
+ } else if (Indoor && name == "floor") {
+ if (wxml->QueryFloatAttribute("start",&spawnx) == XML_NO_ERROR)
+ Indoorp(tmp)->addFloor(wxml->UnsignedAttribute("width"), spawnx);
else
- Indoorp(tmp)->addFloor( wxml->UnsignedAttribute("width") );
+ Indoorp(tmp)->addFloor(wxml->UnsignedAttribute("width"));
}
spawnx = 0;
Village *vptr;
- if(vil){
- tmp->village.push_back(new Village(vil->Attribute("name"), tmp));
- vptr = tmp->village.back();
-
+ if (vil) {
+ vptr = tmp->addVillage(vil->Attribute("name"), tmp);
vil = vil->FirstChildElement();
}
* READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE
*/
- if ( name == "structure" ) {
+ if (name == "structure") {
tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"),
vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? randx : spawnx,
100,
vil->StrAttribute("texture"),
vil->StrAttribute("inside"));
- } else if ( name == "stall" ) {
+ } else if (name == "stall") {
sptr = vil->StrAttribute("type");
// handle markets
- if ( sptr == "market" ) {
+ if (sptr == "market") {
// create a structure and a merchant, and pair them
- tmp->addStructure( STALL_MARKET,
+ tmp->addStructure(STALL_MARKET,
vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? randx : spawnx,
100,
vil->StrAttribute("texture"),
vil->StrAttribute("inside")
- );
- tmp->addMerchant( 0, 100 );
+ );
+ tmp->addMerchant(0, 100);
tmp->merchant.back()->inside = tmp->build.back();
}
// handle traders
- else if ( sptr == "trader") {
- tmp->addStructure( STALL_TRADER,
+ else if (sptr == "trader") {
+ tmp->addStructure(STALL_TRADER,
vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? randx : spawnx,
100,
vil->StrAttribute("texture"),
vil->StrAttribute("inside")
- );
+ );
}
// loop through buy/sell/trade tags
XMLElement *sxml = vil->FirstChildElement();
std::string tag;
- while ( sxml ) {
+ while (sxml) {
tag = sxml->Name();
- if ( tag == "buy" ) {
+ if (tag == "buy") {
// TODO
- } else if ( tag == "sell" ) {
+ } else if (tag == "sell") {
// TODO
- } else if ( tag == "trade" ) {
- tmp->merchant.back()->trade.push_back( Trade( sxml->IntAttribute("quantity"),
+ } else if (tag == "trade") {
+ tmp->merchant.back()->trade.push_back(Trade(sxml->IntAttribute("quantity"),
sxml->StrAttribute("item"),
sxml->IntAttribute("quantity1"),
sxml->StrAttribute("item1")
- ));
+ ));
}
sxml = sxml->NextSiblingElement();