-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocSearchPath.h
More file actions
85 lines (68 loc) · 2.37 KB
/
ocSearchPath.h
File metadata and controls
85 lines (68 loc) · 2.37 KB
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
// Filename: ocSearchPath.h
// Created by: frang (03June04)
//
////////////////////////////////////////////////////////////////////
#ifndef SEARCHPATH_H
#define SEARCHPATH_H
#include "oconfig.h"
#include "filename.h"
#include <vector>
#define ocvector std::vector
///////////////////////////////////////////////////////////////////
// Class : OCSearchPath
// Description : This class stores a list of directories that can be
// searched, in order, to locate a particular file. It
// is normally constructed by passing it a traditional
// searchpath-style string, e.g. a list of directory
// names delimited by spaces or colons, but it can also
// be built up explicitly.
////////////////////////////////////////////////////////////////////
class OCSearchPath {
public:
class Results {
public:
Results();
Results(const Results ©);
void operator = (const Results ©);
~Results();
void clear();
int get_num_files() const;
const Filename &get_file(int n) const;
void add_file(const Filename &file);
private:
typedef ocvector<Filename> Files;
Files _files;
};
public:
OCSearchPath();
OCSearchPath(const string &path, const string &delimiters = ": \n\t");
OCSearchPath(const OCSearchPath ©);
void operator = (const OCSearchPath ©);
~OCSearchPath();
void clear();
void append_directory(const Filename &directory);
void prepend_directory(const Filename &directory);
void append_path(const string &path,
const string &delimiters = ": \n\t");
void append_path(const OCSearchPath &path);
void prepend_path(const OCSearchPath &path);
bool is_empty() const;
int get_num_directories() const;
const Filename &get_directory(int n) const;
Filename find_file(const Filename &filename) const;
int find_all_files(const Filename &filename, Results &results) const;
INLINE static Filename
search_path(const Filename &filename, const string &path,
const string &delimiters = ": \n\t");
void output(ostream &out, const string &separator = ":") const;
void write(ostream &out, int indent_level = 0) const;
private:
typedef ocvector<Filename> Directories;
Directories _directories;
};
INLINE ostream &operator << (ostream &out, const OCSearchPath &sp) {
sp.output(out);
return out;
}
#include "ocSearchPath.I"
#endif