From c7c0b50c7a808e0791a9433e017951191869f2bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 23 Sep 2010 11:59:05 +0200 Subject: Add swap(), empty(), and size() to result class template --- doc/manual.xhtml | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'doc/manual.xhtml') diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 2f24ead..37523854 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -2032,6 +2032,12 @@ namespace odb what () const throw (); }; + struct result_not_cached: odb::exception + { + virtual const char* + what () const throw (); + }; + struct database_exception: odb::exception { }; @@ -2057,6 +2063,10 @@ namespace odb Section 3.6, "Updating Persistent Objects" for more information.

+

The result_not_cached exception is thrown by + the query result class. Refer to Section 4.3, + "Query Result" for details.

+

The database_exception is a base class for all database system-specific exceptions that are thrown by the database system-specific runtime library. See (@@ ref Chapter @@ -2245,6 +2255,27 @@ namespace odb +

The in() function accepts maximum of five argumets. + Use the in_range() function if you need to compare + to more than five values. This function accepts a pair of + standard C++ iterators and compares to all the value from + the begin position inclusive and until and + excluding the end position. The following + code fragment shows how we can use these functions:

+ +
+  std::vector<string> names;
+
+  names.push_back ("John");
+  names.push_back ("Jack");
+  names.push_back ("Jane");
+
+  query q1 (query::first.in ("John", "Jack", "Jane"));
+  query q2 (query::first.in_range (names.begin (), names.end ()));
+  
+ + +

The operator precedence in the query expressions are the same as for equivalent C++ operators. You can use parentheses to make sure the expression is evaluated in the desired order. @@ -2418,13 +2449,24 @@ namespace odb operator= (const result&); void - cache (); + swap (result&) + public: iterator begin (); iterator end (); + + public: + void + cache (); + + bool + empty () const; + + std::size_t + size () const; }; } @@ -2458,6 +2500,13 @@ namespace odb executing any other database function, such as update() or erase() will also invalidate the uncached result.

+

The empty() function returns true if + there are no objects in the result and false otherwise. + The size() function can only be called for cached results. + It returns the number of objects in the result. If you call this + function on an uncached result, the odb::result_not_cached + exception is thrown.

+

To iterate over the objects in a result we use the begin() and end() functions together with the odb::result<T>::iterator -- cgit v1.1