8 #ifndef SOCI_VALUES_H_INCLUDED 9 #define SOCI_VALUES_H_INCLUDED 52 values() : row_(NULL), currentPos_(0), uppercaseColumnNames_(false) {}
54 indicator get_indicator(std::size_t pos)
const;
55 indicator get_indicator(std::string
const & name)
const;
58 T
get(std::size_t pos)
const 62 return row_->get<T>(pos);
64 else if (*indicators_[pos] !=
i_null)
66 return get_from_uses<T>(pos);
70 std::ostringstream msg;
71 msg <<
"Column at position " 72 <<
static_cast<unsigned long>(pos)
73 <<
" contains NULL value and no default was provided";
79 T
get(std::size_t pos, T
const & nullValue)
const 83 return row_->get<T>(pos, nullValue);
85 else if (*indicators_[pos] ==
i_null)
91 return get_from_uses<T>(pos);
96 T
get(std::string
const & name)
const 98 return row_ != NULL ? row_->get<T>(name) : get_from_uses<T>(name);
101 template <
typename T>
102 T
get(std::string
const & name, T
const & nullValue)
const 105 ? row_->get<T>(name, nullValue)
106 : get_from_uses<T>(name, nullValue);
109 template <
typename T>
119 else if (*indicators_[currentPos_] !=
i_null)
126 value = get_from_uses<T>(currentPos_);
131 std::ostringstream msg;
132 msg <<
"Column at position " 133 <<
static_cast<unsigned long>(currentPos_)
134 <<
" contains NULL value and no default was provided";
141 void skip(std::size_t num = 1)
const 157 row_->reset_get_counter();
165 template <
typename T>
169 if(index_.find(name) == index_.end())
171 index_.insert(std::make_pair(name, uses_.size()));
174 indicators_.push_back(pind);
184 deepCopies_.push_back(pcopy);
187 pcopy->
value_, *pind, name));
191 size_t index = index_.find(name)->second;
192 *indicators_[index] = indic;
198 *indicators_[index]);
203 template <
typename T>
207 indicators_.push_back(pind);
215 deepCopies_.push_back(pcopy);
221 template <
typename T>
230 uppercaseColumnNames_ = forceToUpper;
241 std::vector<details::standard_use_type *>
uses_;
242 std::map<details::use_type_base *, indicator *>
unused_;
244 std::map<std::string, std::size_t>
index_;
254 template <
typename T>
257 std::map<std::string, std::size_t>::const_iterator pos = index_.find(name);
258 if (pos != index_.end())
260 if (*indicators_[pos->second] ==
i_null)
265 return get_from_uses<T>(pos->second);
267 throw soci_error(
"Value named " + name +
" not found.");
270 template <
typename T>
273 std::map<std::string, std::size_t>::const_iterator pos = index_.find(name);
274 if (pos != index_.end())
276 return get_from_uses<T>(pos->second);
278 throw soci_error(
"Value named " + name +
" not found.");
281 template <
typename T>
290 base_type
const & baseValue = *
static_cast<base_type*
>(u->
get_data());
299 std::ostringstream msg;
300 msg <<
"Value at position " 301 <<
static_cast<unsigned long>(pos)
302 <<
" was set using a different type" 303 " than the one passed to get()";
320 unused_.insert(std::make_pair(u, i));
333 for (std::map<details::use_type_base *, indicator *>::iterator pos =
334 unused_.begin(); pos != unused_.end(); ++pos)
340 for (std::size_t i = 0; i != deepCopies_.size(); ++i)
342 delete deepCopies_[i];
349 #endif // SOCI_VALUES_H_INCLUDED
values & operator<<(T const &value)
std::map< details::use_type_base *, indicator * > unused_
static void to_base(T const &in, base_type &out, indicator &ind)
bool uppercaseColumnNames_
std::map< std::string, std::size_t > index_
void skip(std::size_t num=1) const
T get_from_uses(std::string const &name, T const &nullValue) const
void add_unused(details::use_type_base *u, indicator *i)
std::vector< indicator * > indicators_
static void from_base(base_type const &in, indicator ind, T &out)
std::vector< details::standard_use_type * > uses_
void uppercase_column_names(bool forceToUpper)
T get_from_uses(std::string const &name) const
virtual void * get_data()
T get_from_uses(std::size_t pos) const
void uppercase_column_names(bool forceToUpper)
std::vector< details::copy_base * > deepCopies_
void reset_get_counter() const
values const & operator>>(T &value) const