00001 // tabbed_values.hxx -- parse tab separated strings into fields 00002 // 00003 // Written by James Turner, started February 2003. 00004 // 00005 // Copyright (C) 2003 James Turner 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU Library General Public 00009 // License as published by the Free Software Foundation; either 00010 // version 2 of the License, or (at your option) any later version. 00011 // 00012 // This library 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 GNU 00015 // Library 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, write to the Free Software 00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 // 00021 // $Id: tabbed__values_8hxx_source.html,v 1.3 2010/02/23 22:10:17 curt Exp $ 00022 00023 #ifndef SG_TABBED_VALUES_HXX 00024 #define SG_TABBED_VALUES_HXX 00025 00026 #include <simgear/compiler.h> 00027 00028 #include <vector> 00029 #include <string> 00030 00031 using std::vector; 00032 using std::string; 00033 00034 class SGTabbedValues 00035 { 00036 public: 00037 SGTabbedValues(const char* line); 00038 00039 string operator[](const unsigned int) const; 00040 00041 bool isValueAt(const unsigned int) const; 00042 00043 double getDoubleAt(const unsigned int) const; 00044 char getCharAt(const unsigned int) const; 00045 long getLongAt(const unsigned int) const; 00046 private: 00047 const char* fieldAt(const unsigned int offset) const; 00048 00049 const char* _line; 00050 00055 mutable vector<char*> _fields; 00056 }; 00057 00058 #endif