Column-oriented GPU-accelerated Database Management System
CoGaDB
/home/sebastian/gpudbms/trunk/cogadb/src/sql/server/location.hh
Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 2.5.  */
00002 
00003 /* Locations for Bison parsers in C++
00004    
00005       Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
00006    
00007    This program is free software: you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation, either version 3 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 /* As a special exception, you may create a larger work that contains
00021    part or all of the Bison parser skeleton and distribute that work
00022    under terms of your choice, so long as that work isn't itself a
00023    parser generator using the skeleton or a modified version thereof
00024    as a parser skeleton.  Alternatively, if you modify or redistribute
00025    the parser skeleton itself, you may (at your option) remove this
00026    special exception, which will cause the skeleton and the resulting
00027    Bison output files to be licensed under the GNU General Public
00028    License without this special exception.
00029    
00030    This special exception was added by the Free Software Foundation in
00031    version 2.2 of Bison.  */
00032 
00038 #ifndef BISON_LOCATION_HH
00039 # define BISON_LOCATION_HH
00040 
00041 # include <iostream>
00042 # include <string>
00043 # include "position.hh"
00044 
00045 
00046 /* Line 162 of location.cc  */
00047 #line 14 "src/sql/server/sql_parser.ypp"
00048 namespace CoGaDB { namespace SQL {
00049 
00050 /* Line 162 of location.cc  */
00051 #line 52 "/home/sebastian/gpudbms/trunk/cogadb/src/sql/server/location.hh"
00052 
00054   class location
00055   {
00056   public:
00057 
00059     location ()
00060       : begin (), end ()
00061     {
00062     }
00063 
00064 
00066     inline void initialize (std::string* fn)
00067     {
00068       begin.initialize (fn);
00069       end = begin;
00070     }
00071 
00074   public:
00076     inline void step ()
00077     {
00078       begin = end;
00079     }
00080 
00082     inline void columns (unsigned int count = 1)
00083     {
00084       end += count;
00085     }
00086 
00088     inline void lines (unsigned int count = 1)
00089     {
00090       end.lines (count);
00091     }
00095   public:
00097     position begin;
00099     position end;
00100   };
00101 
00103   inline const location operator+ (const location& begin, const location& end)
00104   {
00105     location res = begin;
00106     res.end = end.end;
00107     return res;
00108   }
00109 
00111   inline const location operator+ (const location& begin, unsigned int width)
00112   {
00113     location res = begin;
00114     res.columns (width);
00115     return res;
00116   }
00117 
00119   inline location& operator+= (location& res, unsigned int width)
00120   {
00121     res.columns (width);
00122     return res;
00123   }
00124 
00126   inline bool
00127   operator== (const location& loc1, const location& loc2)
00128   {
00129     return loc1.begin == loc2.begin && loc1.end == loc2.end;
00130   }
00131 
00133   inline bool
00134   operator!= (const location& loc1, const location& loc2)
00135   {
00136     return !(loc1 == loc2);
00137   }
00138 
00145   inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
00146   {
00147     position last = loc.end - 1;
00148     ostr << loc.begin;
00149     if (last.filename
00150         && (!loc.begin.filename
00151             || *loc.begin.filename != *last.filename))
00152       ostr << '-' << last;
00153     else if (loc.begin.line != last.line)
00154       ostr << '-' << last.line  << '.' << last.column;
00155     else if (loc.begin.column != last.column)
00156       ostr << '-' << last.column;
00157     return ostr;
00158   }
00159 
00160 
00161 /* Line 271 of location.cc  */
00162 #line 14 "src/sql/server/sql_parser.ypp"
00163 } } // CoGaDB::SQL
00164 
00165 /* Line 271 of location.cc  */
00166 #line 167 "/home/sebastian/gpudbms/trunk/cogadb/src/sql/server/location.hh"
00167 
00168 #endif // not BISON_LOCATION_HH
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines