File indexing completed on 2024-04-28 16:01:34
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_TREE_H 0022 #define LIBQGIT2_TREE_H 0023 0024 #include "qgitobject.h" 0025 0026 #include <QtCore/QString> 0027 0028 namespace LibQGit2 0029 { 0030 class OId; 0031 class TreeEntry; 0032 0033 /** 0034 * @brief Wrapper class for git_tree. 0035 * Represents a Git tree object. 0036 * 0037 * @ingroup LibQGit2 0038 * @{ 0039 */ 0040 class LIBQGIT2_EXPORT Tree : public Object 0041 { 0042 public: 0043 0044 /** 0045 * Creates a Tree that points to tree. The pointer object becomes managed by 0046 * this Tree, and must not be passed to another Tree or closed outside this 0047 * object. 0048 */ 0049 explicit Tree(git_tree *tree = 0); 0050 0051 /** 0052 * Copy constructor; creates a copy of the object, sharing the same underlaying data 0053 * structure. 0054 */ 0055 Tree(const Tree& other); 0056 0057 /** 0058 * Destroys the object. 0059 */ 0060 ~Tree(); 0061 0062 /** 0063 * * Get the id of a tree. 0064 * * @return object identity for the tree. 0065 * */ 0066 OId oid(); 0067 0068 /** 0069 * Get the number of entries listed in a tree 0070 * @return the number of entries in the tree 0071 */ 0072 size_t entryCount(); 0073 0074 /** 0075 * Lookup a tree entry by its filename 0076 * @param filename the filename of the desired entry 0077 * @return the tree entry; NULL if not found 0078 */ 0079 TreeEntry entryByName(const QString& fileName) const; 0080 0081 /** 0082 * Lookup a tree entry by its position in the tree 0083 * @param idx the position in the entry list 0084 * @return the tree entry; NULL if not found 0085 */ 0086 TreeEntry entryByIndex(int idx) const; 0087 0088 git_tree* data() const; 0089 const git_tree* constData() const; 0090 }; 0091 0092 /**@}*/ 0093 } 0094 0095 #endif // LIBQGIT2_TREE_H