<|start_filename|>Pods/Realm/include/core/realm/util/compression.hpp<|end_filename|>
/*************************************************************************
 *
 * REALM CONFIDENTIAL
 * __________________
 *
 *  [2011] - [2016] Realm Inc
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Realm Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Realm Incorporated
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Realm Incorporated.
 *
 **************************************************************************/

#ifndef REALM_UTIL_COMPRESSION_HPP
#define REALM_UTIL_COMPRESSION_HPP

#include <system_error>
#include <vector>
#include <string>
#include <stdint.h>

namespace realm {
namespace util {
namespace compression {

enum class error {
    out_of_memory = 1,
    deflate_buffer_too_small = 2,
    deflate_error = 3,
    corrupt_input = 4,
    incorrect_inflated_size = 5,
    inflate_error = 6
};


class error_category: public std::error_category {
public:
    const char* name() const noexcept final;
    std::string message(int) const final;
};

const std::error_category& compression_error_category();


std::error_condition make_error_condition(error);

} // namespace compression
} // namespace util
} // namespace realm

namespace std {
    template<>
    struct is_error_condition_enum<realm::util::compression::error> {
        static const bool value = true;
    };
}

namespace realm {
namespace util {
namespace compression {

/// deflate_bound() calculates an upper bound on the size of the compressed data. The caller can use this function to
/// allocate memory buffer calling deflate().
/// \param uncompressed_buf is the buffer with uncompresed data. The size of the uncompressed data is \param
/// uncompressed_size.
/// \param compression_level is described under deflate().
/// \param bound is set to the upper bound at return.
/// The return value is a error_condition of category compression::error_category.
std::error_condition deflate_bound(const char* uncompressed_buf, size_t uncompressed_size, size_t& bound, int compression_level = 1);

/// deflate() deflates the data in the \param uncompressed_buf of size \param uncompressed_size
/// into compressed_buf. deflate() resizes compressed_buf. At return, \param compressed_buf has the
/// size of the deflated data.
/// \param compression_level is [1-9] with 1 the fastest for the current zlib implementation.
/// The return value is a error_condition of category compression::error_category.
std::error_condition deflate(const char* uncompressed_buf, size_t uncompressed_size,
                             char* compressed_buf, size_t compressed_buf_size,
                             size_t& compressed_size, int compression_level = 1);

/// inflate() inflates the data in \param compressed_buf of size \param compresed_size into
/// \param decompressed_buf. \param decompressed_size is the expected size of the inflated data.
/// \param decompressed_buf must have size at least \param decompressed_size.
/// inflate() throws on errors, including the error where the size of the decompressed data is unequal to
/// decompressed_size.
/// The return value is a error_condition of category compression::error_category.
std::error_condition inflate(const char* compressed_buf, size_t compressed_size, char* decompressed_buf, size_t decompressed_size);




} // namespace compression
} // namespace util
} // namespace realm

#endif // REALM_UTIL_COMPRESSION_HPP


<|start_filename|>Pods/Realm/include/object_accessor.hpp<|end_filename|>
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#ifndef REALM_OBJECT_ACCESSOR_HPP
#define REALM_OBJECT_ACCESSOR_HPP

#include "list.hpp"
#include "object_schema.hpp"
#include "object_store.hpp"
#include "results.hpp"
#include "schema.hpp"
#include "shared_realm.hpp"
#include "util/format.hpp"

#include <string>
#include <realm/link_view.hpp>
#include <realm/table_view.hpp>

namespace realm {

    class Object {
    public:
        Object(SharedRealm r, const ObjectSchema &s, Row o) : m_realm(r), m_object_schema(&s), m_row(o) {}

        // property getter/setter
        template<typename ValueType, typename ContextType>
        inline void set_property_value(ContextType ctx, std::string prop_name, ValueType value, bool try_update);

        template<typename ValueType, typename ContextType>
        inline ValueType get_property_value(ContextType ctx, std::string prop_name);

        // create an Object from a native representation
        template<typename ValueType, typename ContextType>
        static inline Object create(ContextType ctx, SharedRealm realm, const ObjectSchema &object_schema, ValueType value, bool try_update);

        template<typename ValueType, typename ContextType>
        static Object get_for_primary_key(ContextType ctx, SharedRealm realm, const ObjectSchema &object_schema, ValueType primary_value);

        SharedRealm realm() const { return m_realm; }
        const ObjectSchema &get_object_schema() const { return *m_object_schema; }
        Row row() const { return m_row; }

        bool is_valid() const { return m_row.is_attached(); }

    private:
        SharedRealm m_realm;
        const ObjectSchema *m_object_schema;
        Row m_row;

        template<typename ValueType, typename ContextType>
        inline void set_property_value_impl(ContextType ctx, const Property &property, ValueType value, bool try_update);
        template<typename ValueType, typename ContextType>
        inline ValueType get_property_value_impl(ContextType ctx, const Property &property);

        template<typename ValueType, typename ContextType>
        static size_t get_for_primary_key_impl(ContextType ctx, const ConstTableRef &table, const Property &primary_prop, ValueType primary_value);
        
        inline void verify_attached();
    };

    //
    // Value converters - template specializations must be implemented for each platform in order to call templated methods on Object
    //
    template<typename ValueType, typename ContextType>
    class NativeAccessor {
    public:
        static bool dict_has_value_for_key(ContextType ctx, ValueType dict, const std::string &prop_name);
        static ValueType dict_value_for_key(ContextType ctx, ValueType dict, const std::string &prop_name);

