blob: f310d558c9aa587930aa8ea6e9680d2905b50053 (
plain)
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
|
// file : cutl/fs/path.hxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#ifndef CUTL_FS_PATH_HXX
#define CUTL_FS_PATH_HXX
#include <string>
#include <iosfwd>
#include <cutl/exception.hxx>
namespace cutl
{
namespace fs
{
struct invalid_path: exception
{
virtual char const*
what () const throw ();
};
template <typename C>
class basic_path;
typedef basic_path<char> path;
typedef basic_path<wchar_t> wpath;
template <typename C>
class basic_path
{
public:
typedef std::basic_string<C> string_type;
typedef typename string_type::size_type size_type;
explicit
basic_path (C const* s)
: path_ (s)
{
init (false);
}
explicit
basic_path (string_type const& s)
: path_ (s)
{
init (false);
}
public:
basic_path
leaf () const;
basic_path
directory () const;
basic_path
base () const;
public:
basic_path
operator/ (basic_path const&);
public:
string_type
string () const
{
return path_.empty () ? string_type (1, '/') : path_;
}
private:
void
init (bool internal);
// Assume internal format.
//
basic_path (C const* s, size_type n)
: path_ (s, n)
{
init (true);
}
private:
string_type path_;
};
template <typename C>
inline std::basic_ostream<C>&
operator<< (std::basic_ostream<C>& os, basic_path<C> const& p)
{
return os << p.string ();
}
}
}
#include <cutl/fs/path.txx>
#endif // CUTL_FS_PATH_HXX
|