1 /* bzflag
2  * Copyright (c) 1993-2021 Tim Riker
3  *
4  * This package is free software;  you can redistribute it and/or
5  * modify it under the terms of the license found in the file
6  * named COPYING that should have accompanied this file.
7  *
8  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
9  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11  */
12 
13 #ifndef BZF_BUNDLE_H
14 #define BZF_BUNDLE_H
15 
16 // common header first
17 #include "common.h"
18 
19 // system headers
20 #include <map>
21 #include <vector>
22 #include <string>
23 
24 typedef std::map<std::string, std::string> BundleStringMap;
25 
26 class Bundle
27 {
28 public:
29     /** Localize a string */
30     std::string getLocalString(const std::string &key) const;
31     std::string formatMessage(const std::string &key, const std::vector<std::string> *parms) const;
32 
33 private:
34     typedef enum { tERROR, tCOMMENT, tMSGID, tMSGSTR, tAPPEND } TLineType;
35 
36     Bundle(const Bundle *pBundle);
37     Bundle(const Bundle &xBundle);
38     Bundle& operator=(const Bundle &xBundle);
39     void load(const std::string &path);
40     TLineType parseLine(const std::string &line, std::string &data) const;
41     void ensureNormalText(std::string &msg);
42     BundleStringMap mappings;
43 
44     friend class BundleMgr;
45 };
46 
47 #endif
48 
49 // Local Variables: ***
50 // mode: C++ ***
51 // tab-width: 4 ***
52 // c-basic-offset: 4 ***
53 // indent-tabs-mode: nil ***
54 // End: ***
55 // ex: shiftwidth=4 tabstop=4
56