File: nignore.h

package info (click to toggle)
xstow 1.0.2-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,064 kB
  • ctags: 1,073
  • sloc: cpp: 7,264; sh: 1,216; makefile: 196; awk: 26
file content (92 lines) | stat: -rw-r--r-- 1,643 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * $Log: nignore.h,v $
 * Revision 1.3  2010/07/21 19:38:25  martin
 * gcc-4 Port
 *
 * Revision 1.2  2005/07/04 21:59:42  martin
 * added logging to all files
 *
 */
#ifndef NIGNORE_H
#define NIGNORE_H

#include "local_config.h"

#ifdef CAN_USE_NIGNORE

#include <string>
#include <vector>
#include "ref.h"
#include "leoini.h"
#include "range.h"
#include <iostream>

class Node;

class NIgnore
{
 public:
    struct EnumMatch
    {
	  enum ETYPE
		{
		  FIRST__ = -1,
		  FALSE = 0,
		  TRUE,
		  REQUIRE_NEXT,
		  LAST__
		};
    };

    typedef EnumRange<EnumMatch> MATCH;

 private:
    std::string name;

    std::vector<std::string> dir;
    bool                     follow;


    bool is_valid;

 public:
    NIgnore( const std::string &name, Leo::Ini &ini );

    MATCH match( Ref<Node> node, std::string & strip );

    bool valid() const { return is_valid; }

    std::string getName() const { return name; }

    friend std::ostream & operator<<( std::ostream &out, Ref<NIgnore> ni );
    
 private:
    MATCH match_dir( Ref<Node> node, std::string & strip );
};

std::ostream & operator<<( std::ostream &out, Ref<NIgnore> ni );

class NIgnoreChain
{
    std::vector< Ref<NIgnore> > nignores;
 public:

    NIgnoreChain() {}

    void add( Ref<NIgnore> ni ) { nignores.push_back( ni ); }

    bool match( Ref<Node> node );

    unsigned size() const { return nignores.size(); }
    bool empty() const { return nignores.size(); }

    std::string getName();

    friend std::ostream & operator<<( std::ostream &out, Ref<NIgnoreChain> nc );
};

std::ostream & operator<<( std::ostream &out, Ref<NIgnoreChain> nc );

#endif

#endif