OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [seekoff/] [wchar_t/] [11543.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// Copyright (C) 2003, 2009
2
// Free Software Foundation, Inc.
3
//
4
// This file is part of the GNU ISO C++ Library.  This library is free
5
// software; you can redistribute it and/or modify it under the
6
// terms of the GNU General Public License as published by the
7
// Free Software Foundation; either version 3, or (at your option)
8
// any later version.
9
 
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
 
15
// You should have received a copy of the GNU General Public License along
16
// with this library; see the file COPYING3.  If not see
17
// <http://www.gnu.org/licenses/>.
18
 
19
// 27.8.1.4 Overridden virtual functions
20
 
21
#include <fstream>
22
#include <locale>
23
#include <testsuite_hooks.h>
24
 
25
struct MyState
26
{
27
};
28
 
29
struct MyCharTraits : std::char_traits<wchar_t>
30
{
31
  typedef std::fpos<MyState> pos_type;
32
  typedef MyState state_type;
33
};
34
 
35
namespace std
36
{
37
  template <>
38
    class codecvt<wchar_t, char, MyState> :
39
      public locale::facet, public codecvt_base
40
    {
41
    public:
42
      typedef wchar_t intern_type;
43
      typedef char extern_type;
44
      typedef MyState state_type;
45
 
46
      explicit codecvt(size_t refs = 0)
47
      : locale::facet(refs) { }
48
 
49
      result out(state_type& state, const intern_type* from,
50
                 const intern_type* from_end,  const intern_type*& from_next,
51
                 extern_type* to, extern_type* to_limit,
52
                 extern_type*& to_next) const
53
      { return do_out(state, from, from_end, from_next,
54
                      to, to_limit, to_next); }
55
 
56
      result unshift(state_type& state, extern_type* to, extern_type* to_limit,
57
                     extern_type*& to_next) const
58
      { return do_unshift(state, to, to_limit, to_next); }
59
 
60
      result in(state_type& state, const extern_type* from,
61
                const extern_type* from_end, const extern_type*& from_next,
62
                intern_type* to, intern_type* to_limit,
63
                intern_type*& to_next) const
64
      { return do_in(state, from, from_end, from_next,
65
                     to, to_limit, to_next); }
66
 
67
      int encoding() const throw()
68
      { return do_encoding(); }
69
 
70
      bool always_noconv() const throw()
71
      { return do_always_noconv(); }
72
 
73
      int length(state_type& state, const extern_type* from,
74
                 const extern_type* end, size_t max) const
75
      { return do_length(state, from, end, max); }
76
 
77
      int max_length() const throw()
78
      { return do_max_length(); }
79
 
80
      static locale::id id;
81
 
82
    protected:
83
      virtual ~codecvt();
84
 
85
      virtual result do_out(state_type&, const intern_type*,
86
                            const intern_type*, const intern_type*&,
87
                            extern_type*, extern_type*, extern_type*&) const
88
      { return error; }
89
 
90
      virtual result do_in(state_type&, const extern_type*, const extern_type*,
91
                           const extern_type*&, intern_type*, intern_type*,
92
                           intern_type*&) const
93
      { return error; }
94
 
95
      virtual result do_unshift(state_type&, extern_type*, extern_type*,
96
                                extern_type*&) const
97
      { return noconv; }
98
 
99
      virtual int do_encoding() const throw()
100
      { return 1; }
101
 
102
      virtual bool do_always_noconv() const throw()
103
      { return false; }
104
 
105
      virtual int do_length(state_type&, const extern_type* from,
106
                            const extern_type* end, size_t max) const
107
      {
108
        size_t len = end - from;
109
        return std::min(max, len);
110
      }
111
 
112
      virtual int do_max_length() const throw()
113
      { return 1; }
114
    };
115
 
116
  locale::id codecvt<wchar_t, char, MyState>::id;
117
 
118
  codecvt<wchar_t, char, MyState>::~codecvt()
119
  { }
120
}
121
 
122
void test01()
123
{
124
  bool test __attribute__((unused)) = true;
125
 
126
  std::locale loc(std::locale::classic(),
127
                  new std::codecvt<wchar_t, char, MyState>);
128
  std::basic_filebuf<wchar_t, MyCharTraits> fb;
129
  fb.pubimbue(loc);
130
  fb.open("tmp_11543", std::ios_base::out);
131
  VERIFY( fb.is_open() );
132
  MyCharTraits::pos_type pos = fb.pubseekoff(0, std::ios_base::beg);
133
  VERIFY( pos != MyCharTraits::pos_type(MyCharTraits::off_type(-1)) );
134
  fb.close();
135
}
136
 
137
int main()
138
{
139
  test01();
140
  return 0;
141
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.