OTest2
A C++ testing framework
tagsstack.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Ondrej Starek
3  *
4  * This file is part of OTest2
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include <tagsstack.h>
20 
21 #include <algorithm>
22 #include <assert.h>
23 #include <iterator>
24 #include <vector>
25 
26 #include <tags.h>
27 #include <utils.h>
28 
29 namespace OTest2 {
30 
31 struct TagsStack::Impl {
32  std::vector<TagRecord> stack;
33 
34  /* -- avoid copying */
35  Impl(
36  const Impl&) = delete;
37  Impl& operator = (
38  const Impl&) = delete;
39 
40  Impl();
41  ~Impl();
42 };
43 
44 TagsStack::Impl::Impl() {
45 
46 }
47 
48 TagsStack::Impl::~Impl() {
49 
50 }
51 
53  pimpl(new Impl) {
54 
55 }
56 
58  odelete(pimpl);
59 }
60 
62  const std::string& name_,
63  const Tags& tags_) {
64  pimpl->stack.push_back({name_, tags_});
65 }
66 
68  assert(!pimpl->stack.empty());
69  pimpl->stack.pop_back();
70 }
71 
73  std::vector<TagRecord>& tags_) const {
74  std::copy(pimpl->stack.begin(), pimpl->stack.end(), std::back_inserter(tags_));
75 }
76 
77 } /* -- namespace OTest2 */
OTest2::TagsStack::fillTags
void fillTags(std::vector< TagRecord > &tags_) const
Fill the stack into a vector (used for glob evaluation)
Definition: tagsstack.cpp:72
tags.h
tagsstack.h
OTest2::TagsStack::~TagsStack
~TagsStack()
Dtor.
Definition: tagsstack.cpp:57
OTest2::TagsStack::popTags
void popTags()
Pop tags at the top of the stack.
Definition: tagsstack.cpp:67
OTest2::TagsStack::TagsStack
TagsStack()
Ctor.
Definition: tagsstack.cpp:52
OTest2::TagsStack::operator=
TagsStack & operator=(const TagsStack &)=delete
OTest2::TagsStack::pushTags
void pushTags(const std::string &name_, const Tags &tags_)
Push tags.
Definition: tagsstack.cpp:61
utils.h
OTest2
Definition: assertbean.h:25
OTest2::Tags
List of tags assigned to a testing object.
Definition: tags.h:32
OTest2::odelete
void odelete(T_ *&object_)
Delete a pointer and set it invalid.
Definition: utils.h:34