        static bool has_default_value_for_property(ContextType ctx, Realm *realm, const ObjectSchema &object_schema, const std::string &prop_name);
        static ValueType default_value_for_property(ContextType ctx, Realm *realm, const ObjectSchema &object_schema, const std::string &prop_name);

        static bool to_bool(ContextType, ValueType &);
        static ValueType from_bool(ContextType, bool);
        static long long to_long(ContextType, ValueType &);
        static ValueType from_long(ContextType, long long);
        static float to_float(ContextType, ValueType &);
        static ValueType from_float(ContextType, float);
        static double to_double(ContextType, ValueType &);
        static ValueType from_double(ContextType, double);
        static std::string to_string(ContextType, ValueType &);
        static ValueType from_string(ContextType, StringData);
        static std::string to_binary(ContextType, ValueType &);
        static ValueType from_binary(ContextType, BinaryData);
        static Timestamp to_timestamp(ContextType, ValueType &);
        static ValueType from_timestamp(ContextType, Timestamp);

        static bool is_null(ContextType, ValueType &);
        static ValueType null_value(ContextType);

        // convert value to persisted object
        // for existing objects return the existing row index
        // for new/updated objects return the row index
        static size_t to_object_index(ContextType ctx, SharedRealm realm, ValueType &val, const std::string &type, bool try_update);
        static ValueType from_object(ContextType ctx, Object);

        // object index for an existing object
        static size_t to_existing_object_index(ContextType ctx, SharedRealm realm, ValueType &val);

        // list value accessors
        static size_t list_size(ContextType ctx, ValueType &val);
        static ValueType list_value_at_index(ContextType ctx, ValueType &val, size_t index);
        static ValueType from_list(ContextType ctx, List);

        // results value accessors
        static ValueType from_results(ContextType ctx, Results);

        //
        // Deprecated
        //
        static Mixed to_mixed(ContextType, ValueType&) { throw std::logic_error("'Any' type is unsupported"); }
    };

    struct InvalidatedObjectException : public std::logic_error {
        InvalidatedObjectException(const std::string& object_type, const std::string& message) :
            std::logic_error(message), object_type(object_type) {}
        const std::string object_type;
    };
    
    struct InvalidPropertyException : public std::logic_error {
        InvalidPropertyException(const std::string& object_type, const std::string& property_name, const std::string& message) :
            std::logic_error(message), object_type(object_type), property_name(property_name) {}
        const std::string object_type;
        const std::string property_name;
    };

    struct MissingPropertyValueException : public std::logic_error {
        MissingPropertyValueException(const std::string& object_type, const std::string& property_name, const std::string& message) :
            std::logic_error(message), object_type(object_type), property_name(property_name) {}
        const std::string object_type;
        const std::string property_name;
    };

    struct MissingPrimaryKeyException : public std::logic_error {
        MissingPrimaryKeyException(const std::string& object_type, const std::string& message) : std::logic_error(message), object_type(object_type) {}
        const std::string object_type;
    };

    struct ReadOnlyPropertyException : public std::logic_error {
        ReadOnlyPropertyException(const std::string& object_type, const std::string& property_name, const std::string& message) :
            std::logic_error(message), object_type(object_type), property_name(property_name) {}
        const std::string object_type;
        const std::string property_name;
    };

    struct MutationOutsideTransactionException : public std::logic_error {
        MutationOutsideTransactionException(const std::string& message) : std::logic_error(message) {}
    };

    //
    // template method implementations
    //
    template <typename ValueType, typename ContextType>
    inline void Object::set_property_value(ContextType ctx, std::string prop_name, ValueType value, bool try_update)
    {
        const Property *prop = m_object_schema->property_for_name(prop_name);
        if (!prop) {
            throw InvalidPropertyException(m_object_schema->name, prop_name,
                "Setting invalid property '" + prop_name + "' on object '" + m_object_schema->name + "'.");
        }
        set_property_value_impl(ctx, *prop, value, try_update);
    }

    template <typename ValueType, typename ContextType>
    inline ValueType Object::get_property_value(ContextType ctx, std::string prop_name)
    {
        const Property *prop = m_object_schema->property_for_name(prop_name);
        if (!prop) {
            throw InvalidPropertyException(m_object_schema->name, prop_name,
                "Getting invalid property '" + prop_name + "' on object '" + m_object_schema->name + "'.");
        }
        return get_property_value_impl<ValueType>(ctx, *prop);
    }

