File: lpath.hpp

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (99 lines) | stat: -rw-r--r-- 3,258 bytes parent folder | download
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
//  Boost lpath.hpp  ---------------------------------------------------------//

//  Copyright Beman Dawes 2005

//  Use, modification, and distribution is subject to the Boost Software
//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See library home page at http://www.boost.org/libs/filesystem

#include <boost/filesystem/path.hpp>
#include <string>

namespace std
{
  // Note well: this specialization is meant only to support wide_test.cpp.
  // It is not fully functional, fully correct, or efficient.
  template<> struct char_traits<long>
  {
    typedef long char_type;
    typedef long int_type;
    typedef streamoff off_type;
    typedef streampos pos_type;
    typedef mbstate_t state_type;
    static void assign(char_type& c1, const char_type& c2){c1=c2;}
    static bool eq(const char_type& c1, const char_type& c2){return c1==c2;}
    static bool lt(const char_type& c1, const char_type& c2){return c1<c2;}
    static int compare(const char_type* s1, const char_type* s2, size_t n)
    {
      const char_type* e = s1 + n;
      for ( ;s1 != e && *s1 == *s2; ++s1, ++s2 ) {}
      return s1 == e ? 0 : (*s1<*s2 ? -1 : 1);
    }
    static size_t length(const char_type* s)
    { const char_type* b=s; for(;*s!=0L;++s){} return s-b; } 
 
    static const char_type* find(const char_type* /*s*/, size_t /*n*/, const char_type& /*a*/)
    {   return 0; }

    // copy semantics will do for wide_test
    static char_type* move(char_type* s1, const char_type* s2, size_t n)
      { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; }

    static char_type* copy(char_type* s1, const char_type* s2, size_t n)
      { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; }

    static char_type* assign(char_type* s, size_t n, char_type a)
      { char_type* b=s; for(char_type* e=s+n;s!=e;++s) *s=a; return b; }
 
    static int_type not_eof(const int_type& c);
    static char_type to_char_type(const int_type& c);
    static int_type to_int_type(const char_type& c);
    static bool eq_int_type(const int_type& c1, const int_type& c2);
    static int_type eof();
  };
}

namespace user
{
  typedef std::basic_string<long> lstring;
  struct lpath_traits;
  typedef boost::filesystem::basic_path<lstring, lpath_traits> lpath;

  struct lpath_traits
  {
    typedef lstring internal_string_type;
    typedef std::string external_string_type;

    static external_string_type to_external( const lpath &,
      const internal_string_type & src )
    {
      external_string_type tmp;
      for ( internal_string_type::const_iterator it( src.begin() );
        it != src.end(); ++it )
      {
        tmp += static_cast<external_string_type::value_type>(*it);
      }
      return tmp;
    }

    static internal_string_type to_internal( const external_string_type & src )
    {
      internal_string_type tmp;
      for ( external_string_type::const_iterator it( src.begin() );
        it != src.end(); ++it ) tmp += *it;
      return tmp;
    }
  };

} // namespace user

namespace boost
{
  namespace filesystem
  {
    template<> struct is_basic_path<user::lpath>
      { static const bool value = true; };
  }
}