00001 /* Copyright (C) 2008 Oliver Lemke <olemke@core-dump.info> 00002 00003 This program is free software; you can redistribute it and/or modify it 00004 under the terms of the GNU General Public License as published by the 00005 Free Software Foundation; either version 2, or (at your option) any 00006 later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00016 USA. */ 00017 00018 #ifndef sourcetext_h 00019 #define sourcetext_h 00020 00021 #include "array.h" 00022 #include "mystring.h" 00023 00024 00036 class SourceText { 00037 public: 00038 00040 SourceText() : mLine(0), mColumn(0) { /* Nothing to be done here. */ }; 00041 00044 void AppendFile(const String& name); 00045 00047 char Current() { 00048 return mText[mLine][mColumn]; 00049 } 00050 00055 void AdvanceChar(); 00056 00060 void AdvanceLine(); 00061 00063 const String& File(); 00064 00067 Index Line(); 00068 00070 Index Column() { return mColumn+1; } 00071 00074 void Init(); 00075 00078 bool& LineBreak() { return mLineBreak; } 00079 00082 bool LineBreak() const { return mLineBreak; } 00083 00085 friend ostream& operator << (ostream& os, const SourceText& text); 00086 00087 private: 00088 00090 ArrayOfString mText; 00091 00093 Index mLine; 00094 00096 Index mColumn; 00097 00099 ArrayOfIndex mSfLine; 00100 00102 ArrayOfString mSfName; 00103 00106 bool mLineBreak; 00107 }; 00108 00109 #endif /* sourcetext_h */ 00110