add some hacky code to allow passing sfc files with -b
[openc2e.git] / Catalogue.h
blob69a7f78dca97c601b3a3f78672a2fc924271f987
1 /*
2 * Catalogue.h
3 * openc2e
5 * Created by Alyssa Milburn on Sat 13 Nov 2004.
6 * Copyright (c) 2004-2006 Alyssa Milburn. All rights reserved.
7 * Copyright (c) 2005 Bryan Donlan. All rights reserved.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
20 #ifndef _CATALOGUE_H
21 #define _CATALOGUE_H
23 #include <iostream>
24 #include <map>
25 #include <string>
26 #include <vector>
27 #include <istream>
28 #include <boost/filesystem/path.hpp>
29 #include <list>
30 #include "exceptions.h"
32 class catalogueException : public creaturesException {
33 public:
34 catalogueException(const char *s) throw()
35 : creaturesException(s) {}
36 catalogueException(const std::string &s) throw()
37 : creaturesException(s) {}
38 };
40 class Catalogue {
41 protected:
42 static int yylineno;
43 static const char *catalogue_parse_p;
44 static void yyinit(const char *buf);
45 static int catalex();
46 friend int catalex();
47 friend void cataerror(const char *);
48 static void catalogueParseError(const char *err = NULL);
49 public:
50 std::map<std::string, std::vector<std::string> > data;
52 public:
53 friend std::istream &operator >> (std::istream &, Catalogue &);
55 const std::vector<std::string> &getTag(std::string t) const { return (*data.find(t)).second; }
56 bool hasTag(std::string t) const { return (data.find(t) != data.end()); }
57 const std::string getAgentName(unsigned char family, unsigned char genus, unsigned short species) const;
58 std::string calculateWildcardTag(std::string tag, unsigned char family, unsigned char genus, unsigned short species) const;
60 void reset();
61 void addFile(boost::filesystem::path path);
62 void initFrom(boost::filesystem::path path);
64 void addVals(std::string &title, bool override, int count, const std::list<std::string> &vals);
67 extern Catalogue catalogue;
69 /* For lexer/parser, don't use for anything else. */
71 char catalogue_descape(char c);
73 #endif
74 /* vim: set noet: */