File indexing completed on 2024-04-28 16:01:32

0001 /******************************************************************************
0002  * This file is part of the libqgit2 library
0003  * Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
0004  * Copyright (C) 2013 Leonardo Giordani
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #ifndef LIBQGIT2_INDEX_ENTRY_H
0022 #define LIBQGIT2_INDEX_ENTRY_H
0023 
0024 #include "git2.h"
0025 
0026 #include <QString>
0027 
0028 #include "libqgit2_export.h"
0029 
0030 namespace LibQGit2
0031 {
0032     class OId;
0033 
0034     /**
0035      * @brief Wrapper class for git_index_entry.
0036      * Represents a Git index/stage entry.
0037      *
0038      * @ingroup LibQGit2
0039      * @{
0040      */
0041     class LIBQGIT2_EXPORT IndexEntry
0042     {
0043         public:
0044             /**
0045              * Create a new Git index entry object
0046              */
0047             explicit IndexEntry(const git_index_entry *data);
0048 
0049             /**
0050              * Copy constructor
0051              */
0052             IndexEntry(const IndexEntry& other);
0053 
0054             /**
0055              * Destruct an existing index object.
0056              */
0057             ~IndexEntry();
0058 
0059             /**
0060              * Get the id of an index entry.
0061              */
0062             OId id() const;
0063 
0064             /**
0065              * Get the path of the index entry, represented by a string
0066              */
0067             QString path() const;
0068 
0069             /**
0070              * Get the size of the file
0071              */
0072             qint64 fileSize() const;
0073 
0074             /**
0075              * Get the stage of this index entry.
0076              * See `git read-tree` documentation for the meaning of the different stages.
0077              *
0078              * @return The stage, from 0 to 3 inclusive.
0079              * @see http://git-scm.com/docs/git-read-tree
0080              */
0081             int stage() const;
0082 
0083             const git_index_entry *data() const;
0084 
0085         private:
0086             const git_index_entry *d;
0087     };
0088 
0089     /**@}*/
0090 }
0091 
0092 #endif // LIBQGIT2_INDEX_ENTRY_H