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 #pragma warning( disable : 4530 )
00028 #pragma warning( disable : 4786 )
00029 #include <string>
00030
00031 #include "../util/gltypes.h"
00032 #include "../util/gllist.h"
00033 #include "SDL_endian.h"
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 class GlNameField
00054 {
00055 public:
00056
00057 GlNameField();
00058 ~GlNameField() {}
00059
00060
00061 void Add( const std::string& sentance );
00062
00063
00064 void Calc();
00065
00066
00067 bool Get( const std::string& sentance, U32* value ) const;
00068
00069
00070 void WriteHeader( FILE* text, const char* prefix );
00071
00072 private:
00073 enum
00074 {
00075 MAX_BUCKET = 32
00076 };
00077
00078 bool calcComplete;
00079 int numBucket;
00080 int bitWidth[ MAX_BUCKET ];
00081 int shift[ MAX_BUCKET ];
00082
00083 GlSList< std::string > bucket[ MAX_BUCKET ];
00084 };
00085
00086
00087 class KrCachedWrite
00088 {
00089 public:
00090
00091 KrCachedWrite( SDL_RWops* _stream ) { stream = _stream; }
00092 ~KrCachedWrite() {}
00093
00094
00095
00096 void Write( const std::string& value );
00097
00098
00099 void Flush();
00100
00101
00102 void WriteHeader( FILE* text, const char* prefix );
00103
00104 private:
00105 struct Data
00106 {
00107 U32 pos;
00108 std::string value;
00109
00110 bool operator==( const Data& rhs ) { return value == rhs.value && pos == rhs.pos; }
00111 };
00112 GlNameField nameField;
00113 GlSList< Data > list;
00114 SDL_RWops* stream;
00115 };
00116
00117
00118 #endif
00119