00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef GLNAMEFIELD_INCLUDED
00025 #define GLNAMEFIELD_INCLUDED
00026
00027 #ifdef _MSC_VER
00028 #pragma warning( disable : 4530 )
00029 #pragma warning( disable : 4786 )
00030 #endif
00031
00032 #include <string>
00033
00034 #include "../../grinliz/gltypes.h"
00035 #include "../util/gllist.h"
00036 #include "SDL_endian.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 class GlNameField
00057 {
00058 public:
00059
00060 GlNameField();
00061 ~GlNameField() {}
00062
00063
00064 void Add( const std::string& sentance );
00065
00066
00067 void Calc();
00068
00069
00070 bool Get( const std::string& sentance, U32* value ) const;
00071
00072
00073 void WriteHeader( FILE* text, const char* prefix );
00074
00075 private:
00076 enum
00077 {
00078 MAX_BUCKET = 32
00079 };
00080
00081 bool calcComplete;
00082 int numBucket;
00083 int bitWidth[ MAX_BUCKET ];
00084 int shift[ MAX_BUCKET ];
00085
00086 GlSList< std::string > bucket[ MAX_BUCKET ];
00087 };
00088
00089
00090 class KrCachedWrite
00091 {
00092 public:
00093
00094 KrCachedWrite( SDL_RWops* _stream ) { stream = _stream; }
00095 ~KrCachedWrite() {}
00096
00097
00098
00099 void Write( const std::string& value );
00100
00101
00102 void Flush();
00103
00104
00105 void WriteHeader( FILE* text, const char* prefix );
00106
00107 private:
00108 struct Data
00109 {
00110 U32 pos;
00111 std::string value;
00112
00113 bool operator==( const Data& rhs ) { return value == rhs.value && pos == rhs.pos; }
00114 };
00115 GlNameField nameField;
00116 GlSList< Data > list;
00117 SDL_RWops* stream;
00118 };
00119
00120
00121 #endif
00122