    template <typename ValueType, typename ContextType>
    inline void Object::set_property_value_impl(ContextType ctx, const Property &property, ValueType value, bool try_update)
    {
        using Accessor = NativeAccessor<ValueType, ContextType>;

        verify_attached();

        if (!m_realm->is_in_transaction()) {
            throw MutationOutsideTransactionException("Can only set property values within a transaction.");
        }

        size_t column = property.table_column;
        if (property.is_nullable && Accessor::is_null(ctx, value)) {
            if (property.type == PropertyType::Object) {
                m_row.nullify_link(column);
            }
            else {
                m_row.set_null(column);
            }
            return;
        }

        switch (property.type) {
            case PropertyType::Bool:
                m_row.set_bool(column, Accessor::to_bool(ctx, value));
                break;
            case PropertyType::Int:
                if (property.is_primary)
                    m_row.set_int_unique(column, Accessor::to_long(ctx, value));
                else
                    m_row.set_int(column, Accessor::to_long(ctx, value));
                break;
            case PropertyType::Float:
                m_row.set_float(column, Accessor::to_float(ctx, value));
                break;
            case PropertyType::Double:
                m_row.set_double(column, Accessor::to_double(ctx, value));
                break;
            case PropertyType::String: {
                auto string_value = Accessor::to_string(ctx, value);
                if (property.is_primary)
                    m_row.set_string_unique(column, string_value);
                else
                    m_row.set_string(column, string_value);
                break;
            }
            case PropertyType::Data:
                m_row.set_binary(column, BinaryData(Accessor::to_binary(ctx, value)));
                break;
            case PropertyType::Any:
                m_row.set_mixed(column, Accessor::to_mixed(ctx, value));
                break;
            case PropertyType::Date:
                m_row.set_timestamp(column, Accessor::to_timestamp(ctx, value));
                break;
            case PropertyType::Object: {
                if (Accessor::is_null(ctx, value)) {
                    m_row.nullify_link(column);
                }
                else {
                    m_row.set_link(column, Accessor::to_object_index(ctx, m_realm, value, property.object_type, try_update));
                }
                break;
            }
            case PropertyType::Array: {
                realm::LinkViewRef link_view = m_row.get_linklist(column);
                link_view->clear();
                if (!Accessor::is_null(ctx, value)) {
                    size_t count = Accessor::list_size(ctx, value);
                    for (size_t i = 0; i < count; i++) {
                        ValueType element = Accessor::list_value_at_index(ctx, value, i);
                        link_view->add(Accessor::to_object_index(ctx, m_realm, element, property.object_type, try_update));
                    }
                }
                break;
            }
            case PropertyType::LinkingObjects:
                throw ReadOnlyPropertyException(m_object_schema->name, property.name,
                                                util::format("Cannot modify read-only property '%1.%2'",
                                                             m_object_schema->name, property.name));
        }
    }

    template <typename ValueType, typename ContextType>
    inline ValueType Object::get_property_value_impl(ContextType ctx, const Property &property)
    {
        using Accessor = NativeAccessor<ValueType, ContextType>;

        verify_attached();

        size_t column = property.table_column;
        if (property.is_nullable && m_row.is_null(column)) {
            return Accessor::null_value(ctx);
        }

        switch (property.type) {
            case PropertyType::Bool:
                return Accessor::from_bool(ctx, m_row.get_bool(column));
            case PropertyType::Int:
                return Accessor::from_long(ctx, m_row.get_int(column));
            case PropertyType::Float:
                return Accessor::from_float(ctx, m_row.get_float(column));
            case PropertyType::Double:
                return Accessor::from_double(ctx, m_row.get_double(column));
            case PropertyType::String:
                return Accessor::from_string(ctx, m_row.get_string(column));
            case PropertyType::Data:
                return Accessor::from_binary(ctx, m_row.get_binary(column));
            case PropertyType::Any:
                throw "Any not supported";
            case PropertyType::Date:
                return Accessor::from_timestamp(ctx, m_row.get_timestamp(column));
            case PropertyType::Object: {
                auto linkObjectSchema = m_realm->schema().find(property.object_type);
                TableRef table = ObjectStore::table_for_object_type(m_realm->read_group(), linkObjectSchema->name);
                if (m_row.is_null_link(property.table_column)) {
                    return Accessor::null_value(ctx);
                }
                return Accessor::from_object(ctx, std::move(Object(m_realm, *linkObjectSchema, table->get(m_row.get_link(column)))));
            }
            case PropertyType::Array:
                return Accessor::from_list(ctx, List(m_realm, static_cast<LinkViewRef>(m_row.get_linklist(column))));
            case PropertyType::LinkingObjects: {
                auto target_object_schema = m_realm->config().schema->find(property.object_type);
                auto link_property = target_object_schema->property_for_name(property.link_origin_property_name);
                TableRef table = ObjectStore::table_for_object_type(m_realm->read_group(), target_object_schema->name);
                auto tv = m_row.get_table()->get_backlink_view(m_row.get_index(), table.get(), link_property->table_column);
                Results results(m_realm, std::move(tv));
                return Accessor::from_results(ctx, std::move(results));
            }
        }
    }

