4#ifndef AUX_STATE_STACK_H
5#define AUX_STATE_STACK_H
12 template <
typename StateT>
13 class StateStack final
17 friend class StateStack;
19 Accessor() : m_state(nullptr) { }
20 void Set(StateT& state) { m_state = &state; }
22 StateT* operator->() {
return m_state; }
23 const StateT* operator->()
const {
return m_state; }
24 StateT& operator*() {
return *m_state; }
25 const StateT& operator*()
const {
return *m_state; }
35 bool PopLenient(
unsigned popCount = 1);
36 void Pop(
unsigned popCount = 1);
38 unsigned GetSize()
const;
40 void push(
const StateT& state);
42 std::stack<StateT> m_states;
45 template <
typename StateT>
46 StateStack<StateT>::StateStack()
51 template <
typename StateT>
52 void StateStack<StateT>::Push()
57 template <
typename StateT>
58 bool StateStack<StateT>::PopLenient(
unsigned popCount)
60 if (popCount >= m_states.size())
63 for (
unsigned i = 0; i < popCount; i++)
66 Current.Set(m_states.top());
70 template<
typename StateT>
71 inline void StateStack<StateT>::Pop(
unsigned popCount)
73 if (popCount >= m_states.size())
74 throw std::runtime_error(
"Can't pop out all the states in the stack");
76 for (
unsigned i = 0; i < popCount; i++)
79 Current.Set(m_states.top());
82 template <
typename StateT>
83 void StateStack<StateT>::Clear()
85 for (
unsigned i = 0; i < m_states.size(); i++)
91 template <
typename StateT>
92 unsigned StateStack<StateT>::GetSize()
const
94 return (
unsigned)m_states.size();
97 template <
typename StateT>
98 void StateStack<StateT>::push(
const StateT& state)
100 m_states.push(state);
101 Current.Set(m_states.top());
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
@ Push
Display the fields down appearance (requires an additional appearance stream to be set)