+enum CharInfoFlags {
+ ///
+ CharInfoCombining = 1,
+ ///
+ CharInfoTextFeature = 2,
+ ///
+ CharInfoMathFeature = 4,
+ ///
+ CharInfoForce = 8,
+ ///
+ CharInfoTextNoTermination = 16,
+ ///
+ CharInfoMathNoTermination = 32,
+ ///
+ CharInfoForceSelected = 64,
+ ///
+ CharInfoDeprecated = 128
+};
+
+
+/// Information about a single UCS4 character
+class CharInfo {
+public:
+ CharInfo() : flags_(0) {}
+ CharInfo(
+ docstring const & text_command, docstring const & math_command,
+ std::string const & text_preamble, std::string const & math_preamble,
+ std::string const & tipa_shortcut, unsigned int flags);
+ CharInfo(
+ std::vector<docstring> const & text_commands, std::vector<docstring> const & math_commands,
+ std::string const & text_preamble, std::string const & math_preamble,
+ std::string const & tipa_shortcut, unsigned int flags);
+ // Add a new text command for this symbol.
+ void addTextCommand(const docstring& newTextCommand) { text_commands_.emplace_back(newTextCommand); }
+ // Add a new math command for this symbol.
+ void addMathCommand(const docstring& newMathCommand) { math_commands_.emplace_back(newMathCommand); }
+
+ // we assume that at least one command is nonempty when using unicodesymbols
+ bool isUnicodeSymbol() const { return !text_commands_.empty() || !math_commands_.empty(); }
+ /// LaTeX command (text mode) for this character
+ docstring textCommand() const { return text_commands_[0]; }
+ /// All known LaTeX commands (text mode) for this character
+ const std::vector<docstring>& textCommands() const { return text_commands_; }
+ /// LaTeX command (math mode) for this character
+ docstring mathCommand() const { return math_commands_[0]; }
+ /// All known LaTeX commands (math mode) for this character
+ const std::vector<docstring>& mathCommands() const { return math_commands_; }
+ /// Needed LaTeX preamble (or feature) for text mode
+ std::string textPreamble() const { return text_preamble_; }
+ /// Needed LaTeX preamble (or feature) for math mode
+ std::string mathPreamble() const { return math_preamble_; }
+ /// Is this a combining character?
+ bool combining() const { return flags_ & CharInfoCombining; }
+ /// Is \c textPreamble a feature known by LaTeXFeatures, or a raw LaTeX
+ /// command?
+ bool textFeature() const { return flags_ & CharInfoTextFeature; }
+ /// Is \c mathPreamble a feature known by LaTeXFeatures, or a raw LaTeX
+ /// command?
+ bool mathFeature() const { return flags_ & CharInfoMathFeature; }
+ /// Always force the LaTeX command, even if the encoding contains
+ /// this character?
+ bool force() const { return flags_ & CharInfoForce; }
+ /// Force the LaTeX command for some encodings?
+ bool forceSelected() const { return flags_ & CharInfoForceSelected; }
+ /// Disable LaTeX command => char_type conversion for this deprecated symbol?
+ bool deprecated() const { return flags_ & CharInfoDeprecated; }
+ /// TIPA shortcut
+ std::string const tipaShortcut() const { return tipa_shortcut_; }
+ /// \c textCommand needs no termination (such as {} or space).
+ bool textNoTermination() const { return flags_ & CharInfoTextNoTermination; }
+ /// \c mathCommand needs no termination (such as {} or space).
+ bool mathNoTermination() const { return flags_ & CharInfoMathNoTermination; }
+ ///
+private:
+ /// LaTeX commands (text mode) for this character. The first one is the default, the others
+ /// are only present for compatibility other ways users may encode the character
+ std::vector<docstring> text_commands_;
+ /// LaTeX command (math mode) for this character. The first one is the default, the others
+ // /// are only present for compatibility other ways users may encode the character
+ std::vector<docstring> math_commands_;
+ /// Needed LaTeX preamble (or feature) for text mode
+ trivstring text_preamble_;
+ /// Needed LaTeX preamble (or feature) for math mode
+ trivstring math_preamble_;
+ /// TIPA shortcut
+ trivstring tipa_shortcut_;
+ /// feature flags
+ unsigned int flags_;
+};
+
+
+/**
+ * An encoding as defined in lib/encodings.
+ * All const methods are thread-safe, so the caller does not need any locking.
+ * This property must be kept when changing the class.
+ */