/*
Original code by Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml2.h"
#include <new> // yes, this one new style header, is in the Android SDK.
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
# include <stddef.h>
# include <stdarg.h>
#else
# include <cstddef>
# include <cstdarg>
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
// Microsoft Visual Studio, version 2005 and higher. Not WinCE.
/*int _snprintf_s(
char *buffer,
size_t sizeOfBuffer,
size_t count,
const char *format [,
argument] ...
);*/
static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
{
va_list va;
va_start( va, format );
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
va_end( va );
return result;
}
static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
{
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
return result;
}
#define TIXML_VSCPRINTF _vscprintf
#define TIXML_SSCANF sscanf_s
#elif defined _MSC_VER
// Microsoft Visual Studio 2003 and earlier or WinCE
#define TIXML_SNPRINTF _snprintf
#define TIXML_VSNPRINTF _vsnprintf
#define TIXML_SSCANF sscanf
#if (_MSC_VER < 1400 ) && (!defined WINCE)
// Microsoft Visual Studio 2003 and not WinCE.
#define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
#else
// Microsoft Visual Studio 2003 and earlier or WinCE.
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
{
int len = 512;
for (;;) {
len = len*2;
char* str = new char[len]();
const int required = _vsnprintf(str, len, format, va);
delete[] str;
if ( required != -1 ) {
TIXMLASSERT( required >= 0 );
len = required;
break;
}
}
TIXMLASSERT( len >= 0 );
return len;
}
#endif
#else
// GCC version 3 and higher
//#warning( "Using sn* functions." )
#define TIXML_SNPRINTF snprintf
#define TIXML_VSNPRINTF vsnprintf
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
{
int len = vsnprintf( 0, 0, format, va );
TIXMLASSERT( len >= 0 );
return len;
}
#define TIXML_SSCANF sscanf
#endif
static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
static const char LF = LINE_FEED;
static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
static const char CR = CARRIAGE_RETURN;
static const char SINGLE_QUOTE = '\'';
static const char DOUBLE_QUOTE = '\"';
// Bunch of unicode info at:
// http://www.unicode.org/faq/utf_bom.html
// ef bb bf (Microsoft "lead bytes") - designates UTF-8
static const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
namespace tinyxml2
{
struct Entity {
const char* pattern;
int length;
char value;
};
static const int NUM_ENTITIES = 5;
static const Entity entities[NUM_ENTITIES] = {
{ "quot", 4, DOUBLE_QUOTE },
{ "amp", 3, '&' },
{ "apos", 4, SINGLE_QUOTE },
{ "lt", 2, '<' },
{ "gt", 2, '>' }
};
StrPair::~StrPair()
{
Reset();
}
void StrPair::TransferTo( StrPair* other )
{
if ( this == other ) {
return;
}
// This in effect implements the assignment operator by "moving"
// ownership (as in auto_ptr).
TIXMLASSERT( other != 0 );
TIXMLASSERT( other->_flags == 0 );
TIXMLASSERT( other->_start == 0 );
TIXMLASSERT( other->_end == 0 );
other->Reset();
other->_flags = _flags;
other->_start = _start;
other->_end = _end;
_flags = 0;
_start = 0;
_end = 0;
}
void StrPair::Reset()
{
if ( _flags & NEEDS_DELETE ) {
delete [] _start;
}
_flags = 0;
_start = 0;
_end = 0;
}
void StrPair::SetStr( const char* str, int flags )
{
TIXMLASSERT( str );
Reset();
size_t len = strlen( str );
TIXMLASSERT( _start == 0 );
_start = new char[ len+1 ];
memcpy( _start, str, len+1 );
_end = _start + len;
_flags = flags | NEEDS_DELETE;
}
char* StrPair::ParseText( char* p, const char* endTag, int strFlags, int* curLineNumPtr )
{
TIXMLASSERT( p );
TIXMLASSERT( endTag && *endTag );
TIXMLASSERT(curLineNumPtr);
char* start = p;
char endChar = *endTag;
size_t length = strlen( endTag );
// Inner loop of text parsing.
while ( *p ) {
if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
Set( start, p, strFlags );
return p + length;
} else if (*p == '\n') {
++(*curLineNumPtr);
}
++p;
TIXMLASSERT( p );
}
return 0;
}
char* StrPair::ParseName( char* p )
{
if ( !p || !(*p) ) {
return 0;
}
if ( !XMLUtil::IsNameStartChar( *p ) ) {
return 0;
}
char* const start = p;
++p;
while ( *p && XMLUtil::IsNameChar( *p ) ) {
++p;
}
Set( start, p, 0 );
return p;
}
void StrPair::CollapseWhitespace()
{
// Adjusting _start would cause undefined behavior on delete[]
TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 );
// Trim leading space.
_start = XMLUtil::SkipWhiteSpace( _start, 0 );
if ( *_start ) {
const char* p = _start; // the read pointer
char* q = _start; // the write pointer
while( *p ) {
if ( XMLUtil::IsWhiteSpace( *p )) {
p = XMLUtil::SkipWhiteSpace( p, 0 );
if ( *p == 0 ) {
break; // don't write to q; this trims the trailing space.
}
*q = ' ';
++q;
}
*q = *p;
++q;
++p;
}
*q = 0;
}
}
const char* StrPair::GetStr()
{
TIXMLASSERT( _start );
TIXMLASSERT( _end );
if ( _flags & NEEDS_FLUSH ) {
*_end = 0;
_flags ^= NEEDS_FLUSH;
if ( _flags ) {
const char* p = _start; // the read pointer
char* q = _start; // the write pointer
while( p < _end ) {
if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
// CR-LF pair becomes LF
// CR alone becomes LF
// LF-CR becomes LF
if ( *(p+1) == LF ) {
p += 2;
}
else {
++p;
}
*q = LF;
++q;
}
else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
if ( *(p+1) == CR ) {
p += 2;
}
else {
++p;
}
*q = LF;
++q;
}
else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
// Entities handled by tinyXML2:
// - special entities in the entity table [in/out]
// - numeric character refe
没有合适的资源?快使用搜索试试~ 我知道了~
C++游戏引擎(SkyGameEngine2d)
共1469个文件
html:867个
png:230个
h:131个
需积分: 0 3 下载量 25 浏览量
2023-07-27
17:05:58
上传
评论
收藏 11.71MB ZIP 举报
温馨提示
C++游戏引擎是一个软件框架,用于开发和构建计算机游戏。它提供了一系列的工具、函数库和功能,以便开发者可以方便地创建、设计和管理游戏。 以下是对C++游戏引擎的描述,不包含具体的代码实现: 渲染引擎:游戏引擎通常会包含一个强大的渲染引擎,用于处理图形渲染、光照、材质等方面的任务。它能够将开发者创建的场景、角色和特效以视觉化的方式呈现在屏幕上。 物理引擎:游戏中的物理模拟通常由物理引擎负责处理。这些引擎可以模拟现实世界中的物理规则,如碰撞检测、重力、摩擦力等,从而使游戏对象之间的交互更加真实和可靠。 输入管理:游戏引擎提供了输入管理功能,以便获取玩家的输入信息,如键盘、鼠标、控制器等。通过处理这些输入,开发者可以实现游戏中的交互和控制。 音频引擎:为了增强游戏的沉浸感和体验,游戏引擎通常会包含一个音频引擎,用于处理音效和背景音乐。它可以播放、混合和控制各种音频资源,并提供音频特效和空间音频等功能。 场景管理:游戏引擎提供了场景管理功能,以便开发者可以创建、加载和管理不同的游戏场景。这些场景可以是游戏中的关卡、菜单、过渡界面等,引擎可以帮助开发者进行场景之间的切换和管理。 资
资源推荐
资源详情
资源评论
收起资源包目录
C++游戏引擎(SkyGameEngine2d) (1469个子文件)
tinyxml2.cpp 69KB
MainPlayer.cpp 38KB
WICTextureLoader.cpp 34KB
Monster.cpp 20KB
_Render.cpp 19KB
Widget.cpp 16KB
Color.cpp 16KB
GameLevelScene.cpp 14KB
LineEdit.cpp 11KB
InputEventDispatcher.cpp 9KB
Sprite.cpp 9KB
Node.cpp 9KB
ProgramStateCache.cpp 8KB
Animate.cpp 8KB
Scale9Image.cpp 7KB
AbstractButton.cpp 7KB
ActionInterval.cpp 7KB
Scheduler.cpp 7KB
GameWorld.cpp 7KB
Application.cpp 6KB
MonsterState.cpp 6KB
ActionManager.cpp 6KB
Matrix.cpp 6KB
UiCore.cpp 5KB
Font.cpp 5KB
_AudioPlayer.cpp 5KB
Game.cpp 5KB
ApplicationView.cpp 5KB
StartScene.cpp 4KB
ProgressBar.cpp 4KB
GameOverWidget.cpp 4KB
Vector.cpp 4KB
PushButton.cpp 4KB
Label.cpp 4KB
CheckBox.cpp 4KB
SpriteFrame.cpp 4KB
SpriteFrameCache.cpp 3KB
Geometry.cpp 3KB
AudioManager.cpp 3KB
Camera.cpp 3KB
Text.cpp 3KB
ProgramCache.cpp 3KB
ListWidget.cpp 3KB
Program.cpp 3KB
LogoScene.cpp 3KB
TrianglesCommand.cpp 3KB
RenderQueue.cpp 3KB
EventManager.cpp 2KB
TextCommand.cpp 2KB
Rect.cpp 2KB
TestScene.cpp 2KB
Texture2D.cpp 2KB
Action.cpp 2KB
Scene.cpp 2KB
Line.cpp 2KB
Scale9ImageCommand.cpp 2KB
EventListenerMouse.cpp 2KB
DefultWidget.cpp 2KB
utility.cpp 2KB
ActionInstant.cpp 2KB
GameAppDelegate.cpp 2KB
StringUtility.cpp 2KB
GameAppDelegate.cpp 2KB
Debuger.cpp 2KB
EventListenerKeyboard.cpp 2KB
EventMouse.cpp 2KB
GameAppDelegate.cpp 2KB
GameAppDelegate.cpp 2KB
Material.cpp 2KB
Size.cpp 2KB
GeometryCommand.cpp 1KB
ResourceHelper.cpp 1KB
TextureCache.cpp 1KB
InputEventListener.cpp 1KB
TestScene.cpp 1KB
EventWidgetActive.cpp 1KB
main.cpp 1KB
TestScene.cpp 1KB
main.cpp 1KB
main.cpp 1KB
main.cpp 1KB
EventWidgetMove.cpp 1KB
EventResize.cpp 1KB
EventKey.cpp 1KB
CustomCommand.cpp 1KB
MouseCursor.cpp 1KB
InputEvent.cpp 1KB
EventFocus.cpp 1KB
CharacterEvent.cpp 1KB
Event.cpp 1KB
Shaders.cpp 995B
RenderCommand.cpp 924B
SkyGameEngine.cpp 793B
QuadCommand.cpp 703B
main.cpp 628B
Exp_singleton.cpp 596B
MapDate.cpp 174B
IApplicationView.cpp 37B
ProgramState.cpp 0B
EngineEvent.cpp 0B
共 1469 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
童小纯
- 粉丝: 3w+
- 资源: 289
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功