    template<typename ValueType, typename ContextType>
    inline Object Object::create(ContextType ctx, SharedRealm realm, const ObjectSchema &object_schema, ValueType value, bool try_update)
    {
        using Accessor = NativeAccessor<ValueType, ContextType>;

        if (!realm->is_in_transaction()) {
            throw MutationOutsideTransactionException("Can only create objects within a transaction.");
        }

        // get or create our accessor
        bool created = false;

        // try to get existing row if updating
        size_t row_index = realm::not_found;
        realm::TableRef table = ObjectStore::table_for_object_type(realm->read_group(), object_schema.name);
        const Property *primary_prop = object_schema.primary_key_property();

        if (primary_prop) {
            // search for existing object based on primary key type
            ValueType primary_value = Accessor::dict_value_for_key(ctx, value, object_schema.primary_key);
            row_index = get_for_primary_key_impl(ctx, table, *primary_prop, primary_value);

            if (row_index == realm::not_found) {
                row_index = table->add_empty_row();
                created = true;
                Object object(realm, object_schema, table->get(row_index));
                object.set_property_value_impl(ctx, *primary_prop, primary_value, try_update);
            }
            else if (!try_update) {
                throw std::logic_error(util::format("Attempting to create an object of type '%1' with an existing primary key value.", object_schema.name));
            }
        }
        else {
            row_index = table->add_empty_row();
            created = true;
        }

        // populate
        Object object(realm, object_schema, table->get(row_index));
        for (const Property& prop : object_schema.persisted_properties) {
            if (!prop.is_primary) {
                if (Accessor::dict_has_value_for_key(ctx, value, prop.name)) {
                    object.set_property_value_impl(ctx, prop, Accessor::dict_value_for_key(ctx, value, prop.name), try_update);
                }
                else if (created) {
                    if (Accessor::has_default_value_for_property(ctx, realm.get(), object_schema, prop.name)) {
                        object.set_property_value_impl(ctx, prop, Accessor::default_value_for_property(ctx, realm.get(), object_schema, prop.name), try_update);
                    }
                    else if (prop.is_nullable || prop.type == PropertyType::Array) {
                        object.set_property_value_impl(ctx, prop, Accessor::null_value(ctx), try_update);
                    }
                    else {
                        throw MissingPropertyValueException(object_schema.name, prop.name,
                            "Missing property value for property " + prop.name);
                    }
                }
            }
        }
        return object;
    }

    template<typename ValueType, typename ContextType>
    inline Object Object::get_for_primary_key(ContextType ctx, SharedRealm realm, const ObjectSchema &object_schema, ValueType primary_value)
    {
        auto primary_prop = object_schema.primary_key_property();
        if (!primary_prop) {
            throw MissingPrimaryKeyException(object_schema.name, object_schema.name + " does not have a primary key");
        }

        auto table = ObjectStore::table_for_object_type(realm->read_group(), object_schema.name);
        auto row_index = get_for_primary_key_impl(ctx, table, *primary_prop, primary_value);

        return Object(realm, object_schema, row_index == realm::not_found ? Row() : table->get(row_index));
    }

    template<typename ValueType, typename ContextType>
    inline size_t Object::get_for_primary_key_impl(ContextType ctx, const ConstTableRef &table, const Property &primary_prop, ValueType primary_value) {
        using Accessor = NativeAccessor<ValueType, ContextType>;

        if (primary_prop.type == PropertyType::String) {
            auto primary_string = Accessor::to_string(ctx, primary_value);
            return table->find_first_string(primary_prop.table_column, primary_string);
        }
        else {
            return table->find_first_int(primary_prop.table_column, Accessor::to_long(ctx, primary_value));
        }
    }

    inline void Object::verify_attached() {
        if (!m_row.is_attached()) {
            throw InvalidatedObjectException(m_object_schema->name,
                "Accessing object of type " + m_object_schema->name + " which has been deleted"
            );
        }
    }

    //
    // List implementation
    //
    template<typename ValueType, typename ContextType>
    void List::add(ContextType ctx, ValueType value)
    {
        add(NativeAccessor<ValueType, ContextType>::to_object_index(ctx, m_realm, value, get_object_schema().name, false));
    }

    template<typename ValueType, typename ContextType>
    void List::insert(ContextType ctx, ValueType value, size_t list_ndx)
    {
        insert(list_ndx, NativeAccessor<ValueType, ContextType>::to_object_index(ctx, m_realm, value, get_object_schema().name, false));
    }

    template<typename ValueType, typename ContextType>
    void List::set(ContextType ctx, ValueType value, size_t list_ndx)
    {
        set(list_ndx, NativeAccessor<ValueType, ContextType>::to_object_index(ctx, m_realm, value, get_object_schema().name, false));
    }
}

#endif /* defined(REALM_OBJECT_ACCESSOR_HPP) */


<|start_filename|>Pods/Realm/include/core/realm/util/websocket.hpp<|end_filename|>
/*************************************************************************
 *
 * REALM CONFIDENTIAL
 * __________________
 *
 *  [2011] - [2016] Realm Inc
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Realm Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Realm Incorporated
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Realm Incorporated.
 *
 **************************************************************************/

#ifndef REALM_UTIL_WEBSOCKET_HPP
#define REALM_UTIL_WEBSOCKET_HPP

#include <random>
#include <system_error>

#include <realm/util/logger.hpp>


namespace realm {
namespace util {
namespace websocket {

using WriteCompletionHandler =
    std::function<void(std::error_code, size_t num_bytes_transferred)>;
using ReadCompletionHandler =
    std::function<void(std::error_code, size_t num_bytes_transferred)>;

class Config {
public:

    /// The Socket uses the caller supplied logger for logging.
    virtual util::Logger& get_logger() = 0;

    /// The Socket needs random numbers to satisfy the Websocket protocol.
    /// The caller must supply a random number generator.
    virtual std::mt19937_64& get_random() = 0;

    /// The three functions below are used by the Socket to read and write to the underlying
    /// stream. The functions will typically be implemented as wrappers to a TCP/TLS stream,
    /// but could also map to pure memory streams. These functions abstract away the details of
    /// the underlying sockets.
    /// The functions have the same semantics as util::Socket.
    virtual void async_write(const char* data, size_t size, WriteCompletionHandler handler) = 0;
    virtual void async_read(char* buffer, size_t size, ReadCompletionHandler handler) = 0;
    virtual void async_read_until(char* buffer, size_t size, char delim, ReadCompletionHandler handler) = 0;


