about summary refs log tree commit diff stats
path: root/data/maps/the_ancient
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-10-02 17:37:14 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-10-02 17:37:14 -0400
commit655701e4e9911393e58f2b4ce06f44d6553e0f9c (patch)
tree775c79e0c08f3cfa6eafcec79a1261cb0aeb6200 /data/maps/the_ancient
parentfa9618214eeeec1e55a5e2d8db289375949a6b37 (diff)
downloadlingo2-archipelago-655701e4e9911393e58f2b4ce06f44d6553e0f9c.tar.gz
lingo2-archipelago-655701e4e9911393e58f2b4ce06f44d6553e0f9c.tar.bz2
lingo2-archipelago-655701e4e9911393e58f2b4ce06f44d6553e0f9c.zip
Fix password authentication
Diffstat (limited to 'data/maps/the_ancient')
0 files changed, 0 insertions, 0 deletions
ref='#n139'>139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
#ifndef TOKEN_H_AD62C505
#define TOKEN_H_AD62C505

#include <ostream>
#include <string>
#include <list>
#include <set>
#include "enums.h"
#include "word.h"
#include "part.h"

namespace verbly {

  class token {
    public:
      enum class type {
        word,
        literal,
        part,
        fillin,
        utterance,
        transform
      };

      // Copy & move constructors

      token(const token& other);
      token(token&& other);

      // Assignment operator

      token& operator=(token other);

      // Swap

      friend void swap(token& first, token& second);

      // Destructor

      ~token();

      // Accessors

      type getType() const
      {
        return type_;
      }

      bool isComplete() const;

      std::string compile() const;

      bool isEmpty() const
      {
        return ((type_ == type::utterance) && (utterance_.empty()));
      }

      // Word

      token(word arg, inflection category = inflection::base);

      const word& getWord() const;

      token inflect(inflection category) const;

      // Literal

      token(std::string arg);
      token(const char* arg);

      std::string getLiteral() const;

      // Part

      token(part arg);

      part getPart() const;

      // Fillin

      token(std::set<std::string> synrestrs);

      const std::set<std::string>& getSynrestrs() const;

      bool hasSynrestr(std::string synrestr) const;

      void addSynrestr(std::string synrestr);

      // Utterance

      using iterator = std::list<token>::iterator;
      using const_iterator = std::list<token>::const_iterator;

      token();
      token(std::vector<part> parts);
      token(std::initializer_list<token> pieces);

      iterator begin();
      const_iterator begin() const;

      iterator end();
      const_iterator end() const;

      token& operator<<(token arg);

      // Transform

      enum class casing {
        normal,
        capitalize,
        all_caps,
        title_case
      };

      static token separator(std::string param, token inner);
      static token punctuation(std::string param, token inner);
      static token indefiniteArticle(token inner);
      static token capitalize(casing param, token inner);
      static token quote(std::string open, std::string close, token inner);

      token& getInnerToken();
      const token& getInnerToken() const;

    private:

      std::string compileHelper(
        std::string separator,
        bool indefiniteArticle,
        casing capitalization) const;

      enum class transform_type {
        separator,
        punctuation,
        indefinite_article,
        capitalize,
        quote
      };

      token(
        transform_type type,
        std::string param1,
        std::string param2,
        token inner);

      token(
        transform_type type,
        casing param,
        token inner);

      union {
        struct {
          word word_;
          inflection category_;
        } word_;
        std::string literal_;
        part part_;
        std::set<std::string> fillin_;
        std::list<token> utterance_;
        struct {
          transform_type type_;
          std::string strParam_;
          std::string strParam2_;
          casing casingParam_;
          std::unique_ptr<token> inner_;
        } transform_;
      };
      type type_;
  };

  std::ostream& operator<<(std::ostream& os, token::type type);

};

#endif /* end of include guard: TOKEN_H_AD62C505 */