Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
container.h
Go to the documentation of this file.
1/*
2 Formatting library for C++ - standard container utilities
3
4 Copyright (c) 2012 - 2016, Victor Zverovich
5 All rights reserved.
6
7 For the license information refer to format.h.
8 */
9
10#ifndef FMT_CONTAINER_H_
11#define FMT_CONTAINER_H_
12
13#include "format.h"
14
15namespace fmt {
16
17namespace internal {
18
19/**
20 \rst
21 A "buffer" that appends data to a standard container (e.g. typically a
22 ``std::vector`` or ``std::basic_string``).
23 \endrst
24 */
25template <typename Container>
26class ContainerBuffer : public Buffer<typename Container::value_type> {
27 private:
28 Container& container_;
29
30 protected:
31 virtual void grow(std::size_t size) FMT_OVERRIDE {
33 this->ptr_ = &container_[0];
34 this->capacity_ = size;
35 }
36
37 public:
38 explicit ContainerBuffer(Container& container) : container_(container) {
39 this->size_ = container_.size();
40 if (this->size_ > 0) {
41 this->ptr_ = &container_[0];
42 this->capacity_ = this->size_;
43 }
44 }
45};
46} // namespace internal
47
48/**
49 \rst
50 This class template provides operations for formatting and appending data
51 to a standard *container* like ``std::vector`` or ``std::basic_string``.
52
53 **Example**::
54
55 void vecformat(std::vector<char>& dest, fmt::BasicCStringRef<char> format,
56 fmt::ArgList args) {
57 fmt::BasicContainerWriter<std::vector<char> > appender(dest);
58 appender.write(format, args);
59 }
60 FMT_VARIADIC(void, vecformat, std::vector<char>&,
61 fmt::BasicCStringRef<char>);
62 \endrst
63 */
64template <class Container>
66 : public BasicWriter<typename Container::value_type> {
67 private:
69
70 public:
71 /**
72 \rst
73 Constructs a :class:`fmt::BasicContainerWriter` object.
74 \endrst
75 */
76 explicit BasicContainerWriter(Container& dest)
78};
79
80} // namespace fmt
81
82#endif // FMT_CONTAINER_H_
BasicContainerWriter(Container &dest)
Definition container.h:76
internal::ContainerBuffer< Container > buffer_
Definition container.h:68
virtual void grow(std::size_t size) FMT_OVERRIDE
Definition container.h:31
ContainerBuffer(Container &container)
Definition container.h:38
Definition format.h:408
Definition json.hpp:4518
#define FMT_OVERRIDE
Definition format.h:263