source: trunk/src/generated/position.hh @ 2410

Last change on this file since 2410 was 2410, checked in by touky, 7 years ago

easymesh : Added SmoothMesh operation, works well with triangle, not well with a box.

File size: 4.1 KB
Line 
1/* A Bison parser, made by GNU Bison 2.4.2.  */
2
3/* Positions for Bison parsers in C++
4   
5      Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc.
6   
7   This program is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11   
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16   
17   You should have received a copy of the GNU General Public License
18   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20/* As a special exception, you may create a larger work that contains
21   part or all of the Bison parser skeleton and distribute that work
22   under terms of your choice, so long as that work isn't itself a
23   parser generator using the skeleton or a modified version thereof
24   as a parser skeleton.  Alternatively, if you modify or redistribute
25   the parser skeleton itself, you may (at your option) remove this
26   special exception, which will cause the skeleton and the resulting
27   Bison output files to be licensed under the GNU General Public
28   License without this special exception.
29   
30   This special exception was added by the Free Software Foundation in
31   version 2.2 of Bison.  */
32
33/**
34 ** \file position.hh
35 ** Define the lol::position class.
36 */
37
38#ifndef BISON_POSITION_HH
39# define BISON_POSITION_HH
40
41# include <iostream>
42# include <string>
43# include <algorithm>
44
45
46namespace lol {
47
48/* Line 37 of location.cc  */
49#line 50 "generated/position.hh"
50  /// Abstract a position.
51  class position
52  {
53  public:
54
55    /// Construct a position.
56    position ()
57      : filename (0), line (1), column (1)
58    {
59    }
60
61
62    /// Initialization.
63    inline void initialize (std::string* fn)
64    {
65      filename = fn;
66      line = 1;
67      column = 1;
68    }
69
70    /** \name Line and Column related manipulators
71     ** \{ */
72  public:
73    /// (line related) Advance to the COUNT next lines.
74    inline void lines (int count = 1)
75    {
76      column = 1;
77      line += count;
78    }
79
80    /// (column related) Advance to the COUNT next columns.
81    inline void columns (int count = 1)
82    {
83      column = std::max (1u, column + count);
84    }
85    /** \} */
86
87  public:
88    /// File name to which this position refers.
89    std::string* filename;
90    /// Current line number.
91    unsigned int line;
92    /// Current column number.
93    unsigned int column;
94  };
95
96  /// Add and assign a position.
97  inline const position&
98  operator+= (position& res, const int width)
99  {
100    res.columns (width);
101    return res;
102  }
103
104  /// Add two position objects.
105  inline const position
106  operator+ (const position& begin, const int width)
107  {
108    position res = begin;
109    return res += width;
110  }
111
112  /// Add and assign a position.
113  inline const position&
114  operator-= (position& res, const int width)
115  {
116    return res += -width;
117  }
118
119  /// Add two position objects.
120  inline const position
121  operator- (const position& begin, const int width)
122  {
123    return begin + -width;
124  }
125
126  /// Compare two position objects.
127  inline bool
128  operator== (const position& pos1, const position& pos2)
129  {
130    return (pos1.line == pos2.line
131            && pos1.column == pos2.column
132            && (pos1.filename == pos2.filename
133                || (pos1.filename && pos2.filename
134                    && *pos1.filename == *pos2.filename)));
135  }
136
137  /// Compare two position objects.
138  inline bool
139  operator!= (const position& pos1, const position& pos2)
140  {
141    return !(pos1 == pos2);
142  }
143
144  /** \brief Intercept output stream redirection.
145   ** \param ostr the destination output stream
146   ** \param pos a reference to the position to redirect
147   */
148  inline std::ostream&
149  operator<< (std::ostream& ostr, const position& pos)
150  {
151    if (pos.filename)
152      ostr << *pos.filename << ':';
153    return ostr << pos.line << '.' << pos.column;
154  }
155
156
157} // lol
158
159/* Line 144 of location.cc  */
160#line 161 "generated/position.hh"
161#endif // not BISON_POSITION_HH
Note: See TracBrowser for help on using the repository browser.