diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | doc/manual.xhtml | 19 | ||||
-rw-r--r-- | odb/pragma.cxx | 48 | ||||
-rw-r--r-- | odb/validator.cxx | 2 |
4 files changed, 28 insertions, 44 deletions
@@ -53,6 +53,9 @@ Version 2.1.0 more information, refer to Section 20.1, "Basic Types" in the ODB manual as well as the 'qt' example in the odb-examples package. + * The id() pragma that was used to declare a persistent class without an + object id has been renamed to no_id. + * New pragma, definition, allows the specification of an alternative code generation location for persistent classes, views, and composite value types. This mechanism is primarily useful for converting third-party diff --git a/doc/manual.xhtml b/doc/manual.xhtml index e5632ce..adcc45a 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -454,7 +454,7 @@ for consistency. <tr><th>12.1.3</th><td><a href="#12.1.3"><code>abstract</code></a></td></tr> <tr><th>12.1.4</th><td><a href="#12.1.4"><code>readonly</code></a></td></tr> <tr><th>12.1.5</th><td><a href="#12.1.5"><code>optimistic</code></a></td></tr> - <tr><th>12.1.6</th><td><a href="#12.1.6"><code>id</code></a></td></tr> + <tr><th>12.1.6</th><td><a href="#12.1.6"><code>no_id</code></a></td></tr> <tr><th>12.1.7</th><td><a href="#12.1.7"><code>callback</code></a></td></tr> <tr><th>12.1.8</th><td><a href="#12.1.8"><code>schema</code></a></td></tr> <tr><th>12.1.9</th><td><a href="#12.1.9"><code>polymorphic</code></a></td></tr> @@ -2271,7 +2271,7 @@ class person default-constructible. It is also possible to declare a persistent class without an object id, however, such a class will have limited functionality (<a href="#12.1.6">Section 12.1.6, - "<code>id</code>"</a>).</p> + "<code>no_id</code>"</a>).</p> <p>The above two pragmas are the minimum required to declare a persistent class with an object id. Other pragmas can be used to @@ -9221,7 +9221,7 @@ class person </tr> <tr> - <td><code>id</code></td> + <td><code>no_id</code></td> <td>persistent class has no object id</td> <td><a href="#12.1.6">12.1.6</a></td> </tr> @@ -9435,14 +9435,13 @@ class person <p>For a more detailed discussion of optimistic concurrency, refer to <a href="#11">Chapter 11, "Optimistic Concurrency"</a>.</p> - <h3><a name="12.1.6">12.1.6 <code>id</code></a></h3> + <h3><a name="12.1.6">12.1.6 <code>no_id</code></a></h3> - <p>The <code>id</code> specifier specifies that the persistent class - has no object id. It should be followed by opening and closing - parenthesis. For example:</p> + <p>The <code>no_id</code> specifier specifies that the persistent class + has no object id. For example:</p> <pre class="cxx"> -#pragma db object id() +#pragma db object no_id class person { ... @@ -10920,8 +10919,8 @@ class person <p>Normally, every persistent class has a data member designated as an object's identifier. However, it is possible to declare a - persistent class without an id using the object <code>id</code> - specifier (<a href="#12.1.6">Section 12.1.6, "<code>id</code>"</a>).</p> + persistent class without an id using the object <code>no_id</code> + specifier (<a href="#12.1.6">Section 12.1.6, "<code>no_id</code>"</a>).</p> <p>Note also that the <code>id</code> specifier cannot be used for data members of composite value types or views.</p> diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 5cae6b1..9d97d2a 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -362,18 +362,19 @@ check_spec_decl_type (declaration const& d, int tc (d.tree_code ()); bool type (TREE_CODE_CLASS (tc) == tcc_type); - if (p == "id") + if (p == "no_id") { - // Id can be used for both data members and objects. + // No_id can be used on objects only. // - if (tc != FIELD_DECL && tc != RECORD_TYPE) + if (tc != RECORD_TYPE) { error (l) << "name '" << name << "' in db pragma " << p << " does " << "not refer to a data member or class" << endl; return false; } } - else if (p == "auto" || + else if (p == "id" || + p == "auto" || p == "column" || p == "inverse" || p == "version" || @@ -1434,43 +1435,24 @@ handle_pragma (cxx_lexer& l, } else if (p == "id") { - // id (member) - // id() (object) - // Make sure we've got the correct declaration type. // if (decl && !check_spec_decl_type (decl, decl_name, p, loc)) return; tt = l.next (tl, &tn); + } + else if (p == "no_id") + { + // Make sure we've got the correct declaration type. + // + if (decl && !check_spec_decl_type (decl, decl_name, p, loc)) + return; - if (tt == CPP_OPEN_PAREN) - { - if (qualifier == "member") - { - error (l) << "unexpected '(' after db pragma " << p << endl; - return; - } - - if (l.next (tl, &tn) != CPP_CLOSE_PAREN) - { - error (l) << "')' expected at the end of db pragma " << p << endl; - return; - } - - val = false; // Object without id. - tt = l.next (tl, &tn); - } - else - { - if (qualifier == "object") - { - error (l) << "expected '(' after db pragma " << p << endl; - return; - } + name = "id"; + val = false; - val = true; // Member is object id. - } + tt = l.next (tl, &tn); } else if (p == "auto") { diff --git a/odb/validator.cxx b/odb/validator.cxx index 55f7edf..225a2a1 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -423,7 +423,7 @@ namespace os << c.file () << ":" << c.line () << ":" << c.column () << ":" << " info: or explicitly declare that this persistent class " - << "has no object id" << endl; + << "has no object id with '#pragma db object no_id'" << endl; valid_ = false; } |