44struct CLASS_DECL_ACME block :
53 block(
const block & block)
55 this->m_begin = block.m_begin;
56 this->m_end = block.m_end;
59 block(
const range < ::u8 * > & range);
80 template<const_po
inter_to_prototype_
character PSZ>
83 this->m_begin = (::u8 *)(psz);
84 this->m_end = (::u8 *)(psz + ::string_safe_length(psz));
87 template<const_array_of_prototype_
character CONSTCHARACTERA>
88 block(CONSTCHARACTERA a)
90 this->m_begin = (::u8 *) (a);
91 this->m_end = (::u8 *)(&a[0] + øarray_count(a) - 1);
93 template<array_of_non_prototype_
character NONCHARACTERA>
94 block(NONCHARACTERA & a)
96 this->m_begin = (::u8 *)(a);
97 this->m_end = (::u8 *)(&a[0] + øarray_count(a));
106 template < prototype_
integral INTEGRAL >
107 block(INTEGRAL & i) : block(e_as_little_endian_block, i) {}
108 template <
typename TYPE >
109 block(enum_as_little_endian_block, TYPE & t) :
110 block((
void *)&t,
sizeof(t))
113 reverse(m_begin, m_end);
116 template <
typename TYPE >
117 block(enum_as_block, TYPE & t) : block((
void *)&t,
sizeof(t)) {}
118 template <
typename TYPE >
119 block(enum_as_block,
const TYPE & t) : block((
void *)&t,
sizeof(t)) {}
120 block(
const void * begin,
const void * end) : BLOCK((::u8 *)begin, (::u8 *)end) {}
121 template < prototype_
integral INTEGRAL >
122 block(
const void * data, INTEGRAL count) : BLOCK((::u8 *) data, count) { }
149 constexpr bool has_data()
const {
return !this->is_empty(); }
151 template <
typename TYPE >
152 const TYPE* as_pointer()
const
155 return (
const TYPE*)begin();
159 template <
typename TYPE >
163 return (TYPE*) begin();
168 template<
typename ITERATOR_TYPE>
169 ::range<ITERATOR_TYPE> as_range()
171 ASSERT(this->size() %
sizeof(typename ::range < ITERATOR_TYPE>::ITEM) == 0);
172 return {(ITERATOR_TYPE)begin(), (ITERATOR_TYPE)end()};
176 template<
typename ITERATOR_TYPE>
177 const ::range < ITERATOR_TYPE > as_range()
const
179 ASSERT(this->size() %
sizeof(typename ::range<ITERATOR_TYPE>::ITEM) == 0);
180 return {(ITERATOR_TYPE) begin(), (ITERATOR_TYPE)end()};
184 template<
typename ITERATOR_TYPE>
187 ASSERT(this->size() %
sizeof(typename ::range < ITERATOR_TYPE>::ITEM) == 0);
188 return {(ITERATOR_TYPE)begin(), (ITERATOR_TYPE)end()};
192 template<
typename ITERATOR_TYPE>
193 const ::character_range < ITERATOR_TYPE > as_character_range()
const
195 ASSERT(this->size() %
sizeof(typename ::range<ITERATOR_TYPE>::ITEM) == 0);
196 return {(ITERATOR_TYPE) begin(), (ITERATOR_TYPE)end()};
200 template < prototype_aggregate AGGREGATE >
201 block & operator = (
const AGGREGATE & aggregate)
204 if (this->size() <
sizeof(AGGREGATE))
207 throw_exception(error_end_of_file);
211 ::memory_copy(this->m_begin, &aggregate,
sizeof(aggregate));
217 template <
character_count c >
218 block & operator = (const ::u8(&ba)[c])
221 if (this->size() < c)
224 throw_exception(error_end_of_file);
228 ::memory_copy(this->m_begin, ba, c);
234 template <
typename T >
235 block & operator >>(T & t)
238 if (this->size() <
sizeof(T))
241 throw_exception(error_end_of_file);
245 ::memory_copy(&t, this->begin(),
sizeof(t));
251 template <
character_count c >
252 block & operator >>(::u8(&ba)[c])
255 if (this->size() < c)
258 throw_exception(error_end_of_file);
262 memory_copy(ba, this->m_begin, c);
277 block & from_base64(const ::scoped_string & scopedstr)
const;
280 ::std::strong_ordering compare(
const block& block)
const
283 auto commonSize = minimum(size(), block.size());
285 auto ordering = memory_order(begin(), block.begin(), commonSize) <=>0;
294 return size() <=> block.size();
299 bool operator == (
const block& block)
const
302 if (block.size() != size())
316 return memory_order(begin(), block.begin(), (
size_t)size()) == 0;
321 bool operator != (
const block& block)
const
324 return !operator == (block);
329 memsize find(const ::block& blockFind, memsize start = 0)
const;
331 inline memsize _find(const ::block& blockFind, memsize start = 0)
const
333 return ((::u8*)_memory_find(
334 as_pointer<::u8>() + start, size() - start,
335 blockFind.begin(), blockFind.size())) - as_pointer <::u8>();
340 inline void copy(const ::block & block)
343 memory_copy(m_begin, block.data(), minimum(block.size(), this->size()));
348 inline bool begins(const ::block & block)
const
358 if(this->size() < block.size())
365 if(::memory_order(this->data(), block.data(), block.size()) != 0)
377 inline bool ends(const ::block & block)
const
387 if(this->size() < block.size())
394 if(::memory_order(this->end() - block.size(), block.data(), block.size()) != 0)
406 ::u8 & first_byte(::collection::index i = 0){
return this->m_begin[i];}
407 ::u8 first_byte(::collection::index i = 0)
const{
return this->m_begin[i];}
408 ::u8 & last_byte(::collection::index i = -1){
return this->m_end[i];}
409 ::u8 last_byte(::collection::index i = -1)
const{
return this->m_end[i];}