Ticket #709: 709-get_revision_info.diff

File 709-get_revision_info.diff, 2.0 KB (added by German M. Bravo, 8 years ago)
  • xapian-core/api/omdatabase.cc

    commit 034c5fcd3ff57b5410bc0bbd47377a0a5f47618d
    Author: German M. Bravo <german.mb@deipi.com>
    Date:   Wed Feb 3 16:41:14 2016 -0600
    
        Added get_revision_info() public method to Database class.
        
        This is to allow implementations to get a representation of the
        internal description of the current revision of a database. This can
        be used to implement replication and/or sinchronization protocols
        among databases.
    
    diff --git a/xapian-core/api/omdatabase.cc b/xapian-core/api/omdatabase.cc
    index 876e3ee..1f6dfc4 100644
    a b Database::get_uuid() const  
    750750    RETURN(uuid);
    751751}
    752752
     753std::string
     754Database::get_revision_info() const
     755{
     756    LOGCALL(API, std::string, "Database::get_revision_info", NO_ARGS);
     757    string revision_info;
     758    for (size_t i = 0; i < internal.size(); ++i) {
     759        string sub_revision_info = internal[i]->get_revision_info();
     760        // If any of the sub-databases have no revision_info, we can't make a revision_info for
     761        // the combined database.
     762        if (sub_revision_info.empty())
     763            RETURN(sub_revision_info);
     764        if (!revision_info.empty()) revision_info += ':';
     765        revision_info += sub_revision_info;
     766    }
     767    RETURN(revision_info);
     768}
     769
    753770///////////////////////////////////////////////////////////////////////////
    754771
    755772WritableDatabase::WritableDatabase() : Database()
  • xapian-core/include/xapian/database.h

    diff --git a/xapian-core/include/xapian/database.h b/xapian-core/include/xapian/database.h
    index 4a6acfc..7119d6e 100644
    a b class XAPIAN_VISIBILITY_DEFAULT Database {  
    481481         */
    482482        std::string get_uuid() const;
    483483
     484        /** Get the revision info for the database.
     485         *
     486         *  The revision info is a string representation describing the current
     487         *  revision of the database.
     488         */
     489        std::string get_revision_info() const;
     490
    484491        /** Check the integrity of a database or database table.
    485492         *
    486493         *  @param path Path to database or table