1.友元类 TiXmlNode,TiXmlElement,TiXmlDocument为TiXmlBase的友元类
2虚析构函数 virtual ~TiXmlBase()
3纯虚函数 virtual void Print( FILE* cfile, int depth ) const = 0; Parse();
4静态函数 static void SetCondenseWhiteSpace( bool condense )// 使用了static变量;公共方法,方便外面直接调用
5静态变量 static bool condenseWhiteSpace;
6static成员变量初始化:在.cpp中bool TiXmlBase::condenseWhiteSpace = true; 注意:语句前面不能加static
7静态常量成员变量static const int utf8ByteTable[256];
8静态常量成员变量初始化:在.cpp中const int TiXmlBase::utf8ByteTable[256] = {1,..,1};,注意const不能少
9不能改变类内成员变量的成员函数 int Row() const
10返回值值不能改变并且不能改变类内成员变量的成员函数const void* GetUserData() const
11const连续用即形参指针+返回值+成员函数内部不允许修改const TiXmlNode* FirstChild( const char * value ) const;
12返回值为引用常量const TIXML_STRING& ValueTStr() const
13类内定义结构体
struct Entity
{ const char* str;
unsigned int strLength;
char chr;
};
14类内定义无名枚举enum { TIXML_NO_ERROR = 0,};可以在本类成员函数中或子类成员函数中直接使用,在类外,与调用类
的公有成员变量相同,通过对象直接调用名称
15类外定义无名枚举
enum { TIXML_SUCCESS, TIXML_NO_ATTRIBUTE, TIXML_WRONG_TYPE};,其他处直接使用值,如TIXML_SUCCESS,但不能定义变量
16类内有名枚举,如
class a{
enum TiXmlEncoding{ TIXML_ENCODING_UNKNOWN, TIXML_ENCODING_UTF8, TIXML_ENCODING_LEGACY};};
与调用类的静态成员变量相同,通过类名直接调用,如a::TiXmlEncoding b=TIXML_ENCODING_UNKNOWN;
17内联函数inline static bool IsWhiteSpace( char c )
18类内预定义
#ifdef TIXML_USE_STL
static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
#endif
19#if a // a为表达式
#endif
20#ifdef a// a为#define定义的类型
#endif
21#if defined(a)// a为#define定义的类型
#endif
22#ifdef #endif使用处:区分头文件,函数是否需要声明,对应宏定义的函数声明的实现,在函数内部用于判断调用哪个函数
23#ifndef 2个使用方法:
其后只有一条语句,可以不用#endif结尾
ex1:
#ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED
ex2:
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
如果有多语句,必须用#endif结尾
#ifndef DECLSPEC_NORETURN
#if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
#define DECLSPEC_NORETURN __declspec(noreturn)
#else
#define DECLSPEC_NORETURN
#endif
#endif
24虚函数virtual TiXmlNode* Clone() const;
25虚函数使用用处:
虚析构,虚成员函数
26默认参数bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding =
TIXML_DEFAULT_ENCODING );
27全局常量const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
28调用复制构造函数的3个方法:对象作为形参 用已存在的对象初始化另一对象 函数返回值为对象,如dd abc(dd a);其中dd为类,因形参
和返回值都为类对象,会调用2次复制构造函数。 dd d;dd m = d; // 相当于dd m(d);
29复制构造函数TiXmlBase( const TiXmlBase& ); 格式:类名(const 类名& a);
30赋值函数void operator=( const TiXmlBase& base );格式:类名& operator=(const 类名& a);
2虚析构函数 virtual ~TiXmlBase()
3纯虚函数 virtual void Print( FILE* cfile, int depth ) const = 0; Parse();
4静态函数 static void SetCondenseWhiteSpace( bool condense )// 使用了static变量;公共方法,方便外面直接调用
5静态变量 static bool condenseWhiteSpace;
6static成员变量初始化:在.cpp中bool TiXmlBase::condenseWhiteSpace = true; 注意:语句前面不能加static
7静态常量成员变量static const int utf8ByteTable[256];
8静态常量成员变量初始化:在.cpp中const int TiXmlBase::utf8ByteTable[256] = {1,..,1};,注意const不能少
9不能改变类内成员变量的成员函数 int Row() const
10返回值值不能改变并且不能改变类内成员变量的成员函数const void* GetUserData() const
11const连续用即形参指针+返回值+成员函数内部不允许修改const TiXmlNode* FirstChild( const char * value ) const;
12返回值为引用常量const TIXML_STRING& ValueTStr() const
13类内定义结构体
struct Entity
{ const char* str;
unsigned int strLength;
char chr;
};
14类内定义无名枚举enum { TIXML_NO_ERROR = 0,};可以在本类成员函数中或子类成员函数中直接使用,在类外,与调用类
的公有成员变量相同,通过对象直接调用名称
15类外定义无名枚举
enum { TIXML_SUCCESS, TIXML_NO_ATTRIBUTE, TIXML_WRONG_TYPE};,其他处直接使用值,如TIXML_SUCCESS,但不能定义变量
16类内有名枚举,如
class a{
enum TiXmlEncoding{ TIXML_ENCODING_UNKNOWN, TIXML_ENCODING_UTF8, TIXML_ENCODING_LEGACY};};
与调用类的静态成员变量相同,通过类名直接调用,如a::TiXmlEncoding b=TIXML_ENCODING_UNKNOWN;
17内联函数inline static bool IsWhiteSpace( char c )
18类内预定义
#ifdef TIXML_USE_STL
static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
#endif
19#if a // a为表达式
#endif
20#ifdef a// a为#define定义的类型
#endif
21#if defined(a)// a为#define定义的类型
#endif
22#ifdef #endif使用处:区分头文件,函数是否需要声明,对应宏定义的函数声明的实现,在函数内部用于判断调用哪个函数
23#ifndef 2个使用方法:
其后只有一条语句,可以不用#endif结尾
ex1:
#ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED
ex2:
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
如果有多语句,必须用#endif结尾
#ifndef DECLSPEC_NORETURN
#if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
#define DECLSPEC_NORETURN __declspec(noreturn)
#else
#define DECLSPEC_NORETURN
#endif
#endif
24虚函数virtual TiXmlNode* Clone() const;
25虚函数使用用处:
虚析构,虚成员函数
26默认参数bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding =
TIXML_DEFAULT_ENCODING );
27全局常量const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
28调用复制构造函数的3个方法:对象作为形参 用已存在的对象初始化另一对象 函数返回值为对象,如dd abc(dd a);其中dd为类,因形参
和返回值都为类对象,会调用2次复制构造函数。 dd d;dd m = d; // 相当于dd m(d);
29复制构造函数TiXmlBase( const TiXmlBase& ); 格式:类名(const 类名& a);
30赋值函数void operator=( const TiXmlBase& base );格式:类名& operator=(const 类名& a);