path.hxx   path.hxx 
// file : cutl/fs/path.hxx // file : cutl/fs/path.hxx
// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file // license : MIT; see accompanying LICENSE file
#ifndef CUTL_FS_PATH_HXX #ifndef CUTL_FS_PATH_HXX
#define CUTL_FS_PATH_HXX #define CUTL_FS_PATH_HXX
#include <string> #include <string>
#include <iosfwd> #include <ostream>
#include <cutl/exception.hxx> #include <cutl/exception.hxx>
#include <cutl/details/export.hxx> #include <cutl/details/export.hxx>
namespace cutl namespace cutl
{ {
namespace fs namespace fs
{ {
template <typename C> template <typename C>
skipping to change at line 42 skipping to change at line 42
static C const path_separator = ';'; static C const path_separator = ';';
#else #else
static C const directory_separator = '/'; static C const directory_separator = '/';
static C const path_separator = ':'; static C const path_separator = ':';
#endif #endif
// Directory separator tests. On some platforms there // Directory separator tests. On some platforms there
// could be multiple seperators. For example, on Windows // could be multiple seperators. For example, on Windows
// we check for both '/' and '\'. // we check for both '/' and '\'.
// //
static bool static bool
is_separator (C c) is_separator (C c)
{ {
#ifdef _WIN32 #ifdef _WIN32
return c == '\\' || c == '/'; return c == '\\' || c == '/';
#else #else
return c == '/'; return c == '/';
#endif #endif
} }
skipping to change at line 81 skipping to change at line 80
pos++; pos++;
for (; pos > 0; --pos) for (; pos > 0; --pos)
{ {
if (is_separator (s[pos - 1])) if (is_separator (s[pos - 1]))
return pos - 1; return pos - 1;
} }
return string_type::npos; return string_type::npos;
} }
static int
compare (string_type const& l, string_type const& r)
{
size_type ln (l.size ()), rn (r.size ()), n (ln < rn ? ln : rn);
for (size_type i (0); i != n; ++i)
{
#ifdef _WIN32
C lc (tolower (l[i])), rc (tolower (r[i]));
#else
C lc (l[i]), rc (r[i]);
#endif
if (is_separator (lc) && is_separator (rc))
continue;
if (lc < rc) return -1;
if (lc > rc) return 1;
}
return ln < rn ? -1 : (ln > rn ? 1 : 0);
}
private:
#ifdef _WIN32
static C
tolower (C);
#endif
}; };
template <typename C> template <typename C>
class invalid_basic_path; class invalid_basic_path;
typedef basic_path<char> path; typedef basic_path<char> path;
typedef invalid_basic_path<char> invalid_path; typedef invalid_basic_path<char> invalid_path;
typedef basic_path<wchar_t> wpath; typedef basic_path<wchar_t> wpath;
typedef invalid_basic_path<wchar_t> invalid_wpath; typedef invalid_basic_path<wchar_t> invalid_wpath;
skipping to change at line 213 skipping to change at line 239
directory () const; directory () const;
// Return the path without the extension, if any. // Return the path without the extension, if any.
// //
basic_path basic_path
base () const; base () const;
public: public:
// Normalize the path. This includes collapsing the '.' and '..' // Normalize the path. This includes collapsing the '.' and '..'
// directories if possible, collapsing multiple directory // directories if possible, collapsing multiple directory
// separators, converting all directory separators to the // separators, and converting all directory separators to the
// canonical form, and making the path lower-case if the // canonical form. Returns *this.
// filesystem is not case-sensitive (e.g., Windows). Returns
// *this.
// //
basic_path& basic_path&
normalize (); normalize ();
// Make the path absolute using the current directory unless // Make the path absolute using the current directory unless
// it is already absolute. // it is already absolute.
// //
basic_path& basic_path&
complete (); complete ();
skipping to change at line 252 skipping to change at line 276
return basic_path (path_ + s); return basic_path (path_ + s);
} }
basic_path& basic_path&
operator+= (string_type const& s) operator+= (string_type const& s)
{ {
path_ += s; path_ += s;
return *this; return *this;
} }
// Note that comparison is case-insensitive if the filesystem is
// not case-sensitive (e.g., Windows).
//
bool bool
operator== (basic_path const& x) const operator== (basic_path const& x) const
{ {
return path_ == x.path_; return traits::compare (path_, x.path_) == 0;
} }
bool bool
operator!= (basic_path const& x) const operator!= (basic_path const& x) const
{ {
return !(*this == x); return !(*this == x);
} }
bool bool
operator< (basic_path const& x) const operator< (basic_path const& x) const
{ {
return path_ < x.path_; return traits::compare (path_, x.path_) < 0;
} }
public: public:
string_type string_type
string () const string () const
{ {
return path_; return path_;
} }
// If possible, return a POSIX representation of the path. For exampl e, // If possible, return a POSIX representation of the path. For exampl e,
skipping to change at line 290 skipping to change at line 317
// this path (e.g., c:\foo), this function will throw the invalid_pat h // this path (e.g., c:\foo), this function will throw the invalid_pat h
// exception. // exception.
// //
string_type string_type
posix_string () const; posix_string () const;
private: private:
void void
init (); init ();
#ifdef _WIN32
static C
tolower (C);
#endif
private: private:
string_type path_; string_type path_;
}; };
template <typename C> template <typename C>
inline std::basic_ostream<C>& inline std::basic_ostream<C>&
operator<< (std::basic_ostream<C>& os, basic_path<C> const& p) operator<< (std::basic_ostream<C>& os, basic_path<C> const& p)
{ {
return os << p.string (); return os << p.string ();
} }
 End of changes. 8 change blocks. 
