Author: mysqlpp
Date: Thu Jul 27 22:50:39 2006
New Revision: 1316
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1316&view=rev
Log:
MinGW has problems with inline member functions in DLLs defined outside
the class declaration. To fix this:
- greatly reduced the number of inline functions
- those inlines that are left are part of the class declaration, or
there is a fair reason why not
Modified:
trunk/lib/coldata.h
trunk/lib/myset.h
trunk/lib/result.cpp
trunk/lib/result.h
trunk/lib/string_util.cpp
trunk/lib/string_util.h
trunk/lib/type_info.h
Modified: trunk/lib/coldata.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/coldata.h?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/coldata.h (original)
+++ trunk/lib/coldata.h Thu Jul 27 22:50:39 2006
@@ -156,10 +156,7 @@
inline const bool is_null() const { return null_; }
/// \brief Returns the string form of this object's data.
- inline const std::string& get_string() const
- {
- return buf_;
- }
+ inline const std::string& get_string() const { return buf_; }
/// \brief Returns a const char pointer to the string form of
/// this object's data.
Modified: trunk/lib/myset.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/myset.h?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/myset.h (original)
+++ trunk/lib/myset.h Thu Jul 27 22:50:39 2006
@@ -127,7 +127,7 @@
/// \brief Convert this set's data to a string containing
/// comma-separated items.
- operator std::string();
+ operator std::string() { return stream2string<std::string>(*this); }
};
@@ -137,13 +137,6 @@
const Set<Container>& d)
{
return d.out_stream(s);
-}
-
-
-template <class Container>
-inline Set<Container>::operator std::string()
-{
- return stream2string<std::string>(*this);
}
Modified: trunk/lib/result.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/result.cpp?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/result.cpp (original)
+++ trunk/lib/result.cpp Thu Jul 27 22:50:39 2006
@@ -69,7 +69,8 @@
}
-void ResUse::copy(const ResUse& other)
+void
+ResUse::copy(const ResUse& other)
{
if (initialized_) {
purge();
@@ -108,5 +109,131 @@
initialized_ = true;
}
+
+int
+ResUse::field_num(const std::string& i) const
+{
+ if (!names_) {
+ names_ = new FieldNames(this);
+ }
+
+ size_t index = (*names_)[i];
+ if ((index >= names_->size()) && throw_exceptions()) {
+ throw BadFieldName(i.c_str());
+ }
+
+ return int(index);
+}
+
+
+std::string&
+ResUse::field_name(int i)
+{
+ if (!names_) {
+ names_ = new FieldNames(this);
+ }
+ return (*names_)[i];
+}
+
+
+const std::string&
+ResUse::field_name(int i) const
+{
+ if (!names_) {
+ names_ = new FieldNames(this);
+ }
+ return (*names_)[i];
+}
+
+
+FieldNames&
+ResUse::field_names()
+{
+ if (!names_) {
+ names_ = new FieldNames(this);
+ }
+ return *names_;
+}
+
+
+const FieldNames&
+ResUse::field_names() const
+{
+ if (!names_) {
+ names_ = new FieldNames(this);
+ }
+ return *names_;
+}
+
+
+void
+ResUse::reset_field_names()
+{
+ delete names_;
+ names_ = 0;
+ names_ = new FieldNames(this);
+}
+
+
+mysql_type_info&
+ResUse::field_type(int i)
+{
+ if (!types_) {
+ types_ = new FieldTypes(this);
+ }
+ return (*types_)[i];
+}
+
+
+const mysql_type_info&
+ResUse::field_type(int i) const
+{
+ if (!types_) {
+ types_ = new FieldTypes(this);
+ }
+ return (*types_)[i];
+}
+
+
+FieldTypes&
+ResUse::field_types()
+{
+ if (!types_) {
+ types_ = new FieldTypes(this);
+ }
+ return *types_;
+}
+
+
+const FieldTypes&
+ResUse::field_types() const
+{
+ if (!types_) {
+ types_ = new FieldTypes(this);
+ }
+ return *types_;
+}
+
+
+void
+ResUse::reset_field_types()
+{
+ delete types_;
+ types_ = 0;
+ types_ = new FieldTypes(this);
+}
+
+
+ResUse&
+ResUse::operator =(const ResUse& other)
+{
+ if (this == &other) {
+ return *this;
+ }
+ copy(other);
+ other.result_ = 0;
+ return *this;
+}
+
} // end namespace mysqlpp
Modified: trunk/lib/result.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/result.h?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/result.h (original)
+++ trunk/lib/result.h Thu Jul 27 22:50:39 2006
@@ -216,87 +216,81 @@
/// \brief Get the index of the named field.
///
/// This is the inverse of field_name().
- inline int field_num(const std::string&) const;
+ int field_num(const std::string&) const;
/// \brief Get the name of the field at the given index.
///
/// This is the inverse of field_num().
- inline std::string& field_name(int);
+ std::string& field_name(int);
/// \brief Get the name of the field at the given index.
- inline const std::string& field_name(int) const;
+ const std::string& field_name(int) const;
/// \brief Get the names of the fields within this result set.
- inline FieldNames& field_names();
+ FieldNames& field_names();
/// \brief Get the names of the fields within this result set.
- inline const FieldNames& field_names() const;
+ const FieldNames& field_names() const;
/// \brief Reset the names in the field list to their original
/// values.
- inline void reset_field_names();
+ void reset_field_names();
/// \brief Get the MySQL type for a field given its index.
- inline mysql_type_info& field_type(int i);
+ mysql_type_info& field_type(int i);
/// \brief Get the MySQL type for a field given its index.
- inline const mysql_type_info& field_type(int) const;
+ const mysql_type_info& field_type(int) const;
/// \brief Get a list of the types of the fields within this
/// result set.
- inline FieldTypes& field_types();
+ FieldTypes& field_types();
/// \brief Get a list of the types of the fields within this
/// result set.
- inline const FieldTypes& field_types() const;
+ const FieldTypes& field_types() const;
/// \brief Reset the field types to their original values.
- inline void reset_field_types();
+ void reset_field_types();
/// \brief Alias for field_num()
- inline int names(const std::string & s) const;
+ int names(const std::string & s) const { return field_num(s); }
/// \brief Alias for field_name()
- inline std::string& names(int i);
+ std::string& names(int i) { return field_name(i); }
/// \brief Alias for field_name()
- inline const std::string& names(int i) const;
+ const std::string& names(int i) const { return field_name(i); }
/// \brief Alias for field_names()
- inline FieldNames& names();
+ FieldNames& names() { return field_names(); }
/// \brief Alias for field_names()
- inline const FieldNames& names() const;
+ const FieldNames& names() const { return field_names(); }
/// \brief Alias for reset_field_names()
- inline void reset_names();
+ void reset_names() { reset_field_names(); }
/// \brief Alias for field_type()
- inline mysql_type_info& types(int i);
+ mysql_type_info& types(int i) { return field_type(i); }
/// \brief Alias for field_type()
- inline const mysql_type_info& types(int i) const;
+ const mysql_type_info& types(int i) const { return field_type(i); }
/// \brief Alias for field_types()
- inline FieldTypes& types();
+ FieldTypes& types() { return field_types(); }
/// \brief Alias for field_types()
- inline const FieldTypes& types() const;
+ const FieldTypes& types() const { return field_types(); }
/// \brief Alias for reset_field_types()
- inline void reset_types();
+ void reset_types() { reset_field_types(); }
/// \brief Get the underlying Fields structure.
- const Fields& fields() const
- {
- return fields_;
- }
+ const Fields& fields() const { return fields_; }
/// \brief Get the underlying Field structure given its index.
- const Field& fields(unsigned int i) const
- {
- return fields_.at(i);
- }
+ const Field& fields(unsigned int i) const { return fields_.at(i); }
/// \brief Returns true if the other ResUse object shares the same
/// underlying C API result set as this one.
@@ -472,163 +466,6 @@
};
-inline int ResUse::field_num(const std::string& i) const
-{
- if (!names_) {
- names_ = new FieldNames(this);
- }
-
- size_t index = (*names_)[i];
- if ((index >= names_->size()) && throw_exceptions()) {
- throw BadFieldName(i.c_str());
- }
-
- return int(index);
-}
-
-inline std::string& ResUse::field_name(int i)
-{
- if (!names_) {
- names_ = new FieldNames(this);
- }
- return (*names_)[i];
-}
-
-inline const std::string& ResUse::field_name(int i) const
-{
- if (!names_) {
- names_ = new FieldNames(this);
- }
- return (*names_)[i];
-}
-
-inline FieldNames& ResUse::field_names()
-{
- if (!names_) {
- names_ = new FieldNames(this);
- }
- return *names_;
-}
-
-inline const FieldNames& ResUse::field_names() const
-{
- if (!names_) {
- names_ = new FieldNames(this);
- }
- return *names_;
-}
-
-inline void ResUse::reset_field_names()
-{
- delete names_;
- names_ = 0;
- names_ = new FieldNames(this);
-}
-
-inline mysql_type_info& ResUse::field_type(int i)
-{
- if (!types_) {
- types_ = new FieldTypes(this);
- }
- return (*types_)[i];
-}
-
-inline const mysql_type_info& ResUse::field_type(int i) const
-{
- if (!types_) {
- types_ = new FieldTypes(this);
- }
- return (*types_)[i];
-}
-
-inline FieldTypes& ResUse::field_types()
-{
- if (!types_) {
- types_ = new FieldTypes(this);
- }
- return *types_;
-}
-
-inline const FieldTypes& ResUse::field_types() const
-{
- if (!types_) {
- types_ = new FieldTypes(this);
- }
- return *types_;
-}
-
-inline void ResUse::reset_field_types()
-{
- delete types_;
- types_ = 0;
- types_ = new FieldTypes(this);
-}
-
-inline int ResUse::names(const std::string& s) const
-{
- return field_num(s);
-}
-
-inline std::string& ResUse::names(int i)
-{
- return field_name(i);
-}
-
-inline const std::string& ResUse::names(int i) const
-{
- return field_name(i);
-}
-
-inline FieldNames& ResUse::names()
-{
- return field_names();
-}
-
-inline const FieldNames& ResUse::names() const
-{
- return field_names();
-}
-
-inline void ResUse::reset_names()
-{
- reset_field_names();
-}
-
-inline mysql_type_info& ResUse::types(int i)
-{
- return field_type(i);
-}
-
-inline const mysql_type_info& ResUse::types(int i) const
-{
- return field_type(i);
-}
-
-inline FieldTypes& ResUse::types()
-{
- return field_types();
-}
-
-inline const FieldTypes& ResUse::types() const
-{
- return field_types();
-}
-
-inline void ResUse::reset_types()
-{
- reset_field_types();
-}
-
-inline ResUse& ResUse::operator =(const ResUse& other)
-{
- if (this == &other) {
- return *this;
- }
- copy(other);
- other.result_ = 0;
- return *this;
-}
-
} // end namespace mysqlpp
#endif
Modified: trunk/lib/string_util.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/string_util.cpp?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/string_util.cpp (original)
+++ trunk/lib/string_util.cpp Thu Jul 27 22:50:39 2006
@@ -99,5 +99,47 @@
}
}
+
+void
+str_to_upr(std::string& s)
+{
+ for (std::string::size_type i = 0; i < s.length(); ++i) {
+ s[i] = toupper(s[i]);
+ }
+}
+
+
+void
+str_to_lwr(std::string& s)
+{
+ for (std::string::size_type i = 0; i < s.length(); ++i) {
+ s[i] = tolower(s[i]);
+ }
+}
+
+
+void
+strip_all_blanks(std::string& s)
+{
+ for (std::string::size_type i = 0; i < s.length(); ++i) {
+ if (s[i] == ' ') {
+ s.erase(i, 1);
+ --i;
+ }
+ }
+}
+
+
+void
+strip_all_non_num(std::string& s)
+{
+ for (std::string::size_type i = 0; i < s.length(); ++i) {
+ if (!isdigit(s[i])) {
+ s.erase(i, 1);
+ --i;
+ }
+ }
+}
+
} // end namespace mysqlpp
Modified: trunk/lib/string_util.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/string_util.h?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/string_util.h (original)
+++ trunk/lib/string_util.h Thu Jul 27 22:50:39 2006
@@ -44,34 +44,16 @@
MYSQLPP_EXPORT extern void escape_string(std::string& s);
/// \brief Changes case of string to upper
-inline void str_to_upr(std::string& s)
-{
- for (unsigned int cnt=0; cnt < s.length(); cnt++) {
- char c = s[cnt]; s[cnt]=toupper(c);
- }
-}
+MYSQLPP_EXPORT extern void str_to_upr(std::string& s);
/// \brief Changes case of string to lower
-inline void str_to_lwr (std::string& s)
-{
- for (unsigned int cnt=0; cnt < s.length(); cnt++) {
- char c = s[cnt]; s[cnt]=tolower(c);
- }
-}
+MYSQLPP_EXPORT extern void str_to_lwr(std::string& s);
/// \brief Removes all blanks
-inline void strip_all_blanks (std::string& s)
-{
- for (unsigned int counter=0;counter < s.size();counter++)
- if (s[counter] == ' ') { s.erase(counter,1); counter--;}
-}
+MYSQLPP_EXPORT extern void strip_all_blanks(std::string& s);
/// \brief Removes all non-numerics
-inline void strip_all_non_num (std::string& s)
-{
- for (unsigned int counter=0;counter < s.size();counter++)
- if (!isdigit(s[counter])) { s.erase(counter,1); counter--;}
-}
+MYSQLPP_EXPORT extern void strip_all_non_num(std::string& s);
} // end namespace mysqlpp
Modified: trunk/lib/type_info.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/type_info.h?rev=1316&r1=1315&r2=1316&view=diff
==============================================================================
--- trunk/lib/type_info.h (original)
+++ trunk/lib/type_info.h Thu Jul 27 22:50:39 2006
@@ -130,6 +130,8 @@
/// default mysql_type_info object. This is a very wrong thing
/// to do.
mysql_type_info(unsigned char n = static_cast<unsigned char>(-1)) :
+ _length(0),
+ _max_length(0),
num_(n)
{
}
@@ -139,16 +141,28 @@
/// \param t the MySQL C API type ID for this type
/// \param _unsigned if true, this is the unsigned version of the type
/// \param _null if true, this type can hold a SQL null
- inline mysql_type_info(enum_field_types t,
- bool _unsigned, bool _null);
+ mysql_type_info(enum_field_types t, bool _unsigned, bool _null) :
+ _length(0),
+ _max_length(0),
+ num_(type(t, _unsigned, _null))
+ {
+ }
/// \brief Create object from a MySQL C API field
///
/// \param f field from which we extract the type info
- inline mysql_type_info(const MYSQL_FIELD& f);
+ mysql_type_info(const MYSQL_FIELD& f) :
+ _length(f.length),
+ _max_length(f.max_length),
+ num_(type(f.type, (f.flags & UNSIGNED_FLAG) != 0,
+ (f.flags & NOT_NULL_FLAG) == 0))
+ {
+ }
/// \brief Create object as a copy of another
mysql_type_info(const mysql_type_info& t) :
+ _length(0),
+ _max_length(0),
num_(t.num_)
{
}
@@ -157,9 +171,9 @@
///
/// This tries to map a C++ type to the closest MySQL data type.
/// It is necessarily somewhat approximate.
- mysql_type_info(const std::type_info& t)
- {
- num_ = lookups[t];
+ mysql_type_info(const std::type_info& t) :
+ num_(lookups[t])
+ {
}
/// \brief Assign a new internal type value
@@ -194,37 +208,40 @@
///
/// Returns the name that would be returned by typeid().name() for
/// the C++ type associated with the SQL type.
- inline const char* name() const;
+ const char* name() const { return deref().c_type_->name(); }
/// \brief Returns the name of the SQL type.
///
/// Returns the SQL name for the type.
- inline const char* sql_name() const;
+ const char* sql_name() const { return deref().sql_name_; }
/// \brief Returns the type_info for the C++ type associated with
/// the SQL type.
///
/// Returns the C++ type_info record corresponding to the SQL type.
- inline const std::type_info& c_type() const;
+ const std::type_info& c_type() const { return *deref().c_type_; }
/// \brief Return length of data in this field
///
/// This only works if you initialized this object from a
/// MYSQL_FIELD object.
- inline const unsigned int length() const;
+ const unsigned int length() const { return _length; }
/// \brief Return maximum length of data in this field
///
/// This only works if you initialized this object from a
/// MYSQL_FIELD object.
- inline const unsigned int max_length() const;
+ const unsigned int max_length() const { return _max_length; }
/// \brief Returns the type_info for the C++ type inside of the
/// mysqlpp::Null type.
///
/// Returns the type_info for the C++ type inside the mysqlpp::Null
/// type. If the type is not Null then this is the same as c_type().
- inline const mysql_type_info base_type() const;
+ const mysql_type_info base_type() const
+ {
+ return mysql_type_info(deref().base_type_);
+ }
/// \brief Returns the ID of the SQL type.
///
@@ -307,50 +324,6 @@
unsigned char num_;
};
-inline const char* mysql_type_info::name() const
-{
- return deref().c_type_->name();
-}
-
-inline const char* mysql_type_info::sql_name() const
-{
- return deref().sql_name_;
-}
-
-inline const unsigned int mysql_type_info::length() const
-{
- return _length;
-}
-
-inline const unsigned int mysql_type_info::max_length() const
-{
- return _max_length;
-}
-
-inline const std::type_info& mysql_type_info::c_type() const
-{
- return *deref().c_type_;
-}
-
-inline const mysql_type_info mysql_type_info::base_type() const
-{
- return mysql_type_info(deref().base_type_);
-}
-
-inline mysql_type_info::mysql_type_info(enum_field_types t,
- bool _unsigned, bool _null)
-{
- num_ = type(t, _unsigned, _null);
-}
-
-inline mysql_type_info::mysql_type_info(const MYSQL_FIELD& f)
-{
- num_ = type(f.type, (f.flags & UNSIGNED_FLAG) != 0,
- (f.flags & NOT_NULL_FLAG) == 0);
- _length = f.length;
- _max_length = f.max_length;
-}
-
/// \brief Returns true if two mysql_type_info objects are equal.
inline bool operator ==(const mysql_type_info& a, const mysql_type_info& b)
{
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits