OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [src/] [memlink.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#include "mistream.h"
7
#include "ustdxept.h"
8
 
9
namespace ustl {
10
 
11
/// Reads the object from stream \p s
12
void memlink::read (istream& is)
13
{
14
    written_size_type n = 0;
15
    is >> n;
16
    if (!is.verify_remaining ("read", "ustl::memlink", n))
17
        return;
18
    if (n > size())
19
        USTL_THROW(length_error ("memlink can not increase the size of the linked storage for reading"));
20
    resize (n);
21
    is.read (data(), n);
22
    is.align (alignof (n));
23
}
24
 
25
/// Copies data from \p p, \p n to the linked block starting at \p start.
26
void memlink::copy (iterator start, const void* p, size_type n)
27
{
28
    assert (data() || !n);
29
    assert (p || !n);
30
    assert (start >= begin() && start + n <= end());
31
    if (p)
32
        copy_n (const_iterator(p), n, start);
33
}
34
 
35
/// Fills the linked block with the given pattern.
36
/// \arg start   Offset at which to start filling the linked block
37
/// \arg p       Pointer to the pattern.
38
/// \arg elSize  Size of the pattern.
39
/// \arg elCount Number of times to write the pattern.
40
/// Total number of bytes written is \p elSize * \p elCount.
41
///
42
void memlink::fill (iterator start, const void* p, size_type elSize, size_type elCount)
43
{
44
    assert (data() || !elCount || !elSize);
45
    assert (start >= begin() && start + elSize * elCount <= end());
46
    if (elSize == 1)
47
        fill_n (start, elCount, *reinterpret_cast<const uint8_t*>(p));
48
    else while (elCount--)
49
        start = copy_n (const_iterator(p), elSize, start);
50
}
51
 
52
} // namespace ustl

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.