forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.h
More file actions
77 lines (61 loc) · 1.83 KB
/
state.h
File metadata and controls
77 lines (61 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Aseprite CSS Library
// Copyright (C) 2013 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef CSS_STATE_H_INCLUDED
#define CSS_STATE_H_INCLUDED
#pragma once
#include <string>
#include <vector>
namespace css {
class State {
public:
State() { }
State(const std::string& name) : m_name(name) { }
const std::string& name() const { return m_name; }
private:
std::string m_name;
};
class States {
public:
typedef std::vector<const State*> List;
typedef List::iterator iterator;
typedef List::const_iterator const_iterator;
typedef List::reverse_iterator reverse_iterator;
typedef List::const_reverse_iterator const_reverse_iterator;
States() { }
States(const State& state) {
operator+=(state);
}
iterator begin() { return m_list.begin(); }
iterator end() { return m_list.end(); }
const_iterator begin() const { return m_list.begin(); }
const_iterator end() const { return m_list.end(); }
reverse_iterator rbegin() { return m_list.rbegin(); }
reverse_iterator rend() { return m_list.rend(); }
const_reverse_iterator rbegin() const { return m_list.rbegin(); }
const_reverse_iterator rend() const { return m_list.rend(); }
States& operator+=(const State& other) {
m_list.push_back(&other);
return *this;
}
States& operator+=(const States& others) {
for (const_iterator it=others.begin(), end=others.end(); it != end; ++it)
operator+=(*(*it));
return *this;
}
bool operator<(const States& other) const {
return m_list < other.m_list;
}
private:
List m_list;
};
inline States operator+(const State& a, const State& b) {
States states;
states += a;
states += b;
return states;
}
} // namespace css
#endif