    /// websocket_handshake_completion_handler() is called when the websocket is connected, .i.e.
    /// after the handshake is done. It is not allowed to send messages on the socket before the
    /// handshake is done. No message_received callbacks will be called before the handshake is done.
    virtual void websocket_handshake_completion_handler() = 0;


    /// websocket_read_error_handler() and websocket_write_error_handler() are called when an
    /// error occurs on the underlying stream given by the async_read and async_write functions above.
    /// The error_code is passed through.
    /// websocket_protocol_error_handler() is called when there is an protocol error in the incoming
    /// messages.
    /// After calling any of these error callbacks, the Socket will move into the stopped state, and
    /// no more messages should be sent, or will be received.
    virtual void websocket_read_error_handler(std::error_code) = 0;
    virtual void websocket_write_error_handler(std::error_code) = 0;
    virtual void websocket_protocol_error_handler() = 0;


    /// The five callback functions below are called whenever a full message has arrived.
    /// The Socket defragments fragmented messages internally and delivers a full message.
    /// The message is delivered in the buffer \param data of size \param size.
    /// The buffer is only valid until the function returns.
    virtual void websocket_text_message_received(const char* data, size_t size);
    virtual void websocket_binary_message_received(const char* data, size_t size);
    virtual void websocket_close_message_received(const char* data, size_t size);
    virtual void websocket_ping_message_received(const char* data, size_t size);
    virtual void websocket_pong_message_received(const char* data, size_t size);
};


enum class Opcode {
    continuation =  0,
    text         =  1,
    binary       =  2,
    close        =  8,
    ping         =  9,
    pong         = 10
};


class Socket {
public:

    Socket(Config&);
    Socket(Socket&&) noexcept;
    ~Socket() noexcept;

    /// initiate_client_handshake() starts the Socket in client mode. The Socket will send
    /// the HTTP request that initiates the WebSocket protocol and wait for the HTTP response
    /// from the server. The HTTP request will contain the \param request_uri in the
    /// HTTP request line. The \param host will be sent as the value in a HTTP Host header line.
    /// When the server responds with a valid HTTP response, the callback function
    /// websocket_handshake_completion_handler() is called. Messages can only be sent and
    /// received after the handshake has completed.
    void initiate_client_handshake(std::string request_uri, std::string host);

    /// initiate_server_handshake() starts the Socket in server mode. It will wait for a
    /// HTTP request from a client and respond with a HTTP response. After sending a HTTP
    /// response, websocket_handshake_completion_handler() is called. Messages can only be sent and
    /// received after the handshake has completed.
    void initiate_server_handshake();


    /// The async_write_* functions send frames. Only one frame should be sent at a time,
    /// meaning that the user must wait for the handler to be called before sending the next frame.
    /// The handler is type std::function<void()> and is called when the frame has been successfully
    /// sent. In case of errors, the Config::websocket_write_error_handler() is called.

    /// async_write_frame() sends a single frame with the fin bit set to 0 or 1 from \param fin, and the opcode
    /// set by \param opcode. The frame payload is taken from \param data of size \param size. \param handler is
    /// called when the frame has been successfully sent. Error s are reported through
    /// websocket_write_error_handler() in Config.
    /// This function is rather low level and should only be used with knowledge of the WebSocket protocol.
    /// The five utility functions below are recommended for message sending.
    void async_write_frame(bool fin, Opcode opcode, const char* data, size_t size, std::function<void()> handler);

    /// Five utility functions used to send whole messages. These five functions are implemented in terms of
    /// async_write_frame(). These functions send whole unfragmented messages. These functions should be
    /// preferred over async_write_frame() for most use cases.
    void async_write_text(const char* data, size_t size, std::function<void()> handler);
    void async_write_binary(const char* data, size_t size, std::function<void()> handler);
    void async_write_close(const char* data, size_t size, std::function<void()> handler);
    void async_write_ping(const char* data, size_t size, std::function<void()> handler);
    void async_write_pong(const char* data, size_t size, std::function<void()> handler);

    /// stop() stops the socket. The socket will stop processing incoming data, sending data, and calling callbacks.
    /// It is an error to attempt to send a message after stop() has been called. stop() will typically be called
    /// before the underlying TCP/TLS connection is closed. The Socket can be restarted with
    /// initiate_client_handshake() and initiate_server_handshake().
    void stop() noexcept;

private:
    class Impl;
    std::unique_ptr<Impl> m_impl;
};

} // namespace websocket
} // namespace util
} // namespace realm

#endif // REALM_UTIL_WEBSOCKET_HPP


<|start_filename|>Pods/Realm/include/core/realm/timestamp.hpp<|end_filename|>
/*************************************************************************
 *
 * Copyright 2016 Realm Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 **************************************************************************/

#ifndef REALM_TIMESTAMP_HPP
#define REALM_TIMESTAMP_HPP

#include <cstdint>
#include <ostream>
#include <realm/util/assert.hpp>

