1 // StarPlot - A program for interactively viewing 3D maps of stellar positions. 2 // Copyright (C) 2000 Kevin B. McCarty 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 2 7 // of the License, or (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 19 /* 20 parse.h 21 Header file for the starconvert utility; contains lots of necessary structs. 22 */ 23 24 #ifndef _PARSE_H 25 #define _PARSE_H 26 27 #include <fstream> 28 #include <cstdlib> 29 #include <cstdio> 30 #include <cstring> 31 #include <cmath> 32 #include <vector> 33 34 #include "../classes/strings.h" 35 #include "../classes/specclass.h" 36 #include "../classes/vector3.h" 37 38 // Lots of typedef'd structs in which to store the results of parsing the 39 // configuration file 40 41 struct substring { 42 unsigned int start, len; 43 }; 44 45 struct comments { 46 substring s; 47 }; 48 49 const unsigned int NUM_COORD_OPTIONS = 7; 50 #ifndef _CONVERT_H 51 static const char * coordoptions[NUM_COORD_OPTIONS][2] = 52 { { "ra-hours", "long-deg" }, 53 { "ra-min", "long-min" }, 54 { "ra-sec", "long-sec" }, 55 { "dec-sign", "lat-sign" }, 56 { "dec-deg", "lat-deg" }, 57 { "dec-min", "lat-min" }, 58 { "dec-sec", "lat-sec" } 59 }; 60 #endif 61 // The above #ifndef prevents coordoptions from being unnecessarily defined 62 // in the convert.cc file. (I'm one of those people who hate to see 63 // compiler warnings.) 64 65 struct coordinates { 66 substring s[NUM_COORD_OPTIONS]; 67 bool isCelestial; 68 }; 69 70 const unsigned int NUM_DISTANCE_UNITS = 5; 71 #ifndef _CONVERT_H 72 static const char * distanceunits[NUM_DISTANCE_UNITS] = 73 { "milliarcsec", "arcsec", "pc", "ly", "specclass" }; 74 #endif 75 enum eunittype { MILLIARCSEC, ARCSEC, PC, LY, SPECCLASS }; 76 // The above char *[] and enum must be kept in sync! 77 // The #ifndef above prevents distanceunits from being unnecessarily defined 78 // in the convert.cc file. 79 80 struct stardistance { 81 eunittype type; 82 substring s, err; 83 double minparallax, maxerror; 84 }; 85 86 enum emagtype { ABSOLUTE, VISUAL }; 87 88 struct magnitude { 89 emagtype type; 90 substring s; 91 }; 92 93 struct characteristics { 94 std::vector<substring> s; 95 std::vector<stardistance> distarray; 96 std::vector<magnitude> magarray; 97 characteristicscharacteristics98 characteristics() : 99 s(), distarray(), magarray() { } 100 }; 101 102 struct systems { 103 substring comp, sep; 104 bool isSeparationCommented; 105 StringList sep_prefixes; 106 systemssystems107 systems() : sep_prefixes() { } 108 }; 109 110 const unsigned int NUM_NAME_TYPES = 5; 111 #ifndef _CONVERT_H 112 static const char * nametypes[NUM_NAME_TYPES] = 113 { "bayer", "flamsteed", "const-specific", "dm", "other" }; 114 #endif 115 enum enametype { BAYER, FLAMSTEED, CONSTSPECIFIC, DM, OTHER }; 116 // The above char *[] and enum must be kept in sync! 117 // The #ifndef above prevents nametypes from being unnecessarily defined 118 // in the convert.cc file. 119 120 struct name { 121 enametype type; 122 bool isNameCommented; 123 substring s; 124 StringList name_prefixes; 125 namename126 name() : name_prefixes() { } 127 }; 128 129 struct substitution { 130 std::string subst1; 131 std::string subst2; 132 int insert_posn; 133 substitutionsubstitution134 substitution() : subst1(), subst2(), insert_posn(0) { } substitutionsubstitution135 substitution(std::string s1, std::string s2, int posn) : 136 subst1(s1), subst2(s2), insert_posn(posn) { } 137 }; 138 139 struct namedata { 140 std::vector<name> names; 141 std::vector<substitution> substs; 142 bool isSubstCaseSensitive; 143 namedatanamedata144 namedata() : names(), substs() { } 145 }; 146 147 struct parsedata { 148 comments Comments; 149 coordinates Coord; 150 characteristics Charact; 151 systems Systems; 152 namedata Names; 153 parsedataparsedata154 parsedata() : Comments(), Coord(), Charact(), Systems(), Names() { } 155 }; 156 157 enum parsetype { NONE, COORDS, CHARACT, SYSTEMS, NAMES, SUBST }; 158 159 // External function declarations for the parsing file 160 161 extern void parse_config_file(std::istream &, parsedata *); 162 163 #endif // #ifndef _PARSE_H 164