diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-28 10:12:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-28 10:12:34 +0200 |
commit | 2709ab07167efffddd65f772ff99361bba30b006 (patch) | |
tree | 7f47f502f1422ce5ae9c285dac7a0b3c81044775 /doc | |
parent | c7329f436428ffe9110b410979bd98bfa7f2fcce (diff) |
Documentation for std::vector<char> to BLOB mapping
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.xhtml | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 47ec14b..ede430d 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -7725,6 +7725,41 @@ aCC +W2161 ... to the <code>VARCHAR(255)</code> MySQL type. Otherwise, it is mapped to <code>TEXT</code>.</p> + <p>The MySQL ODB runtime library also provides support for mapping the + <code>std::vector<char></code> type to the MySQL BLOB types. + However, this mapping is not enabled by default (by default, + <code>std::vector<char></code> will be treated as a container). + To enable the BLOB mapping for this type we need to specify + the database type explicitly using the <code>db type</code> + pragma (<a href="#10.3.3">Section 10.3.3, "<code>type</code>"</a>), + for example:</p> + + <pre class="c++"> +#pragma db object +class object +{ + ... + + #pragma db type("BLOB") + std::vector<char> buf_; +}; + </pre> + + <p>Alternatively, this can be done on the per-type basis, for example:</p> + + <pre class="c++"> +typedef std::vector<char> buffer; +#pragma db value(buffer) type("BLOB") + +#pragma db object +class object +{ + ... + + buffer buf_; // Mapped to BLOB. +}; + </pre> + <p>Additionally, by default, C++ enumerations are automatically mapped to a suitable MySQL type. Contiguous enumerations with the zero first enumerator are mapped to the MySQL <code>ENUM</code> @@ -8230,6 +8265,41 @@ namespace odb </tr> </table> + <p>The SQLite ODB runtime library also provides support for mapping the + <code>std::vector<char></code> type to the SQLite BLOB type. + However, this mapping is not enabled by default (by default, + <code>std::vector<char></code> will be treated as a container). + To enable the BLOB mapping for this type we need to specify + the database type explicitly using the <code>db type</code> + pragma (<a href="#10.3.3">Section 10.3.3, "<code>type</code>"</a>), + for example:</p> + + <pre class="c++"> +#pragma db object +class object +{ + ... + + #pragma db type("BLOB") + std::vector<char> buf_; +}; + </pre> + + <p>Alternatively, this can be done on the per-type basis, for example:</p> + + <pre class="c++"> +typedef std::vector<char> buffer; +#pragma db value(buffer) type("BLOB") + +#pragma db object +class object +{ + ... + + buffer buf_; // Mapped to BLOB. +}; + </pre> + <p>Additionally, by default, C++ enumerations are automatically mapped to the SQLite <code>INTEGER</code> type with the default <code>NULL</code> semantics being <code>NOT NULL</code>.</p> @@ -8780,6 +8850,41 @@ class person </tr> </table> + <p>The PostgreSQL ODB runtime library also provides support for mapping the + <code>std::vector<char></code> type to the PostgreSQL BYTEA type. + However, this mapping is not enabled by default (by default, + <code>std::vector<char></code> will be treated as a container). + To enable the BYTEA mapping for this type we need to specify + the database type explicitly using the <code>db type</code> + pragma (<a href="#10.3.3">Section 10.3.3, "<code>type</code>"</a>), + for example:</p> + + <pre class="c++"> +#pragma db object +class object +{ + ... + + #pragma db type("BYTEA") + std::vector<char> buf_; +}; + </pre> + + <p>Alternatively, this can be done on the per-type basis, for example:</p> + + <pre class="c++"> +typedef std::vector<char> buffer; +#pragma db value(buffer) type("BYTEA") + +#pragma db object +class object +{ + ... + + buffer buf_; // Mapped to BYTEA. +}; + </pre> + <p>Additionally, by default, C++ enumerations are automatically mapped to <code>INTEGER</code> with the default <code>NULL</code> semantics being <code>NOT NULL</code>.</p> |