namespace realm {

class Timestamp {
public:
    // Construct from the number of seconds and nanoseconds since the UNIX epoch: 00:00:00 UTC on 1 January 1970
    //
    // To split a native nanosecond representation, only division and modulo are necessary:
    //
    //     s = native_nano / nanoseconds_per_second
    //     n = native_nano % nanoseconds_per_second
    //     Timestamp ts(s, n);
    //
    // To convert back into native nanosecond representation, simple multiply and add:
    //
    //     native_nano = ts.s * nanoseconds_per_second + ts.n
    //
    // Specifically this allows the nanosecond part to become negative (only) for Timestamps before the UNIX epoch.
    // Usually this will not need special attention, but for reference, valid Timestamps will have one of the
    // following sign combinations:
    //
    //     s | n
    //     -----
    //     + | +
    //     + | 0
    //     0 | +
    //     0 | 0
    //     0 | -
    //     - | 0
    //     - | -
    //
    // Examples:
    //     The UNIX epoch is constructed by Timestamp(0, 0)
    //     Relative times are constructed as follows:
    //       +1 second is constructed by Timestamp(1, 0)
    //       +1 nanosecond is constructed by Timestamp(0, 1)
    //       +1.1 seconds (1100 milliseconds after the epoch) is constructed by Timestamp(1, 100000000)
    //       -1.1 seconds (1100 milliseconds before the epoch) is constructed by Timestamp(-1, -100000000)
    //
    Timestamp(int64_t seconds, int32_t nanoseconds)
        : m_seconds(seconds)
        , m_nanoseconds(nanoseconds)
        , m_is_null(false)
    {
        REALM_ASSERT_EX(-nanoseconds_per_second < nanoseconds && nanoseconds < nanoseconds_per_second, nanoseconds);
        const bool both_non_negative = seconds >= 0 && nanoseconds >= 0;
        const bool both_non_positive = seconds <= 0 && nanoseconds <= 0;
        REALM_ASSERT_EX(both_non_negative || both_non_positive, both_non_negative, both_non_positive);
    }
    Timestamp(realm::null)
        : m_is_null(true)
    {
    }
    Timestamp()
        : Timestamp(null{})
    {
    }

    bool is_null() const
    {
        return m_is_null;
    }

    int64_t get_seconds() const noexcept
    {
        REALM_ASSERT(!m_is_null);
        return m_seconds;
    }

    int32_t get_nanoseconds() const noexcept
    {
        REALM_ASSERT(!m_is_null);
        return m_nanoseconds;
    }

    // Note that these operators do not work if one of the Timestamps are null! Please use realm::Greater,
    // realm::Equal etc instead. This is in order to collect all treatment of null behaviour in a single place for all
    // types (query_conditions.hpp) to ensure that all types sort and compare null vs. non-null in the same manner,
    // especially for int/float where we cannot override operators. This design is open for discussion, though,
    // because it has usability drawbacks
    bool operator==(const Timestamp& rhs) const
    {
        REALM_ASSERT(!is_null());
        REALM_ASSERT(!rhs.is_null());
        return m_seconds == rhs.m_seconds && m_nanoseconds == rhs.m_nanoseconds;
    }
    bool operator!=(const Timestamp& rhs) const
    {
        REALM_ASSERT(!is_null());
        REALM_ASSERT(!rhs.is_null());
        return m_seconds != rhs.m_seconds || m_nanoseconds != rhs.m_nanoseconds;
    }
    bool operator>(const Timestamp& rhs) const
    {
        REALM_ASSERT(!is_null());
        REALM_ASSERT(!rhs.is_null());
        return (m_seconds > rhs.m_seconds) || (m_seconds == rhs.m_seconds && m_nanoseconds > rhs.m_nanoseconds);
    }
    bool operator<(const Timestamp& rhs) const
    {
        REALM_ASSERT(!is_null());
        REALM_ASSERT(!rhs.is_null());
        return (m_seconds < rhs.m_seconds) || (m_seconds == rhs.m_seconds && m_nanoseconds < rhs.m_nanoseconds);
    }
    bool operator<=(const Timestamp& rhs) const
    {
        REALM_ASSERT(!is_null());
        REALM_ASSERT(!rhs.is_null());
        return *this < rhs || *this == rhs;
    }
    bool operator>=(const Timestamp& rhs) const
    {
        REALM_ASSERT(!is_null());
        REALM_ASSERT(!rhs.is_null());
        return *this > rhs || *this == rhs;
    }
    Timestamp& operator=(const Timestamp& rhs) = default;

    template <class Ch, class Tr>
    friend std::basic_ostream<Ch, Tr>& operator<<(std::basic_ostream<Ch, Tr>& out, const Timestamp&);
    static constexpr int32_t nanoseconds_per_second = 1000000000;

private:
    int64_t m_seconds;
    int32_t m_nanoseconds;
    bool m_is_null;
};

// LCOV_EXCL_START
template <class C, class T>
inline std::basic_ostream<C, T>& operator<<(std::basic_ostream<C, T>& out, const Timestamp& d)
{
    out << "Timestamp(" << d.m_seconds << ", " << d.m_nanoseconds << ")";
    return out;
}
// LCOV_EXCL_STOP

} // namespace realm

#endif // REALM_TIMESTAMP_HPP


<|start_filename|>Pods/Realm/include/impl/sync_client.hpp<|end_filename|>
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#ifndef REALM_OS_SYNC_CLIENT_HPP
#define REALM_OS_SYNC_CLIENT_HPP

#include <realm/sync/client.hpp>

#include <thread>

namespace realm {
namespace _impl {

using Reconnect = sync::Client::Reconnect;

struct SyncClient {
    sync::Client client;

    SyncClient(std::unique_ptr<util::Logger> logger,
               std::function<sync::Client::ErrorHandler> handler,
               Reconnect reconnect_mode = Reconnect::normal,
               bool verify_ssl = true)
    : client(make_client(*logger, reconnect_mode, verify_ssl)) // Throws
    , m_logger(std::move(logger))
    , m_thread([this, handler=std::move(handler)] {
        client.set_error_handler(std::move(handler));
        client.run();
    }) // Throws
    {
    }

