Suggestion
For extensibility & easy manipulation of data.
RIFF[len:4byte]STRx
PTR (string pointer)[len:4byte][String pointer data.]
DATA(string data)[len:4byte][String data. array of null terminated strings]
// + additional datas.
//ex ) CDIF (Chkdraft Information) [len:4byte] [chkdraft-exclusive things...]
Inner format of PTR
struct PtrChunk {
uint32 auto_inc_id_generator; //generates id
struct StringPointerData {
uint32 id; //id of string pointer
uint32 ref; //How many has pointer been referenced?
int strid;
} strptr[?]
}
uint32 auto_inc_id_generator; //generates id
struct StringPointerData {
uint32 id; //id of string pointer
uint32 ref; //How many has pointer been referenced?
int strid;
} strptr[?]
}
Inner format of DATA
struct DataChunk {
struct String {
// reference counting of indivisual strings are done in load time.
// int ref = sum( ref of string pointer pointing to this string )
char szString[?];
} str[?]
}
struct String {
// reference counting of indivisual strings are done in load time.
// int ref = sum( ref of string pointer pointing to this string )
char szString[?];
} str[?]
}
interface :
Interface prototype?
class StringTable {
typedef int StringPointer; //can be saved.
// 1 stringpointer <-> 1 stringpointerdata
// n stringpointer <-> 1 string (for string recycling)
load(const buffer &buf); //or sort of
save(buffer &buf);
StringPointer addstring(const std::string& str); //creates new string pointer and returns pointer id.
int changeString(StringPointer strptr, const std::string &newval); // change string. This may change StringPointerData (not strptr)
int deleteString(StringPointer &strptr); // unref string pointer. for safety, strpointer is set to -1.
};
typedef int StringPointer; //can be saved.
// 1 stringpointer <-> 1 stringpointerdata
// n stringpointer <-> 1 string (for string recycling)
load(const buffer &buf); //or sort of
save(buffer &buf);
StringPointer addstring(const std::string& str); //creates new string pointer and returns pointer id.
int changeString(StringPointer strptr, const std::string &newval); // change string. This may change StringPointerData (not strptr)
int deleteString(StringPointer &strptr); // unref string pointer. for safety, strpointer is set to -1.
};
StringData, StringPointerData are managed internally by StringTable.
User should use only StringPointer.
Post has been edited 1 time(s), last time on Sep 24 2013, 2:33 am by trgk.
EUD