00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _terimber_strrep_h_
00029 #define _terimber_strrep_h_
00030
00031 #include "../base/ns.h"
00032 #include "../base/list.h"
00033 #include "../base/map.h"
00034 #include "../base/string.h"
00035
00036 BEGIN_TERIMBER_NAMESPACE
00037
00038
00039
00040
00041
00042
00043 template < unsigned char N >
00044 class backet_tank
00045 {
00046 typedef ub8_t rooms_type_t;
00047 public:
00048 enum BACKET { LENGTH = (1<<N) + 4, ROOMS = 8*sizeof(rooms_type_t) };
00049
00050 backet_tank(byte_allocator& all);
00051
00052 inline bool full() const;
00053 inline bool empty() const ;
00054 inline char* get_chunk();
00055 inline void put_chunk(char* ptr);
00056 inline void reset();
00057
00058 private:
00059 char* _head;
00060 rooms_type_t _states;
00061 };
00062
00063 template < unsigned char N, int M >
00064 class string_backet
00065 {
00066 public:
00067 string_backet();
00068 ~string_backet();
00069
00070 inline char* allocate();
00071 inline void deallocate(char* ptr);
00072 inline void reset();
00073 inline void release();
00074
00075 private:
00076 byte_allocator _all;
00077 backet_tank< N >* _pages[M];
00078 int _page;
00079 };
00080
00081 class string_repository
00082 {
00083 public:
00084 inline char* allocate(size_t len);
00085 inline void deallocate(char* ptr);
00086
00087 private:
00088 string_backet< 4, 64*1024 > _backet4;
00089 string_backet< 5, 32*1024 > _backet5;
00090 string_backet< 6, 16*1024 > _backet6;
00091 string_backet< 7, 8*1024 > _backet7;
00092 string_backet< 8, 4*1024 > _backet8;
00093 string_backet< 9, 2*1024 > _backet9;
00094 string_backet< 10, 1*1024 > _backet10;
00095 string_backet< 11, 512 > _backet11;
00096 string_backet< 12, 256 > _backet12;
00097 string_backet< 13, 128 > _backet13;
00098 };
00099
00100
00101 END_TERIMBER_NAMESPACE
00102
00103 #endif // _terimber_strrep_h_