    ~SyncClient()
    {
        client.stop();
        m_thread.join();
    }

private:
    static sync::Client make_client(util::Logger& logger, Reconnect reconnect_mode, bool verify_ssl)
    {
        sync::Client::Config config;
        config.logger = &logger;
        config.reconnect = std::move(reconnect_mode);
        config.verify_servers_ssl_certificate = verify_ssl;
        return sync::Client(std::move(config)); // Throws
    }

    const std::unique_ptr<util::Logger> m_logger;
    std::thread m_thread;
};

}
}

#endif // REALM_OS_SYNC_CLIENT_HPP


<|start_filename|>Pods/Target Support Files/RealmSwift/RealmSwift-umbrella.h<|end_filename|>
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif


FOUNDATION_EXPORT double RealmSwiftVersionNumber;
FOUNDATION_EXPORT const unsigned char RealmSwiftVersionString[];



<|start_filename|>Pods/Realm/include/core/realm/table_macros.hpp<|end_filename|>
/*************************************************************************
 *
 * Copyright 2016 Realm Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 **************************************************************************/

/*************************************************************************
 *
 * CAUTION:  DO NOT EDIT THIS FILE -- YOUR CHANGES WILL BE LOST!
 *
 * This file is generated by Cheetah from the following template:
 *
 *     table_macros.hpp.cheetah
 *
 *************************************************************************/

#ifndef REALM_TABLE_MACROS_HPP
#define REALM_TABLE_MACROS_HPP

#include <realm/table_basic.hpp>

/*****************************************************************************
 *                                                                           *
 *      THIS INTERFACE IS DEPRECATED AND MAY BE REMOVED WITHOUT NOTICE       *
 *                                                                           *
 ****************************************************************************/

// clang-format off

