123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- #ifndef MYSQLX_ROW_H
- #define MYSQLX_ROW_H
- #include "common.h"
- #include "document.h"
- #include "detail/row.h"
- #include <memory>
- namespace mysqlx {
- class Row
- : private internal::Row_detail
- {
- Row(internal::Row_detail &&other)
- try
- : Row_detail(std::move(other))
- {}
- CATCH_AND_WRAP
- public:
- Row() {}
- template<typename T, typename... Types>
- explicit Row(T val, Types... vals)
- {
- try {
- Row_detail::set_values(0, val, vals...);
- }
- CATCH_AND_WRAP
- }
- col_count_t colCount() const
- {
- try {
- return Row_detail::col_count();
- }
- CATCH_AND_WRAP
- }
-
- bytes getBytes(col_count_t pos) const
- {
- try {
- return Row_detail::get_bytes(pos);
- }
- CATCH_AND_WRAP
- }
-
- Value& get(col_count_t pos)
- {
- try {
- return Row_detail::get_val(pos);
- }
- CATCH_AND_WRAP
- }
-
- Value& set(col_count_t pos, const Value &val)
- {
- try {
- Row_detail::set_values(pos, val);
- return Row_detail::get_val(pos);
- }
- CATCH_AND_WRAP
- }
-
- const Value& operator[](col_count_t pos) const
- {
- return const_cast<Row*>(this)->get(pos);
- }
-
- Value& operator[](col_count_t pos)
- {
- ensure_impl();
- try {
- return get(pos);
- }
- catch (const out_of_range&)
- {
- return set(pos, Value());
- }
- }
-
- bool isNull() const { return NULL == m_impl; }
- operator bool() const { return !isNull(); }
- void clear()
- {
- try {
- Row_detail::clear();
- }
- CATCH_AND_WRAP
- }
- private:
- using internal::Row_detail::m_impl;
-
- friend internal::Row_result_detail<Columns>;
- friend internal::Table_insert_detail;
-
- };
- }
- #endif
|