MySQL++: stadapter.h Source File
stadapter.h
Go to the documentation of this file.
/***********************************************************************
Copyright © 1998 by Kevin Atkinson, © 1999-2001 by MySQL AB, and
© 2004-2009, 2018 by Educational Technology Resources, Inc. Others may
also hold copyrights on code in this file. See the CREDITS.txt file
in the top directory of the distribution for details.
This file is part of MySQL++.
MySQL++ is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
MySQL++ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MySQL++; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
***********************************************************************/
#if !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)
#define MYSQLPP_SQL_TYPE_ADAPTER_H
#include "common.h"
#include "datetime.h"
#include "null.h"
#include "sql_buffer.h"
#include "tiny_int.h"
#include <stdexcept>
#include <string>
namespace mysqlpp {
#if !defined(DOXYGEN_IGNORE)
class MYSQLPP_EXPORT String;
#endif
class MYSQLPP_EXPORT SQLTypeAdapter
{
public:
typedef size_t size_type;
SQLTypeAdapter();
SQLTypeAdapter(const SQLTypeAdapter& other);
SQLTypeAdapter(const String& str, bool processed = false);
SQLTypeAdapter(const std::string& str, bool processed = false);
SQLTypeAdapter(const char* str, bool processed = false);
SQLTypeAdapter(const char* str, int len, bool processed = false);
SQLTypeAdapter(char c);
SQLTypeAdapter(tiny_int<signed char> i);
SQLTypeAdapter(tiny_int<unsigned char> i);
SQLTypeAdapter(short i);
SQLTypeAdapter(unsigned short i);
SQLTypeAdapter(int i);
SQLTypeAdapter(unsigned i);
SQLTypeAdapter(long i);
SQLTypeAdapter(unsigned long i);
SQLTypeAdapter(longlong i);
SQLTypeAdapter(ulonglong i);
SQLTypeAdapter(float i);
SQLTypeAdapter(double i);
SQLTypeAdapter(const Date& d);
SQLTypeAdapter(const DateTime& dt);
SQLTypeAdapter(const Time& t);
SQLTypeAdapter(const null_type& i);
SQLTypeAdapter& operator =(const SQLTypeAdapter& rhs);
SQLTypeAdapter& operator =(const null_type& n);
operator const char*() const { return data(); }
SQLTypeAdapter& assign(const SQLTypeAdapter& sta);
SQLTypeAdapter& assign(const char* pc, int len = -1);
SQLTypeAdapter& assign(const null_type& n);
#if !defined(DOXYGEN_IGNORE) && __cplusplus >= 201103L
// Can't use MAY_THROW() here: it confuses Doxygen 1.8.14.
char at(size_type i) const noexcept(false);
#else
char at(size_type i) const throw(std::out_of_range);
#endif
int compare(const SQLTypeAdapter& other) const;
int compare(const std::string& other) const;
int compare(size_type pos, size_type num, std::string& other) const;
int compare(const char* other) const;
int compare(size_type pos, size_type num, const char* other) const;
const char* data() const;
bool escape_q() const;
bool is_null() const { return buffer_->is_null(); }
bool is_processed() const { return is_processed_; }
size_type length() const;
size_type size() const { return length(); }
bool quote_q() const;
int type_id() const;
void set_processed() { is_processed_ = true; }
#if !defined(DOXYGEN_IGNORE)
// Parallel interface for Null<>-wrapped versions of types we
// support above. No need for parallel documentation.
SQLTypeAdapter(const Null<std::string>& str, bool processed = false);
SQLTypeAdapter(const Null<String>& str, bool processed = false);
SQLTypeAdapter(Null<char> c);
SQLTypeAdapter(Null< tiny_int<signed char> > i);
SQLTypeAdapter(Null< tiny_int<unsigned char> > i);
SQLTypeAdapter(Null<short> i);
SQLTypeAdapter(Null<unsigned short> i);
SQLTypeAdapter(Null<int> i);
SQLTypeAdapter(Null<unsigned> i);
SQLTypeAdapter(Null<long> i);
SQLTypeAdapter(Null<unsigned long> i);
SQLTypeAdapter(Null<longlong> i);
SQLTypeAdapter(Null<ulonglong> i);
SQLTypeAdapter(Null<float> i);
SQLTypeAdapter(Null<double> i);
SQLTypeAdapter(const Null<Date>& d);
SQLTypeAdapter(const Null<DateTime>& dt);
SQLTypeAdapter(const Null<Time>& t);
SQLTypeAdapter& operator =(const Null<std::string>& str);
#endif // !defined(DOXYGEN_IGNORE)
private:
RefCountedBuffer buffer_;
bool is_processed_;
};
} // end namespace mysqlpp
#endif // !defined(MYSQLPP_SQL_TYPE_ADAPTER_H)
null.h
Declares classes that implement SQL "null" semantics within C++'s type system.
mysqlpp::SQLTypeAdapter::size_type
size_t size_type
size of length values
Definition: stadapter.h:76
mysqlpp::Time
C++ form of SQL's TIME type.
Definition: datetime.h:347
mysqlpp::DateTime
C++ form of SQL's DATETIME type.
Definition: datetime.h:48
datetime.h
Declares classes to add SQL-compatible date and time types to C++'s type system.
mysqlpp::tiny_int
Class for holding an SQL TINYINT value.
Definition: tiny_int.h:55
mysqlpp::null_type
The type of the global mysqlpp::null object.
Definition: null.h:49
mysqlpp::SQLTypeAdapter::set_processed
void set_processed()
Turns on the internal 'is_processed_' flag.
Definition: stadapter.h:299
mysqlpp::SQLTypeAdapter::is_null
bool is_null() const
Return true if buffer's contents represent a SQL null.
Definition: stadapter.h:272
mysqlpp::SQLTypeAdapter::is_processed
bool is_processed() const
Returns true if the internal 'processed' flag is set.
Definition: stadapter.h:278
mysqlpp::Date
C++ form of SQL's DATE type.
Definition: datetime.h:225
mysqlpp::RefCountedPointer< SQLBuffer >
mysqlpp::SQLTypeAdapter::size
size_type size() const
alias for length()
Definition: stadapter.h:282
common.h
This file includes top-level definitions for use both internal to the library, and outside it....
sql_buffer.h
Declares the SQLBuffer class.
mysqlpp::SQLTypeAdapter
Converts many different data types to strings suitable for use in SQL queries.
Definition: stadapter.h:73
tiny_int.h
Declares class for holding a SQL TINYINT.
mysqlpp::Null
Class for holding data from a SQL column with the NULL attribute.
Definition: null.h:170
mysqlpp::String
A std::string work-alike that can convert itself from SQL text data formats to C++ data types.
Definition: mystring.h:139