#define REALM_TABLE_1(Table, name1, type1) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        ColNames(Init i) noexcept: name1(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1)); \
        } \
        void insert(size_t _realm_i, type1 name1) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1)); \
        } \
        void set(size_t _realm_i, type1 name1) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_2(Table, name1, type1, name2, type2) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        ColNames(Init i) noexcept: name1(i), name2(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_3(Table, name1, type1, name2, type2, name3, type3) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_4(Table, name1, type1, name2, type2, name3, type3, name4, type4) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_5(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_6(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_7(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_8(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_9(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_10(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9, name10, type10) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns9; \
    typedef ::realm::util::TypeAppend< Columns9, type10 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        typename Col<9>::type name10; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i), name10(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
        names[9] = realm::StringData(#name10, sizeof #name10 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_11(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9, name10, type10, name11, type11) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns9; \
    typedef ::realm::util::TypeAppend< Columns9, type10 >::type Columns10; \
    typedef ::realm::util::TypeAppend< Columns10, type11 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        typename Col<9>::type name10; \
        typename Col<10>::type name11; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i), name10(i), name11(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
        names[9] = realm::StringData(#name10, sizeof #name10 - 1); \
        names[10] = realm::StringData(#name11, sizeof #name11 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_12(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9, name10, type10, name11, type11, name12, type12) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns9; \
    typedef ::realm::util::TypeAppend< Columns9, type10 >::type Columns10; \
    typedef ::realm::util::TypeAppend< Columns10, type11 >::type Columns11; \
    typedef ::realm::util::TypeAppend< Columns11, type12 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        typename Col<9>::type name10; \
        typename Col<10>::type name11; \
        typename Col<11>::type name12; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i), name10(i), name11(i), name12(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
        names[9] = realm::StringData(#name10, sizeof #name10 - 1); \
        names[10] = realm::StringData(#name11, sizeof #name11 - 1); \
        names[11] = realm::StringData(#name12, sizeof #name12 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_13(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9, name10, type10, name11, type11, name12, type12, name13, type13) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns9; \
    typedef ::realm::util::TypeAppend< Columns9, type10 >::type Columns10; \
    typedef ::realm::util::TypeAppend< Columns10, type11 >::type Columns11; \
    typedef ::realm::util::TypeAppend< Columns11, type12 >::type Columns12; \
    typedef ::realm::util::TypeAppend< Columns12, type13 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        typename Col<9>::type name10; \
        typename Col<10>::type name11; \
        typename Col<11>::type name12; \
        typename Col<12>::type name13; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i), name10(i), name11(i), name12(i), name13(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
        names[9] = realm::StringData(#name10, sizeof #name10 - 1); \
        names[10] = realm::StringData(#name11, sizeof #name11 - 1); \
        names[11] = realm::StringData(#name12, sizeof #name12 - 1); \
        names[12] = realm::StringData(#name13, sizeof #name13 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_14(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9, name10, type10, name11, type11, name12, type12, name13, type13, name14, type14) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns9; \
    typedef ::realm::util::TypeAppend< Columns9, type10 >::type Columns10; \
    typedef ::realm::util::TypeAppend< Columns10, type11 >::type Columns11; \
    typedef ::realm::util::TypeAppend< Columns11, type12 >::type Columns12; \
    typedef ::realm::util::TypeAppend< Columns12, type13 >::type Columns13; \
    typedef ::realm::util::TypeAppend< Columns13, type14 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        typename Col<9>::type name10; \
        typename Col<10>::type name11; \
        typename Col<11>::type name12; \
        typename Col<12>::type name13; \
        typename Col<13>::type name14; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i), name10(i), name11(i), name12(i), name13(i), name14(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
        names[9] = realm::StringData(#name10, sizeof #name10 - 1); \
        names[10] = realm::StringData(#name11, sizeof #name11 - 1); \
        names[11] = realm::StringData(#name12, sizeof #name12 - 1); \
        names[12] = realm::StringData(#name13, sizeof #name13 - 1); \
        names[13] = realm::StringData(#name14, sizeof #name14 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13, type14 name14) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13, name14)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13, type14 name14) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13, name14)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13, type14 name14) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13, name14)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


#define REALM_TABLE_15(Table, name1, type1, name2, type2, name3, type3, name4, type4, name5, type5, name6, type6, name7, type7, name8, type8, name9, type9, name10, type10, name11, type11, name12, type12, name13, type13, name14, type14, name15, type15) \
struct Table##Spec: ::realm::SpecBase { \
    typedef ::realm::util::TypeAppend< void,     type1 >::type Columns1; \
    typedef ::realm::util::TypeAppend< Columns1, type2 >::type Columns2; \
    typedef ::realm::util::TypeAppend< Columns2, type3 >::type Columns3; \
    typedef ::realm::util::TypeAppend< Columns3, type4 >::type Columns4; \
    typedef ::realm::util::TypeAppend< Columns4, type5 >::type Columns5; \
    typedef ::realm::util::TypeAppend< Columns5, type6 >::type Columns6; \
    typedef ::realm::util::TypeAppend< Columns6, type7 >::type Columns7; \
    typedef ::realm::util::TypeAppend< Columns7, type8 >::type Columns8; \
    typedef ::realm::util::TypeAppend< Columns8, type9 >::type Columns9; \
    typedef ::realm::util::TypeAppend< Columns9, type10 >::type Columns10; \
    typedef ::realm::util::TypeAppend< Columns10, type11 >::type Columns11; \
    typedef ::realm::util::TypeAppend< Columns11, type12 >::type Columns12; \
    typedef ::realm::util::TypeAppend< Columns12, type13 >::type Columns13; \
    typedef ::realm::util::TypeAppend< Columns13, type14 >::type Columns14; \
    typedef ::realm::util::TypeAppend< Columns14, type15 >::type Columns; \
 \
    template<template<int> class Col, class Init> \
    struct ColNames { \
        typename Col<0>::type name1; \
        typename Col<1>::type name2; \
        typename Col<2>::type name3; \
        typename Col<3>::type name4; \
        typename Col<4>::type name5; \
        typename Col<5>::type name6; \
        typename Col<6>::type name7; \
        typename Col<7>::type name8; \
        typename Col<8>::type name9; \
        typename Col<9>::type name10; \
        typename Col<10>::type name11; \
        typename Col<11>::type name12; \
        typename Col<12>::type name13; \
        typename Col<13>::type name14; \
        typename Col<14>::type name15; \
        ColNames(Init i) noexcept: name1(i), name2(i), name3(i), name4(i), name5(i), name6(i), name7(i), name8(i), name9(i), name10(i), name11(i), name12(i), name13(i), name14(i), name15(i) {} \
    }; \
 \
    static void dyn_col_names(realm::StringData* names) noexcept \
    { \
        names[0] = realm::StringData(#name1, sizeof #name1 - 1); \
        names[1] = realm::StringData(#name2, sizeof #name2 - 1); \
        names[2] = realm::StringData(#name3, sizeof #name3 - 1); \
        names[3] = realm::StringData(#name4, sizeof #name4 - 1); \
        names[4] = realm::StringData(#name5, sizeof #name5 - 1); \
        names[5] = realm::StringData(#name6, sizeof #name6 - 1); \
        names[6] = realm::StringData(#name7, sizeof #name7 - 1); \
        names[7] = realm::StringData(#name8, sizeof #name8 - 1); \
        names[8] = realm::StringData(#name9, sizeof #name9 - 1); \
        names[9] = realm::StringData(#name10, sizeof #name10 - 1); \
        names[10] = realm::StringData(#name11, sizeof #name11 - 1); \
        names[11] = realm::StringData(#name12, sizeof #name12 - 1); \
        names[12] = realm::StringData(#name13, sizeof #name13 - 1); \
        names[13] = realm::StringData(#name14, sizeof #name14 - 1); \
        names[14] = realm::StringData(#name15, sizeof #name15 - 1); \
    } \
 \
    struct ConvenienceMethods { \
        void add(type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13, type14 name14, type15 name15) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->add((::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13, name14, name15)); \
        } \
        void insert(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13, type14 name14, type15 name15) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->insert(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13, name14, name15)); \
        } \
        void set(size_t _realm_i, type1 name1, type2 name2, type3 name3, type4 name4, type5 name5, type6 name6, type7 name7, type8 name8, type9 name9, type10 name10, type11 name11, type12 name12, type13 name13, type14 name14, type15 name15) \
        { \
            ::realm::BasicTable<Table##Spec>* const _realm_t = \
                static_cast< ::realm::BasicTable<Table##Spec>* >(this); \
            _realm_t->set(_realm_i, (::realm::util::tuple(), name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12, name13, name14, name15)); \
        } \
    }; \
}; \
typedef ::realm::BasicTable<Table##Spec> Table;


// clang-format on

#endif // REALM_TABLE_MACROS_HPP
