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_TREEENTRY_H 0022 #define LIBQGIT2_TREEENTRY_H 0023 0024 #include "git2.h" 0025 0026 #include "qgitobject.h" 0027 #include "libqgit2_export.h" 0028 0029 namespace LibQGit2 0030 { 0031 class OId; 0032 class Repository; 0033 0034 /** 0035 * @brief Wrapper class for git_tree_entry. 0036 * Represents a Git child tree entry, that can either point to another tree object or a blob. 0037 * 0038 * @ingroup LibQGit2 0039 * @{ 0040 */ 0041 class LIBQGIT2_EXPORT TreeEntry 0042 { 0043 public: 0044 explicit TreeEntry(const git_tree_entry* treeEntry); 0045 TreeEntry(const TreeEntry& other); 0046 ~TreeEntry(); 0047 0048 public: 0049 /** 0050 * @return true when internal pointer is 0; otherwise false 0051 */ 0052 bool isNull() const; 0053 0054 /** 0055 * Get the UNIX file attributes of a tree entry 0056 * @return attributes as an integer 0057 */ 0058 unsigned int attributes() const; 0059 0060 /** 0061 * Get the filename of a tree entry 0062 * @return the name of the file 0063 */ 0064 const QString name() const; 0065 0066 /** 0067 * Get the id of the object pointed by the entry 0068 * @return the oid of the object 0069 */ 0070 OId oid() const; 0071 0072 /** 0073 * Get the type of the \c Object where this entry points to. 0074 * @note %Tree entries might not support all the possible object types. 0075 */ 0076 Object::Type type() const; 0077 0078 /** 0079 * Convert a tree entry to the Object it points too. 0080 * 0081 * @param object pointer to the converted object 0082 * @return a reference to the pointed object in the repository 0083 * @throws LibQGit2::Exception 0084 */ 0085 Object toObject(const Repository& repo); 0086 0087 const git_tree_entry* data() const; 0088 0089 private: 0090 const git_tree_entry *d; 0091 }; 0092 0093 /**@}*/ 0094 } 0095 0096 #endif // LIBQGIT2_TREEENTRY_H