|
Boost : |
From: davlet_panech (davlet_panech_at_[hidden])
Date: 2002-02-14 17:32:46
Hello,
Is there any interest in a filename parser library?
What I have in mind is a filename class modelled as a container of
path components; each path component consists of a "proper" name and
an extension, something along these lines:
// (possibly a template)
class filename_component
{
public:
typedef std::string string_type;
// Full name
string_type str() const;
void str( const string_type &s );
// Name minus extension
string_type proper() const;
void proper( const string_type &s );
// Extension
string_type ext() const;
void ext( const string_type &s );
bool has_ext() const;
// ...
};
// This is a sequence of filename_components
class filename
{
public:
// Things from sequence requirements, e.g.
const filename_component &
operator [] ( size_type n ) const;
//
// additional members
//
static const char path_sep_char;
// Full path name
string_type str() const;
void str( const string_type &s );
// Parent filename
filename parent() const;
// Absolute or relative path?
bool absolute() const;
// Last component
const filename_component &base() const
{
return operator[] ( size() - 1 );
}
// ...
};
Comments?
D.P.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk