about summary refs log tree commit diff stats
path: root/data/maps/the_owl/rooms/Blue Room.txtpb
Commit message (Collapse)AuthorAgeFilesLines
* Changed how door location names are formattedStar Rauchenberger2025-08-301-1/+0
| | | | | | | | | | | | | | | | | | STANDARD type doors with at most four panels in the same map area and no other trigger objects will have their location names generated from the names of the panels used to open the door, similar to Lingo 1. Other door types will use the door's name. In either case, the name can be overridden using the new location_name field. Rooms can also set a panel_display_name field, which will be used in location names for doors, and is used to group panels into areas. Panels themselves can set display names, which differentiates their locations from other panels in the same area. Many maps were updated for this, but note that the_symbolic and the_unyielding have validator failures because of duplicate panel names. This won't matter until panelsanity is implemented.
* Converted puzzle symbols to an enumStar Rauchenberger2025-08-201-1/+1
|
* Added the_owlStar Rauchenberger2025-08-171-0/+9
37'>137 138 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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
#ifndef STATEMENT_H_29F51659
#define STATEMENT_H_29F51659

#include <string>
#include <list>
#include <map>
#include <set>
#include "binding.h"
#include "enums.h"
#include "field.h"
#include "filter.h"

namespace verbly {

  class filter;
  class order;

  class statement {
  public:

    statement(object context, filter queryFilter);

    std::string getQueryString(std::list<std::string> select, order sortOrder, int limit, bool debug = false) const;

    std::list<binding> getBindings() const;

  private:

    class join {
    public:

      join(
        bool outer,
        std::string foreignTableName,
        std::string joinTable,
        std::string joinColumn,
        std::string foreignTable,
        std::string foreignColumn) :
          outer_(outer),
          foreignTableName_(std::move(foreignTableName)),
          joinTable_(std::move(joinTable)),
          joinColumn_(std::move(joinColumn)),
          foreignTable_(std::move(foreignTable)),
          foreignColumn_(std::move(foreignColumn))
      {
      }

      bool isOuterJoin() const
      {
        return outer_;
      }

      const std::string& getForeignTableName() const
      {
        return foreignTableName_;
      }

      const std::string& getJoinTable() const
      {
        return joinTable_;
      }

      const std::string& getJoinColumn() const
      {
        return joinColumn_;
      }

      const std::string& getForeignTable() const
      {
        return foreignTable_;
      }

      const std::string& getForeignColumn() const
      {
        return foreignColumn_;
      }

    private:
      bool outer_ = false;
      std::string foreignTableName_;
      std::string joinTable_;
      std::string joinColumn_;
      std::string foreignTable_;
      std::string foreignColumn_;

    };

    friend std::ostream& operator<<(std::ostream& oss, const join& j);

    class condition {
    public:
      enum class type {
        empty,
        singleton,
        group
      };

      enum class comparison {
        equals,
        does_not_equal,
        is_greater_than,
        is_at_most,
        is_less_than,
        is_at_least,
        is_like,
        is_not_like,
        is_not_null,
        is_null
      };

      // Copy and move constructors

      condition(const condition& other);
      condition(condition&& other);

      // Assignment

      condition& operator=(condition other);

      // Swap

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

      // Destructor

      ~condition();

      // Accessors

      type getType() const
      {
        return type_;
      }

      // Empty

      condition();

      // Singleton

      condition(std::string table, std::string column, bool isNull);

      condition(std::string table, std::string column, comparison comp, binding value, object parentObject = object::undefined);

      // Group

      explicit condition(bool orlogic);

      condition& operator+=(condition n);

      condition& operator&=(condition n);

      const std::list<condition>& getChildren() const;

      // Utility

      std::string toSql(bool toplevel, bool debug = false) const;

      std::list<binding> flattenBindings() const;

      condition flatten() const;

      condition resolveCompareFields(object context, std::string tableName) const;

    private:
      union {
        struct {
          std::string table_;
          std::string column_;
          comparison comparison_;
          binding value_;
          object parentObject_;
        } singleton_;
        struct {
          std::list<condition> children_;
          bool orlogic_;
        } group_;
      };
      type type_;
    };

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

    class with {
    public:

      with(
        std::string identifier,
        field f,
        std::map<std::string, std::string> tables,
        std::string topTable,
        condition where,
        std::list<join> joins,
        bool recursive) :
          identifier_(std::move(identifier)),
          field_(f),
          tables_(std::move(tables)),
          topTable_(std::move(topTable)),
          topCondition_(std::move(where)),
          joins_(std::move(joins)),
          recursive_(recursive)
      {
      }

      const std::string& getIdentifier() const
      {
        return identifier_;
      }

      field getField() const
      {
        return field_;
      }

      std::string getTableForId(std::string identifier) const
      {
        return tables_.at(identifier);
      }

      const std::string& getTopTable() const
      {
        return topTable_;
      }

      const condition& getCondition() const
      {
        return topCondition_;
      }

      const std::list<join>& getJoins() const
      {
        return joins_;
      }

      bool isRecursive() const
      {
        return recursive_;
      }

    private:
      std::string identifier_;
      field field_;
      std::map<std::string, std::string> tables_;
      std::string topTable_;
      condition topCondition_;
      std::list<join> joins_;
      bool recursive_;

    };

    static constexpr const char* getTableForContext(object context)
    {
      return (context == object::notion) ? "notions"
        : (context == object::word) ? "words"
        : (context == object::frame) ? "frames"
        : (context == object::part) ? "parts"
        : (context == object::form) ? "forms"
        : (context == object::pronunciation) ? "pronunciations"
        : throw std::domain_error("Provided context has no associated table");
    }

    static const std::list<field> getSelectForContext(object context);

    statement(object context, std::string tableName, filter clause, int nextTableId = 0, int nextWithId = 0);

    condition parseFilter(filter queryFilter);

    std::string instantiateTable(std::string name);

    std::string instantiateWith(std::string name);

    condition integrate(statement subStmt, bool cte = false);

    int nextTableId_;
    int nextWithId_;

    object context_;
    std::map<std::string, std::string> tables_;
    std::string topTable_;
    std::list<join> joins_;
    std::list<with> withs_;
    condition topCondition_;

  };

};

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