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;
This class is used to access a database, or a group of databases.
const int DB_CREATE_OR_OPEN
Create database if it doesn't already exist.
void set_metadata(const std::string &key, const std::string &metadata)
Set the user-specified metadata associated with a given key.
std::string get_metadata(const std::string &key) const
Get the user-specified metadata associated with a given key.
Class for iterating over a list of terms.
This class provides read/write access to a database.
Public interfaces for the Xapian library.
void commit()
Commit any pending modifications made to the database.
std::string get_description() const
Return a string describing this object.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Xapian::TermIterator metadata_keys_begin(const std::string &prefix=std::string()) const
An iterator which returns all user-specified metadata keys.
Xapian::TermIterator metadata_keys_end(const std::string &=std::string()) const
Corresponding end iterator to metadata_keys_begin().