89class CLASS_DECL_ACME memory_base :
91 virtual public ::subparticle
95 typedef bstring_manager manager;
97 typedef ::u8 value_type;
112 memory_base(
const memory_base & base) : MEMORY(base) {}
113 memory_base(memory_base && base) : MEMORY(::transfer(base)) {}
114 ~memory_base()
override;
117 using ::subparticle::clear_flag;
118 using MEMORY::operator();
121 virtual string as_utf8()
const;
129 virtual bool begins_eat(
const BLOCK & block);
140 virtual bool ends_eat(
const BLOCK & block);
144 virtual memory detach_as_primitive_memory();
151 inline void defer_set_size(memsize sizeLarger) {
if (sizeLarger > size())
return set_size(sizeLarger); }
152 virtual void set_size(memsize dwNewLength);
153 virtual void allocate_internal(memsize dwNewLength);
155 inline void truncate(memsize sizeSmaller) {
if (sizeSmaller < size())
return set_size(sizeSmaller); }
157 virtual ::u8 * impl_alloc(memsize dwAllocation);
158 virtual ::u8 * impl_realloc(
void * pdata,memsize dwAllocation);
159 virtual void impl_free(::u8 * pdata);
161 virtual void reserve(memsize dwNewLength);
164 virtual void erase_offset();
173 virtual memsize calc_allocation(memsize size);
177 virtual void assign_file(
::file::file * pfileIn, memsize uiBufferSize = 1024 * 1024);
178 virtual void assign_entire_file(
::file::file * pfileIn, memsize uiBufferSize = 1024 * 1024);
180 virtual void append_file(
::file::file * pfileIn, memsize uiBufferSize = 1024 * 1024);
181 virtual void append_entire_file(
::file::file * pfileIn, memsize uiBufferSize = 1024 * 1024);
184 void allocate_add_up(memsize iAddUp);
187 ::subparticle_pointer clone()
override;
214 ::block & block() {
return *
this; }
215 const ::block & block()
const {
return *
this; }
217 inline bool is_set()
const {
return MEMORY::is_set(); }
218 inline bool is_empty()
const {
return MEMORY::is_empty(); }
219 inline bool has_data()
const {
return this->size() > 0; }
221 inline ::u8 operator [] (::collection::index i)
const {
return data()[i]; }
222 inline ::u8 & operator [] (::collection::index i) {
return data()[i]; }
224 inline operator const ::u8 * ()
const {
return data(); }
225 inline operator ::u8 * () {
return data(); }
227 inline operator const void * ()
const {
return data(); }
228 inline operator void * () {
return data(); }
231 template < prototype_
character CHARACTER >
232 range < CHARACTER * > get_buffer(character_count len)
241 return { p, len,
true };
246 memory_base & operator = (const ::memory_base &
memory) { assign(
memory.data(),
memory.size());
return *
this; }
247 memory_base & operator = (const ::block & block) { assign(block.data(), block.size());
return *
this; }
250 memory_base & operator += (const ::memory_base &
memory) { append(
memory.data(),
memory.size());
return *
this; }
251 memory_base & operator += (const ::block & block) { append(block.data(), block.size());
return *
this; }
254 void from_string(const ::wide_character * pwsz);
255 void from_string(const ::scoped_string & scopedstr);
256 void from_string(const ::string & str);
257 void from_string(const ::payload &
payload);
258 void append_from_string(const ::wide_character * pwsz);
259 void append_from_string(const ::scoped_string & scopedstr);
260 void append_from_string(const ::string & str);
261 void append_from_string(const ::payload &
payload);
262 void append_byte(::u8 b){ append(&b, 1);}
264 virtual string get_string()
const;
265 virtual string get_string(memsize iStart, memsize uiSize = -1)
const;
267 void delete_begin(memsize iSize);
268 void eat_begin(
const void * pdata, memsize iSize);
269 void set_data(
const void * pdata, memsize uiSize);
270 void set_at(::collection::index i,
const void * pdata, memsize uiSize);
271 void copy_from(
const memory_base * pstorage);
272 void copy_from(
const void * pdata, memsize s);
273 void copy_to(
void * pdata, memsize s)
const;
274 void set(::u8 b,memsize iStart = 0,memsize uiSize = -1);
275 void zero(memsize iStart = 0, memsize uiSize = -1);
278 void assign(const ::block & block);
279 void assign(
const void * pdata, memsize iCount);
280 void assign(
const void * pdata, memsize iStart, memsize iCount);
281 void assign(memsize iCount, uchar uch);
284 void append(const ::block & block);
285 void append(
const void * pdata, memsize iCount);
286 void append(memsize iCount, uchar uch);
287 void append(
const memory_base &
memory, memsize iStart = 0, memsize iCount = -1);
292 void splice(const ::u8 * pbMemory, memsize iCountSrc, memsize iStartDst = 0, memsize iCountDst = 0);
293 void splice(
const memory_base &
memory, memsize iStartDst = 0, memsize iCountDst = 0, memsize iStartSrc = 0, memsize iCountSrc = -1);
294 ::memory slice(memsize start, memsize count);
298 void move_and_grow(memsize offset);
299 void transfer(memsize offset,
bool bGrow =
false);
304 void to_hex(
string & str, memsize iStart = 0, memsize size = -1);
305 string to_hex(memsize iStart = 0, memsize size = -1);
306 character_count from_hex(const ::block & block);
308 void to_base64(
string & str, memsize iStart = 0, memsize size = -1);
309 string to_base64(memsize iStart = 0, memsize size = -1);
310 void from_base64(const ::scoped_string & scopedstr);
312 inline void to_asc(
string & str)
const { str.assign((const_char_pointer )data(), size()); }
313 inline string to_asc()
const {
string str; to_asc(str);
return str; }
314 inline void from_asc(const ::scoped_string & scopedstr) { assign(scopedstr.data(), scopedstr.size()); }
316 bool operator == (
const memory_base & s)
const;
317 bool operator == (
const struct block & block)
const ;
320 memory_base & reverse();
322 memory_base & prefix_der_uint_content();
323 memory_base & prefix_der_length();
324 memory_base & prefix_der_type(::i32 iType);
326 memory_base & prefix_der_uint();
327 memory_base & prefix_der_sequence();
329 memsize get_length()
const;
330 memsize length()
const;
332 inline void set_char_at_grow(character_count iChar, ::i8 ch);
335 ::u8 * find(const ::block& block, ::collection::index iStart = 0)
const;
336 ::collection::index find_index(const ::block& block, ::collection::index iStart = 0)
const;
337 ::collection::index find_index(::i8 ch, ::collection::index iStart = 0)
const;
338 ::u8* rear_find(const ::block& block, ::collection::index iStart = 0)
const;
339 ::collection::index reverse_find_index(const ::block& block, ::collection::index iStart = 0)
const;
340 ::u8* reverse_find_byte_not_in_block(const ::block& block, ::collection::index iStart = 0)
const;
341 ::collection::index reverse_find_index_of_byte_not_in_block(const ::block& block, ::collection::index iStart = 0)
const;
343 ::u8 * find_line_prefix(const ::block& blockPrefix, ::collection::index iStart = 0);
344 ::collection::index find_line_prefix_index(const ::block& blockPrefix, ::collection::index iStart = 0);
345 void patch_line_suffix(const ::block & blockPrefix, const ::block& blockSuffix, ::collection::index iStart = 0);
348#if defined(UNIVERSAL_WINDOWS) && defined(__cplusplus_winrt)
350 inline Array < uchar, 1U > ^ get_os_bytes(memsize pos = 0, memsize size = -1)
const;
351 inline ::winrt::Windows::Storage::Streams::IBuffer ^ get_os_crypt_buffer(memsize pos = 0, memsize size = -1)
const;
352 inline ::winrt::Windows::Storage::Streams::IBuffer ^ get_os_buffer(memsize pos = 0, memsize size = -1)
const;
353 inline void set_os_bytes(Array < uchar, 1U > ^ a, memsize pos = 0, memsize size = -1);
354 inline void set_os_crypt_buffer(::winrt::Windows::Storage::Streams::IBuffer ^ ibuf, memsize pos = 0, memsize size = -1);
355 inline void set_os_buffer(::winrt::Windows::Storage::Streams::IBuffer ^ ibuf, memsize pos = 0, memsize size = -1);
368 memory_base & erase(memsize pos = 0,memsize len = -1);