• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KHolidays Library

  • sources
  • kde-4.14
  • kdepimlibs
  • kholidays
  • parsers
  • plan2
position.hh
Go to the documentation of this file.
1 
2 /* A Bison parser, made by GNU Bison 2.4.1. */
3 
4 /* Positions for Bison parsers in C++
5 
6  Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 
21 /* As a special exception, you may create a larger work that contains
22  part or all of the Bison parser skeleton and distribute that work
23  under terms of your choice, so long as that work isn't itself a
24  parser generator using the skeleton or a modified version thereof
25  as a parser skeleton. Alternatively, if you modify or redistribute
26  the parser skeleton itself, you may (at your option) remove this
27  special exception, which will cause the skeleton and the resulting
28  Bison output files to be licensed under the GNU General Public
29  License without this special exception.
30 
31  This special exception was added by the Free Software Foundation in
32  version 2.2 of Bison. */
33 
39 #ifndef BISON_POSITION_HH
40 # define BISON_POSITION_HH
41 
42 # include <iostream>
43 # include <string>
44 # include <algorithm>
45 
46 
47 /* Line 38 of location.cc */
48 #line 1 "[Bison:b4_percent_define_default]"
49 
50 namespace KHolidays {
51 
52 /* Line 38 of location.cc */
53 #line 54 "position.hh"
54  class position
56  {
57  public:
58 
60  position ()
61  : filename (0), line (1), column (1)
62  {
63  }
64 
65 
67  inline void initialize (std::string* fn)
68  {
69  filename = fn;
70  line = 1;
71  column = 1;
72  }
73 
76  public:
78  inline void lines (int count = 1)
79  {
80  column = 1;
81  line += count;
82  }
83 
85  inline void columns (int count = 1)
86  {
87  column = std::max (1u, column + count);
88  }
91  public:
93  std::string* filename;
95  unsigned int line;
97  unsigned int column;
98  };
99 
101  inline const position&
102  operator+= (position& res, const int width)
103  {
104  res.columns (width);
105  return res;
106  }
107 
109  inline const position
110  operator+ (const position& begin, const int width)
111  {
112  position res = begin;
113  return res += width;
114  }
115 
117  inline const position&
118  operator-= (position& res, const int width)
119  {
120  return res += -width;
121  }
122 
124  inline const position
125  operator- (const position& begin, const int width)
126  {
127  return begin + -width;
128  }
129 
131  inline bool
132  operator== (const position& pos1, const position& pos2)
133  {
134  return
135  (pos1.filename == pos2.filename
136  || pos1.filename && pos2.filename && *pos1.filename == *pos2.filename)
137  && pos1.line == pos2.line && pos1.column == pos2.column;
138  }
139 
141  inline bool
142  operator!= (const position& pos1, const position& pos2)
143  {
144  return !(pos1 == pos2);
145  }
146 
151  inline std::ostream&
152  operator<< (std::ostream& ostr, const position& pos)
153  {
154  if (pos.filename)
155  ostr << *pos.filename << ':';
156  return ostr << pos.line << '.' << pos.column;
157  }
158 
159 
160 /* Line 144 of location.cc */
161 #line 1 "[Bison:b4_percent_define_default]"
162 
163 } // KHolidays
164 
165 /* Line 144 of location.cc */
166 #line 167 "position.hh"
167 #endif // not BISON_POSITION_HH
KHolidays::position::position
position()
Construct a position.
Definition: position.hh:60
KHolidays::position::column
unsigned int column
Current column number.
Definition: position.hh:97
KHolidays::position::columns
void columns(int count=1)
(column related) Advance to the COUNT next columns.
Definition: position.hh:85
KHolidays::position::line
unsigned int line
Current line number.
Definition: position.hh:95
KHolidays::position
Abstract a position.
Definition: position.hh:55
KHolidays::position::lines
void lines(int count=1)
(line related) Advance to the COUNT next lines.
Definition: position.hh:78
KHolidays::position::initialize
void initialize(std::string *fn)
Initialization.
Definition: position.hh:67
KHolidays::position::filename
std::string * filename
File name to which this position refers.
Definition: position.hh:93
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHolidays Library

Skip menu "KHolidays Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal