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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
includefile(include/header)
COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::Glob)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
(Files matching a pattern)
manpagename(FBB::Glob)
(Wrapper around bf(glob)(3) to find files matching a pattern)
manpagesynopsis()
bf(#include <bobcat/glob>)nl()
Linking option: tt(-lbobcat)
manpagedescription()
The bf(FBB::Glob) class is a wrapper around the bf(C) function
bf(glob)(3). It returns a list of files matching a certain pattern provided to
bf(FBB::Glob)'s constructors or members.
includefile(include/namespace)
manpagesection(INHERITS FROM)
-
manpagesection(ENUMERATIONS)
bf(Glob::Type): nl()
This enumeration, which is identical to the bf(stat)(3bobcat) tt(Type)
enumeration, defines the following values:
includefile(gs.inc)
These values are also used by bf(stat)(2) and bf(lstat)(2). Although they
can be combined using the tt(bitor) operator, they are not uniquely
recognizable when combined. E.g., the value of tt(CHARACTER_DEVICE |
DIRECTORY) is equal to the value of tt(BLOCK_DEVICE). It's also possible
to combine tt(Type) values in a tt(std::unordered_set), which avoids the
confusion that may result from using the tt(bitor) operator.
bf(Glob::Flags):
itemization(
itt(NO_FLAG): Equals 0, and can be used to avoid having to specify 0. It
has no further use.
itt(ERR): Return on read errors;
itt(MARK): Append a slash to each name.
itt(NOSORT): Don't sort the names.
itt(NOESCAPE): Backslashes don't quote metacharacters.
itt(PERIOD): Leading tt(.)-characters can be matched by metachars (i.e.,
tt(*) and tt(?)).
itt(NOMATCH): When specified the constructors won't throw exceptions when
no files matching their glob-patterns could be found. Instead they
will return normally, and tt(Glob's size()) member (see below) will
return 0.
)
bf(Glob::Dots):
itemization(
itt(FIRST): Filenames starting with a dot will be listed first. Within
this set and in the leftover-set the relative ordering is maintained.
itt(DEFAULT): Return filenames as they appear in the globbing process.
)
manpagesection(CONSTRUCTORS)
itemization(
itb(Glob(std::string const &pattern = "*", int flags = PERIOD,
Dots dots = FIRST))
This constructor (which can also be used as the default constructor)
determines all elements matching tt(pattern).
An tt(Exception) exception is thrown if the constructor could not
properly complete it tasks.
Multiple flags may be specified, separated by the tt(bitor) operator.
This constructor properly completes its task if only defined bf(Flag)
values were specified and if the bf(glob)(3) function returned without
errors;
itb(Glob(Type type, std::string const &pattern = "*", int flags = PERIOD,
Dots dots = FIRST))
This constructor determines all elements of tt(pattern) when their
types `tt(elementType)' are equal to the value of tt(elementType &
type). The specified tt(type) value may consist of any tt(bitor)-ed
combination of enum values defined by the tt(Type) enum. Note that
this may produce confusing results. E.g., when specifying
tt(DIRECTORY), elements that are tt(BLOCK_DEVICEs) or tt(SOCKETs) are
also accepted. The next constructor can be used to avoid this
confusion;
itb(Glob(std::unordered_set<Type> const &typeSet,
std::string const &pattern = "*", int flags = PERIOD,
Dots dots = FIRST))
This constructor determines all elements of tt(pattern) when their
types are found in tt(typeSet). Different from the previous
constructor, for an element to be accepted its type must exactly match
a type value in the tt(typeSet) set.
)
Copy and move constructors (and assignment operators) are available.
manpagesection(OVERLOADED OPERATORS)
itemization(
itb(char const *operator[](size_t idx) const)
The element at index position tt(idx) is returns as a bf(C) string. It
returns an empty string if tt(idx) is or exceeds bf(size()).
)
manpagesection(MEMBER FUNCTIONS)
itemization(
itb(size_t size() const)
Returns the number of elements that were detected;
itb(char const *const *begin() const)
Returns a pointer to the first element that was detected. This pointer
can be used in generic algorithms as an output-iterator supporting
pointer arithmetic;
itb(char const *const *end() const)
Returns a pointer beyond the last element that was detected. This
pointer can be used in generic algorithms as an output-iterator
supporting pointer arithmetic;
itb(void swap(Glob &other))
Swaps the content of the other object with the current object.
)
manpagesection(EXAMPLES)
verb(
int main(int argc, char **argv)
{
if (argc == 1)
{
cout << "Provide glob-expression as 1st arg\n";
return 1;
}
cout << "General:\n";
Glob general;
for (size_t idx = 0; idx < general.size(); idx++)
cout << idx << ": " << general[idx] << endl;
cout << "Pattern: " << argv[1] << "\n";
Glob pattern(argv[1], Glob::PERIOD, Glob::DEFAULT);
for (size_t idx = 0; idx < pattern.size(); idx++)
cout << idx << ": " << pattern[idx] << endl;
}
)
manpagefiles()
em(bobcat/glob) - defines the class interface
manpageseealso()
bf(bobcat)(7), bf(stat)(3bobcat), bf(glob)(3)
manpagebugs()
No Reported Bugs.
includefile(include/trailer)
|