33 #define PROG_NAME "xapian-metadata"
34 #define PROG_DESC "Read and write user metadata"
37 cout <<
"Usage: " PROG_NAME " get PATH_TO_DATABASE KEY\n"
38 " " PROG_NAME " list PATH_TO_DATABASE [PREFIX]\n"
39 " " PROG_NAME " set PATH_TO_DATABASE KEY VALUE\n";
43 main(
int argc,
char **argv)
45 const char * command = argv[1];
52 if (command[0] ==
'-') {
53 if (strcmp(command,
"--help") == 0) {
58 if (strcmp(command,
"--version") == 0) {
64 if (strcmp(command,
"get") == 0) {
65 if (argc != 4)
goto syntax_error;
68 }
else if (strcmp(command,
"list") == 0) {
69 if (argc != 3 && argc != 4)
goto syntax_error;
72 if (argc == 4) prefix = argv[3];
78 }
else if (strcmp(command,
"set") == 0) {
79 if (argc != 5)
goto syntax_error;
An indexed database of documents.
Xapian::TermIterator metadata_keys_begin(std::string_view prefix={}) const
An iterator which returns all user-specified metadata keys.
Xapian::TermIterator metadata_keys_end(std::string_view={}) const noexcept
End iterator corresponding to metadata_keys_begin().
std::string get_metadata(std::string_view key) const
Get the user-specified metadata associated with a given key.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
std::string get_description() const
Return a string describing this object.
Class for iterating over a list of terms.
This class provides read/write access to a database.
void set_metadata(std::string_view key, std::string_view metadata)
Set the user-specified metadata associated with a given key.
void commit()
Commit pending modifications.
const int DB_CREATE_OR_OPEN
Create database if it doesn't already exist.
Public interfaces for the Xapian library.