1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
13 #include "unicode/utypes.h"
17 * Represents an absolute path into a resource bundle.
18 * For example: "/units/length/meter"
22 /** Constructs an empty path (top of tree) */
25 /** Constructs from a string path */
26 ResKeyPath(const std::string
& path
, UErrorCode
& status
);
28 void push(const std::string
& key
);
31 const std::list
<std::string
>& pieces() const;
34 std::list
<std::string
> fPath
;
37 std::ostream
& operator<<(std::ostream
& out
, const ResKeyPath
& value
);
41 * Interface used to determine whether to include or reject pieces of a
42 * resource bundle based on their absolute path.
52 static const char* kEInclusionNames
[];
54 virtual ~PathFilter();
57 * Returns an EInclusion on whether or not the given path should be included.
59 * INCLUDE = include the whole subtree
60 * PARTIAL = recurse into the subtree
61 * EXCLUDE = reject the whole subtree
63 virtual EInclusion
match(const ResKeyPath
& path
) const = 0;
68 * Implementation of PathFilter for a list of inclusion/exclusion rules.
70 * The wildcard pattern "*" means that the subsequent filters are applied to
71 * every other tree sharing the same parent.
73 * For example, given this list of filter rules:
76 // +/alabama/alaska/arizona
79 // +/mississippi/michigan
80 // +/mississippi/*/maine
81 // -/mississippi/*/iowa
82 // +/mississippi/louisiana/iowa
84 * You get the following structure:
86 * SimpleRuleBasedPathFilter {
135 class SimpleRuleBasedPathFilter
: public PathFilter
{
137 void addRule(const std::string
& ruleLine
, UErrorCode
& status
);
138 void addRule(const ResKeyPath
& path
, bool inclusionRule
, UErrorCode
& status
);
140 EInclusion
match(const ResKeyPath
& path
) const override
;
142 void print(std::ostream
& out
) const;
149 /** Copy constructor */
150 Tree(const Tree
& other
);
153 * Information on the USER-SPECIFIED inclusion/exclusion.
155 * INCLUDE = this path exactly matches a "+" rule
156 * PARTIAL = this path does not match any rule, but subpaths exist
157 * EXCLUDE = this path exactly matches a "-" rule
159 EInclusion fIncluded
= PARTIAL
;
160 std::map
<std::string
, Tree
> fChildren
;
161 std::unique_ptr
<Tree
> fWildcard
;
164 const ResKeyPath
& path
,
165 std::list
<std::string
>::const_iterator it
,
171 void print(std::ostream
& out
, int32_t indent
) const;
177 std::ostream
& operator<<(std::ostream
& out
, const SimpleRuleBasedPathFilter
& value
);
180 #endif //__FILTERRB_H__