Crevice  0.1
 All Classes Functions Variables Pages
TokenList.cc
1 /*
2  * File: Tokenlist.cc
3  *
4  * Copyright 2014 Heinrich Schuchardt <xypron.glpk@gmx.de>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #include "TokenList.h"
20 
25 }
26 
32  for (std::vector<Token *>::const_iterator pos = orig.list.begin();
33  pos != list.end(); ++pos) {
34  // Append copy of token.
35  append(new Token(**pos));
36  }
37 }
38 
43  for (std::vector<Token *>::iterator pos = list.begin();
44  pos != list.end(); ++pos) {
45  delete *pos;
46  *pos = NULL;
47  }
48 }
49 
54 std::vector<Token *>::const_iterator TokenList::begin() {
55  return list.begin();
56 }
57 
62 std::vector<Token *>::const_iterator TokenList::end() {
63  return list.end();
64 }
65 
71  return list.size();
72 };
73 
78 const Token * TokenList::tokenAt(int pos) {
79  if (pos < 0 || pos >= list.size()) {
80  throw invalid;
81  } else {
82  return list[pos];
83  }
84 }
85 
91  list.push_back(tok);
92 }