2021-03-10 16:20:11 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of morm
|
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2022-02-08 12:47:34 +01:00
|
|
|
* Copyright (c) 2021-2022, Tomasz Sowa
|
2021-03-10 16:20:11 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_morm_ft
|
|
|
|
#define headerfile_morm_ft
|
|
|
|
|
|
|
|
namespace morm
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* field types
|
|
|
|
*/
|
|
|
|
class FT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum FieldType
|
|
|
|
{
|
|
|
|
default_type = 0,
|
|
|
|
primary_key = 1,
|
|
|
|
foreign_key = 2,
|
|
|
|
foreign_key_in_child = 4,
|
|
|
|
no_insertable = 8,
|
|
|
|
no_updatable = 16,
|
|
|
|
no_fetchable = 32, /* not supported yet */
|
2021-05-21 22:12:10 +02:00
|
|
|
no_removable = 64,
|
|
|
|
raw_field_name = 128,
|
2022-02-08 12:47:34 +01:00
|
|
|
dont_use_utf8 = 256, /* used only with wchar_t and std::wstring, ignored if binary or hexadecimal flags are used */
|
2021-05-21 22:12:10 +02:00
|
|
|
hexadecimal = 512,
|
|
|
|
binary = 1024,
|
2021-08-12 21:56:32 +02:00
|
|
|
json = 2048,
|
|
|
|
space = 4096,
|
|
|
|
pretty_print = 8192,
|
2022-05-16 13:42:51 +02:00
|
|
|
numeric = 16384,
|
2021-03-10 16:20:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* type can be a superposition from FieldType values
|
|
|
|
*/
|
|
|
|
int type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FT()
|
|
|
|
{
|
|
|
|
type = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FT(const FT & field_type)
|
|
|
|
{
|
|
|
|
type = field_type.type;
|
|
|
|
}
|
|
|
|
|
|
|
|
FT(FieldType type)
|
|
|
|
{
|
|
|
|
this->type = static_cast<int>(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
FT(int type)
|
|
|
|
{
|
|
|
|
this->type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
FT & operator=(const FT & field_type)
|
|
|
|
{
|
|
|
|
type = field_type.type;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_flag_set(int flag_mask) const
|
|
|
|
{
|
|
|
|
return (type & flag_mask) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool is_primary_key() const
|
|
|
|
{
|
|
|
|
return is_flag_set(primary_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool is_foreign_key() const
|
|
|
|
{
|
|
|
|
return is_flag_set(foreign_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_foreign_key_in_child() const
|
|
|
|
{
|
|
|
|
return is_flag_set(foreign_key_in_child);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_insertable() const
|
|
|
|
{
|
|
|
|
return !is_flag_set(no_insertable);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_updatable() const
|
|
|
|
{
|
|
|
|
return !is_flag_set(no_updatable);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_fetchable() const
|
|
|
|
{
|
|
|
|
return !is_flag_set(no_fetchable);
|
|
|
|
}
|
|
|
|
|
2021-05-21 22:12:10 +02:00
|
|
|
bool is_removable() const
|
|
|
|
{
|
|
|
|
return !is_flag_set(no_removable);
|
|
|
|
}
|
2021-04-12 18:53:55 +02:00
|
|
|
|
|
|
|
bool is_raw_field_name() const
|
|
|
|
{
|
|
|
|
return is_flag_set(raw_field_name);
|
|
|
|
}
|
|
|
|
|
2021-05-11 22:11:31 +02:00
|
|
|
bool use_utf8() const
|
|
|
|
{
|
|
|
|
return !is_flag_set(dont_use_utf8);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_hexadecimal() const
|
|
|
|
{
|
|
|
|
return is_flag_set(hexadecimal);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_binary() const
|
|
|
|
{
|
|
|
|
return is_flag_set(binary);
|
|
|
|
}
|
|
|
|
|
2021-08-12 21:56:32 +02:00
|
|
|
bool is_json() const
|
|
|
|
{
|
|
|
|
return is_flag_set(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_space() const
|
|
|
|
{
|
|
|
|
return is_flag_set(space);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_pretty_print() const
|
|
|
|
{
|
|
|
|
return is_flag_set(pretty_print);
|
|
|
|
}
|
2021-05-11 22:11:31 +02:00
|
|
|
|
2022-05-16 13:42:51 +02:00
|
|
|
bool is_numeric() const
|
|
|
|
{
|
|
|
|
return is_flag_set(numeric);
|
|
|
|
}
|
|
|
|
|
2021-03-10 16:20:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|