ccdevnet / openc2e

openc2e

This URL has Read+Write access

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