| 1 | // |
| 2 | // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) |
| 3 | // |
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | |
| 8 | #ifndef BOOST_MYSQL_COLUMN_TYPE_HPP |
| 9 | #define BOOST_MYSQL_COLUMN_TYPE_HPP |
| 10 | |
| 11 | #include <boost/mysql/detail/config.hpp> |
| 12 | |
| 13 | #include <iosfwd> |
| 14 | |
| 15 | namespace boost { |
| 16 | namespace mysql { |
| 17 | |
| 18 | /** |
| 19 | * \brief Represents the database type of a MySQL column. |
| 20 | * \details This represents a database type, as opposed to \ref field_kind, which represents a |
| 21 | * C++ type. |
| 22 | *\n |
| 23 | * Unless otherwise noted, the names in this enumeration |
| 24 | * directly correspond to the names of the types you would use in |
| 25 | * a `CREATE TABLE` statement to create a column of this type |
| 26 | * (e.g. `VARCHAR` corresponds to \ref column_type::varchar). |
| 27 | */ |
| 28 | enum class column_type |
| 29 | { |
| 30 | tinyint, ///< `TINYINT` (signed and unsigned). |
| 31 | smallint, ///< `SMALLINT` (signed and unsigned). |
| 32 | mediumint, ///< `MEDIUMINT` (signed and unsigned). |
| 33 | int_, ///< `INT` (signed and unsigned). |
| 34 | bigint, ///< `BIGINT` (signed and unsigned). |
| 35 | float_, ///< `FLOAT` (warning: FLOAT(p) where p >= 24 creates a DOUBLE column). |
| 36 | double_, ///< `DOUBLE` |
| 37 | decimal, ///< `DECIMAL` |
| 38 | bit, ///< `BIT` |
| 39 | year, ///< `YEAR` |
| 40 | time, ///< `TIME` |
| 41 | date, ///< `DATE` |
| 42 | datetime, ///< `DATETIME` |
| 43 | timestamp, ///< `TIMESTAMP` |
| 44 | char_, ///< `CHAR` (any length) |
| 45 | varchar, ///< `VARCHAR` (any length) |
| 46 | binary, ///< `BINARY` (any length) |
| 47 | varbinary, ///< `VARBINARY` (any length) |
| 48 | text, ///< `TEXT` types (`TINYTEXT`, `MEDIUMTEXT`, `TEXT` and `LONGTEXT`) |
| 49 | blob, ///< `BLOB` types (`TINYBLOB`, `MEDIUMBLOB`, `BLOB` and `LONGBLOB`) |
| 50 | enum_, ///< `ENUM` |
| 51 | set, ///< `SET` |
| 52 | json, ///< `JSON` |
| 53 | geometry, ///< `GEOMETRY` |
| 54 | unknown, ///< None of the known types; maybe a new MySQL type we have no knowledge of. |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * \brief Streams a `column_type`. |
| 59 | */ |
| 60 | BOOST_MYSQL_DECL |
| 61 | std::ostream& operator<<(std::ostream& os, column_type t); |
| 62 | |
| 63 | } // namespace mysql |
| 64 | } // namespace boost |
| 65 | |
| 66 | #ifdef BOOST_MYSQL_HEADER_ONLY |
| 67 | #include <boost/mysql/impl/column_type.ipp> |
| 68 | #endif |
| 69 | |
| 70 | #endif |
| 71 | |