PageRenderTime 32ms CodeModel.GetById 19ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/win32/shellext/dirstate.h

https://bitbucket.org/tortoisehg/hgtk/
C++ Header | 56 lines | 26 code | 15 blank | 15 comment | 0 complexity | 024c80935ac56e1dc629b263df4ec38b MD5 | raw file
 1
 2// Copyright (C) 2009 Benjamin Pollack
 3// Copyright (C) 2009 Adrian Buehlmann
 4//
 5// This program is free software: you can redistribute it and/or modify
 6// it under the terms of the GNU General Public License as published by
 7// the Free Software Foundation, either version 2 of the License, or
 8// (at your option) any later version.
 9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18#ifndef _DIRSTATE_H
19#define _DIRSTATE_H
20
21#include "Directory.h"
22
23#include <string>
24
25
26#define HASH_LENGTH 20
27
28class Dirstate
29{
30    Directory root_;
31
32    unsigned num_added_; // number of entries that have state 'a'
33    unsigned num_entries_;
34
35public:
36    char parent1[HASH_LENGTH];
37    char parent2[HASH_LENGTH];
38
39    static std::auto_ptr<Dirstate> read(const std::string& path, bool& unset);
40
41    Directory& root() { return root_; }
42
43    void add(const std::string& relpath, Direntry& e) {
44        root_.add(relpath, e);
45        ++num_entries_; 
46    }
47    
48    unsigned num_added() const { return num_added_; }
49    unsigned size() const { return num_entries_; }
50
51private:
52    Dirstate()
53    : root_(0, "", ""), num_added_(0), num_entries_(0) {}
54};
55
56#endif