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

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 #include "qgittree.h"
0022 
0023 #include "qgittreeentry.h"
0024 #include "qgitoid.h"
0025 
0026 #include "private/pathcodec.h"
0027 
0028 namespace LibQGit2
0029 {
0030 
0031 Tree::Tree(git_tree *tree)
0032     : Object(reinterpret_cast<git_object*>(tree))
0033 {
0034 }
0035 
0036 Tree::Tree( const Tree& other )
0037     : Object(other)
0038 {
0039 }
0040 
0041 Tree::~Tree()
0042 {
0043 }
0044 
0045 OId Tree::oid()
0046 {
0047     return OId(git_tree_id(data()));
0048 }
0049 
0050 size_t Tree::entryCount()
0051 {
0052     return git_tree_entrycount(data());
0053 }
0054 
0055 TreeEntry Tree::entryByName(const QString& fileName) const
0056 {
0057     return TreeEntry(git_tree_entry_byname(constData(), PathCodec::toLibGit2(fileName)));
0058 }
0059 
0060 TreeEntry Tree::entryByIndex(int idx) const
0061 {
0062     return TreeEntry(git_tree_entry_byindex(data(), idx));
0063 }
0064 
0065 git_tree* Tree::data() const
0066 {
0067     return reinterpret_cast<git_tree*>(Object::data());
0068 }
0069 
0070 const git_tree* Tree::constData() const
0071 {
0072     return reinterpret_cast<git_tree*>(Object::data());
0073 }
0074 
0075 } // namespace LibQGit2