OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
hypertextparser.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWDIALOGUE_HYPERTEXTPARSER_H
2 #define GAME_MWDIALOGUE_HYPERTEXTPARSER_H
3 
4 #include <string>
5 #include <vector>
6 
7 namespace MWDialogue
8 {
9  namespace HyperTextParser
10  {
11  struct Token
12  {
13  enum Type
14  {
15  ExplicitLink, // enclosed in @#
17  };
18 
19  Token(const std::string & text, Type type) : mText(text), mType(type) {}
20 
21  bool isExplicitLink() { return mType == ExplicitLink; }
22  bool isImplicitKeyword() { return mType == ImplicitKeyword; }
23 
24  std::string mText;
26  };
27 
28  // In translations (at least Russian) the links are marked with @#, so
29  // it should be a function to parse it
30  std::vector<Token> parseHyperText(const std::string & text);
31  void tokenizeKeywords(const std::string & text, std::vector<Token> & tokens);
32  size_t removePseudoAsterisks(std::string & phrase);
33  }
34 }
35 
36 #endif
Token(const std::string &text, Type type)
Definition: hypertextparser.hpp:19
Definition: hypertextparser.hpp:11
Type mType
Definition: hypertextparser.hpp:25
Definition: hypertextparser.hpp:15
std::vector< Token > parseHyperText(const std::string &text)
Definition: hypertextparser.cpp:17
bool isImplicitKeyword()
Definition: hypertextparser.hpp:22
Definition: hypertextparser.hpp:16
std::string mText
Definition: hypertextparser.hpp:24
Type
Definition: hypertextparser.hpp:13
size_t removePseudoAsterisks(std::string &phrase)
Definition: hypertextparser.cpp:72
bool isExplicitLink()
Definition: hypertextparser.hpp:21
void tokenizeKeywords(const std::string &text, std::vector< Token > &tokens)
Definition: hypertextparser.cpp:48