13 lines changed or deleted 35 lines changed or added


 path.ixx   path.ixx 
skipping to change at line 14 skipping to change at line 14
#ifdef _WIN32 #ifdef _WIN32
# include <cctype> // std::tolower # include <cctype> // std::tolower
# include <cwctype> // std::towlower # include <cwctype> // std::towlower
#endif #endif
namespace cutl namespace cutl
{ {
namespace fs namespace fs
{ {
#ifdef _WIN32
template <>
inline char path_traits<char>::
tolower (char c)
{
return std::tolower (c);
}
template <>
inline wchar_t path_traits<wchar_t>::
tolower (wchar_t c)
{
return std::towlower (c);
}
#endif
template <typename C> template <typename C>
inline bool basic_path<C>:: inline bool basic_path<C>::
absolute () const absolute () const
{ {
#ifdef _WIN32 #ifdef _WIN32
return path_.size () > 1 && path_[1] == ':'; return path_.size () > 1 && path_[1] == ':';
#else #else
return !path_.empty () && traits::is_separator (path_[0]); return !path_.empty () && traits::is_separator (path_[0]);
#endif #endif
} }
skipping to change at line 54 skipping to change at line 70
} }
#ifndef _WIN32 #ifndef _WIN32
template <typename C> template <typename C>
inline typename basic_path<C>::string_type basic_path<C>:: inline typename basic_path<C>::string_type basic_path<C>::
posix_string () const posix_string () const
{ {
return string (); return string ();
} }
#endif #endif
#ifdef _WIN32
template <>
inline char basic_path<char>::
tolower (char c)
{
return std::tolower (c);
}
template <>
inline wchar_t basic_path<wchar_t>::
tolower (wchar_t c)
{
return std::towlower (c);
}
#endif
} }
} }
 End of changes. 2 change blocks. 
16 lines changed or deleted 16 lines changed or added


 path.txx   path.txx 
skipping to change at line 185 skipping to change at line 185
r.push_back (s); r.push_back (s);
} }
// Reassemble the path. // Reassemble the path.
// //
string_type p; string_type p;
for (typename paths::const_iterator i (r.begin ()), e (r.end ()); for (typename paths::const_iterator i (r.begin ()), e (r.end ());
i != e;) i != e;)
{ {
#ifdef _WIN32
for (size_type j (0), n (i->size ()); j < n; ++j)
p += tolower ((*i)[j]);
#else
p += *i; p += *i;
#endif
++i;
if (i != e) if (++i != e)
p += traits::directory_separator; p += traits::directory_separator;
} }
if (p.empty () && !r.empty ()) if (p.empty () && !r.empty ())
p += traits::directory_separator; // Root directory. p += traits::directory_separator; // Root directory.
path_.swap (p); path_.swap (p);
return *this; return *this;
} }
 End of changes. 3 change blocks. 
7 lines changed or deleted 1 lines changed or added


 value-traits.hxx   value-traits.hxx 
skipping to change at line 43 skipping to change at line 43
static bool static bool
parse (std::string, const parser&); parse (std::string, const parser&);
static std::string static std::string
serialize (bool v, const serializer&) serialize (bool v, const serializer&)
{ {
return v ? "true" : "false"; return v ? "true" : "false";
} }
}; };
template <>
struct LIBCUTL_EXPORT default_value_traits<std::string>
{
static std::string
parse (std::string s, const parser&)
{
return s;
}
static std::string
serialize (const std::string& v, const serializer&)
{
return v;
}
};
template <typename T> template <typename T>
struct value_traits: default_value_traits<T> {}; struct value_traits: default_value_traits<T> {};
template <typename T, std::size_t N> template <typename T, std::size_t N>
struct value_traits<T[N]>: default_value_traits<const T*> {}; struct value_traits<T[N]>: default_value_traits<const T*> {};
} }
} }
#include <cutl/xml/value-traits.txx> #include <cutl/xml/value-traits.txx>
 End of changes. 1 change blocks. 
0 lines changed or deleted 16 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/