1 | // |
---|---|
2 | // Array.h |
3 | // |
4 | // Library: Redis |
5 | // Package: Redis |
6 | // Module: Array |
7 | // |
8 | // Implementation of the Array class. |
9 | // |
10 | // Copyright (c) 2015, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #include "Poco/Redis/Array.h" |
18 | |
19 | |
20 | namespace Poco { |
21 | namespace Redis { |
22 | |
23 | |
24 | Array::Array() |
25 | { |
26 | } |
27 | |
28 | |
29 | Array::Array(const Array& copy): |
30 | _elements(copy._elements) |
31 | { |
32 | } |
33 | |
34 | |
35 | Array::~Array() |
36 | { |
37 | } |
38 | |
39 | |
40 | Array& Array::addRedisType(RedisType::Ptr value) |
41 | { |
42 | checkNull(); |
43 | |
44 | _elements.value().push_back(value); |
45 | |
46 | return *this; |
47 | } |
48 | |
49 | |
50 | int Array::getType(size_t pos) const |
51 | { |
52 | if (_elements.isNull()) throw NullValueException(); |
53 | |
54 | if (pos >= _elements.value().size()) throw InvalidArgumentException(); |
55 | |
56 | RedisType::Ptr element = _elements.value().at(pos); |
57 | return element->type(); |
58 | } |
59 | |
60 | |
61 | std::string Array::toString() const |
62 | { |
63 | return RedisTypeTraits<Array>::toString(*this); |
64 | } |
65 | |
66 | |
67 | } } // namespace Poco::Redis |
68 |