📄 classxapian_1_1writabledatabase.tex
字号:
\hypertarget{classXapian_1_1WritableDatabase}{\section{Xapian::Writable\-Database Class Reference}\label{classXapian_1_1WritableDatabase}\index{Xapian::WritableDatabase@{Xapian::WritableDatabase}}}This class provides read/write access to a database. {\tt \#include $<$database.h$>$}Inheritance diagram for Xapian::Writable\-Database:\begin{figure}[H]\begin{center}\leavevmode\includegraphics[width=86pt]{classXapian_1_1WritableDatabase__inherit__graph}\end{center}\end{figure}Collaboration diagram for Xapian::Writable\-Database:\begin{figure}[H]\begin{center}\leavevmode\includegraphics[width=86pt]{classXapian_1_1WritableDatabase__coll__graph}\end{center}\end{figure}\subsection*{Public Member Functions}\begin{CompactItemize}\item virtual \hyperlink{classXapian_1_1WritableDatabase_98ae55d72630237f346986b60e765e36}{$\sim$Writable\-Database} ()\begin{CompactList}\small\item\em Destroy this handle on the database. \item\end{CompactList}\item \hyperlink{classXapian_1_1WritableDatabase_c80ed31814feebd10c6222386e31472e}{Writable\-Database} ()\begin{CompactList}\small\item\em Create an empty \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database}. \item\end{CompactList}\item \hyperlink{classXapian_1_1WritableDatabase_2084dc5811aedc7de65d77e7979a2ec8}{Writable\-Database} (const std::string \&path, int action)\begin{CompactList}\small\item\em Open a database for update, automatically determining the database backend to use. \item\end{CompactList}\item \hypertarget{classXapian_1_1WritableDatabase_f746042dda9a411719cef333783d6534}{{\bf Writable\-Database} (Database::Internal $\ast$internal)}\label{classXapian_1_1WritableDatabase_f746042dda9a411719cef333783d6534}\item \hyperlink{classXapian_1_1WritableDatabase_1529742b3f7eb92f07e75f2308bc2f3a}{Writable\-Database} (const \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database} \&other)\begin{CompactList}\small\item\em Copying is allowed. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_c97254827cb74c93606ae046dcdd3754}{operator=} (const \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database} \&other)\begin{CompactList}\small\item\em Assignment is allowed. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}{flush} ()\begin{CompactList}\small\item\em Flush to disk any modifications made to the database. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_702276148fd73a78310e5ec5e4c466cd}{begin\_\-transaction} ()\begin{CompactList}\small\item\em Begin a transaction. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_3d330f3a27cc17d78635781c7b77280f}{commit\_\-transaction} ()\begin{CompactList}\small\item\em End the transaction currently in progress, committing the modifications made to the database. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_537b50dd4aad61020ea8536e93559a72}{cancel\_\-transaction} ()\begin{CompactList}\small\item\em End the transaction currently in progress, cancelling the potential modifications made to the database. \item\end{CompactList}\item \hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} \hyperlink{classXapian_1_1WritableDatabase_ecdd2e1d3a0364c4933ef4fe655f080b}{add\_\-document} (const \hyperlink{classXapian_1_1Document}{Xapian::Document} \&document)\begin{CompactList}\small\item\em Add a new document to the database. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_0cfd78ba9108b9ef2cf9b4a9f545c70d}{delete\_\-document} (\hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} did)\begin{CompactList}\small\item\em Delete a document from the database. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_8426619892e77112e832fc4b11b8efc3}{delete\_\-document} (const std::string \&unique\_\-term)\begin{CompactList}\small\item\em Delete any documents indexed by a term from the database. \item\end{CompactList}\item void \hyperlink{classXapian_1_1WritableDatabase_23344c9000ea98b15d491fa875bd5d1e}{replace\_\-document} (\hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} did, const \hyperlink{classXapian_1_1Document}{Xapian::Document} \&document)\begin{CompactList}\small\item\em Replace a given document in the database. \item\end{CompactList}\item \hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} \hyperlink{classXapian_1_1WritableDatabase_43c4630ec482508667e9ca539f19cbf0}{replace\_\-document} (const std::string \&unique\_\-term, const \hyperlink{classXapian_1_1Document}{Xapian::Document} \&document)\begin{CompactList}\small\item\em Replace any documents matching a term. \item\end{CompactList}\item std::string \hyperlink{classXapian_1_1WritableDatabase_714ee6f7f21fd72307329a4ba21227a0}{get\_\-description} () const \begin{CompactList}\small\item\em Introspection method. \item\end{CompactList}\end{CompactItemize}\subsection{Detailed Description}This class provides read/write access to a database. \subsection{Constructor \& Destructor Documentation}\hypertarget{classXapian_1_1WritableDatabase_98ae55d72630237f346986b60e765e36}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!~WritableDatabase@{$\sim$WritableDatabase}}\index{~WritableDatabase@{$\sim$WritableDatabase}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[$\sim$WritableDatabase]{\setlength{\rightskip}{0pt plus 5cm}virtual Xapian::Writable\-Database::$\sim$Writable\-Database ()\hspace{0.3cm}{\tt \mbox{[}virtual\mbox{]}}}}\label{classXapian_1_1WritableDatabase_98ae55d72630237f346986b60e765e36}Destroy this handle on the database. If there are no copies of this object remaining, the database will be closed. If there are any transactions in progress these will be ended. \hypertarget{classXapian_1_1WritableDatabase_c80ed31814feebd10c6222386e31472e}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!WritableDatabase@{WritableDatabase}}\index{WritableDatabase@{WritableDatabase}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[WritableDatabase]{\setlength{\rightskip}{0pt plus 5cm}Xapian::Writable\-Database::Writable\-Database ()}}\label{classXapian_1_1WritableDatabase_c80ed31814feebd10c6222386e31472e}Create an empty \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database}. \hypertarget{classXapian_1_1WritableDatabase_2084dc5811aedc7de65d77e7979a2ec8}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!WritableDatabase@{WritableDatabase}}\index{WritableDatabase@{WritableDatabase}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[WritableDatabase]{\setlength{\rightskip}{0pt plus 5cm}Xapian::Writable\-Database::Writable\-Database (const std::string \& {\em path}, int {\em action})}}\label{classXapian_1_1WritableDatabase_2084dc5811aedc7de65d77e7979a2ec8}Open a database for update, automatically determining the database backend to use. If the database is to be created, \hyperlink{namespaceXapian}{Xapian} will try to create the directory indicated by path if it doesn't already exist (but only the leaf directory, not recursively).\begin{Desc}\item[Parameters:]\begin{description}\item[{\em path}]directory that the database is stored in. \item[{\em action}]one of:\begin{itemize}\item Xapian::DB\_\-CREATE\_\-OR\_\-OPEN open for read/write; create if no db exists\item Xapian::DB\_\-CREATE create new database; fail if db exists\item Xapian::DB\_\-CREATE\_\-OR\_\-OVERWRITE overwrite existing db; create if none exists\item Xapian::DB\_\-OPEN open for read/write; fail if no db exists \end{itemize}\end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_1529742b3f7eb92f07e75f2308bc2f3a}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!WritableDatabase@{WritableDatabase}}\index{WritableDatabase@{WritableDatabase}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[WritableDatabase]{\setlength{\rightskip}{0pt plus 5cm}Xapian::Writable\-Database::Writable\-Database (const \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database} \& {\em other})}}\label{classXapian_1_1WritableDatabase_1529742b3f7eb92f07e75f2308bc2f3a}Copying is allowed. The internals are reference counted, so copying is cheap. \subsection{Member Function Documentation}\hypertarget{classXapian_1_1WritableDatabase_ecdd2e1d3a0364c4933ef4fe655f080b}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!add_document@{add\_\-document}}\index{add_document@{add\_\-document}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[add\_\-document]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} Xapian::Writable\-Database::add\_\-document (const \hyperlink{classXapian_1_1Document}{Xapian::Document} \& {\em document})}}\label{classXapian_1_1WritableDatabase_ecdd2e1d3a0364c4933ef4fe655f080b}Add a new document to the database. This method adds the specified document to the database, returning a newly allocated document ID.Note that this does not mean the document will immediately appear in the database; see \hyperlink{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}{flush()} for more details.As with all database modification operations, the effect is atomic: the document will either be fully added, or the document fails to be added and an exception is thrown (possibly at a later time when flush is called or the database is closed).\begin{Desc}\item[Parameters:]\begin{description}\item[{\em document}]The new document to be added.\end{description}\end{Desc}\begin{Desc}\item[Returns:]The document ID of the newly added document.\end{Desc}\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while writing to the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_702276148fd73a78310e5ec5e4c466cd}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!begin_transaction@{begin\_\-transaction}}\index{begin_transaction@{begin\_\-transaction}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[begin\_\-transaction]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::begin\_\-transaction ()}}\label{classXapian_1_1WritableDatabase_702276148fd73a78310e5ec5e4c466cd}Begin a transaction. For the purposes of \hyperlink{namespaceXapian}{Xapian}, a transaction is a group of modifications to the database which are grouped together such that either all or none of them will succeed. Even in the case of a power failure, this characteristic should be preserved (as long as the filesystem isn't corrupted, etc).Transactions are only available with certain access methods, and as you might expect will generally have a fairly high performance cost.\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Unimplemented\-Error}]will be thrown if transactions are not available for this database type.\item[{\em Xapian::Invalid\-Operation\-Error}]will be thrown if this is called at an invalid time, such as when a transaction is already in progress. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_537b50dd4aad61020ea8536e93559a72}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!cancel_transaction@{cancel\_\-transaction}}\index{cancel_transaction@{cancel\_\-transaction}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[cancel\_\-transaction]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::cancel\_\-transaction ()}}\label{classXapian_1_1WritableDatabase_537b50dd4aad61020ea8536e93559a72}End the transaction currently in progress, cancelling the potential modifications made to the database. If an error occurs in this method, an exception will be thrown, but the transaction will be cancelled anyway.\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while modifying the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state.\item[{\em Xapian::Invalid\-Operation\-Error}]will be thrown if a transaction is not currently in progress.\item[{\em Xapian::Unimplemented\-Error}]will be thrown if transactions are not available for this database type. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_3d330f3a27cc17d78635781c7b77280f}{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -