1 // This file is part of the ustl library, an STL implementation.
3 // Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net>
4 // This file is free software, distributed under the MIT License.
8 // A pointer to a sized block of memory.
16 /// Reads the object from stream \p s
17 void memlink::read (istream
& is
)
21 is
.verify_remaining ("read", "ustl::memlink", n
);
23 throw length_error ("memlink can not increase the size of the linked storage for reading");
26 is
.align (alignof (n
));
29 /// Copies data from \p p, \p n to the linked block starting at \p start.
30 void memlink::copy (iterator start
, const void* p
, size_type n
)
32 assert (data() || !n
);
34 assert (start
>= begin() && start
+ n
<= end());
36 copy_n (const_iterator(p
), n
, start
);
39 /// Fills the linked block with the given pattern.
40 /// \arg start Offset at which to start filling the linked block
41 /// \arg p Pointer to the pattern.
42 /// \arg elSize Size of the pattern.
43 /// \arg elCount Number of times to write the pattern.
44 /// Total number of bytes written is \p elSize * \p elCount.
46 void memlink::fill (iterator start
, const void* p
, size_type elSize
, size_type elCount
)
48 assert (data() || !elCount
|| !elSize
);
49 assert (start
>= begin() && start
+ elSize
* elCount
<= end());
51 fill_n (start
, elCount
, *reinterpret_cast<const uint8_t*>(p
));
52 else while (elCount
--)
53 start
= copy_n (const_iterator(p
), elSize
, start
);