You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by an...@apache.org on 2006/06/30 18:18:20 UTC
svn commit: r418318 - in /incubator/stdcxx/trunk/tests: include/21.strings.h
include/rw_streambuf.h src/21.strings.cpp
Author: antonp
Date: Fri Jun 30 09:18:19 2006
New Revision: 418318
URL: http://svn.apache.org/viewvc?rev=418318&view=rev
Log:
2006-06-30 Anton Pevtsov <an...@moscow.vdiweb.com>
* 21.strings.h (MemberId): Added new elements for inserter,
extractor, getline non-members.
(OverloadId): Added new enum elements for these non-members and
their overloads.
(ArgId): Added new elements for input and output stream arguments.
* 21.strings.cpp (_rw_sigcat): Updated to operate with
stream arguments and new fids, added new formatting variables
ISTREAM and OSTREAM processing
(_rw_setvars): Added new formatting variables ISTREAM and OSTREAM
processing to operate with stream arguments in string's non-members.
* rw_streambuf.h: Added support for UserChar.
Modified:
incubator/stdcxx/trunk/tests/include/21.strings.h
incubator/stdcxx/trunk/tests/include/rw_streambuf.h
incubator/stdcxx/trunk/tests/src/21.strings.cpp
Modified: incubator/stdcxx/trunk/tests/include/21.strings.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/21.strings.h?rev=418318&r1=418317&r2=418318&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/21.strings.h (original)
+++ incubator/stdcxx/trunk/tests/include/21.strings.h Fri Jun 30 09:18:19 2006
@@ -110,6 +110,9 @@
/* 40 */ fid_c_str,
/* 41 */ fid_data,
/* 42 */ fid_get_allocator,
+ /* 43 */ fid_extractor,
+ /* 44 */ fid_inserter,
+ /* 45 */ fid_getline,
/* -- */ fid_bits = 6,
/* -- */ fid_mask = 63
};
@@ -131,6 +134,8 @@
/* 10 */ arg_str, // string& (or this for member functions)
/* 11 */ arg_cstr, // const string& (or const this for members)
/* 12 */ arg_alloc, // const allocator&
+ /* 13 */ arg_istream, // istream&
+ /* 14 */ arg_ostream, // ostream&
/* -- */ arg_bits = 4,
/* -- */ arg_mask = 15
};
@@ -599,7 +604,19 @@
//////////////////////////////////////////////////////////////
// get_allocator () const
- MEMBER_0 (get_allocator, cstr)
+ MEMBER_0 (get_allocator, cstr),
+
+ //////////////////////////////////////////////////////////////
+ // operator>> (istream&, basic_string&)
+ NON_MEMBER_2 (extractor, istream, str),
+ // operator<< (ostream&, const basic_string&)
+ NON_MEMBER_2 (inserter, ostream, cstr),
+
+ //////////////////////////////////////////////////////////////
+ // getline (istream&, basic_string&)
+ NON_MEMBER_2 (getline, istream, str),
+ // getline (istream&, basic_string&, value_type)
+ NON_MEMBER_3 (getline, istream, str, val)
};
// clean up helper macros used above
Modified: incubator/stdcxx/trunk/tests/include/rw_streambuf.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/rw_streambuf.h?rev=418318&r1=418317&r2=418318&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/rw_streambuf.h (original)
+++ incubator/stdcxx/trunk/tests/include/rw_streambuf.h Fri Jun 30 09:18:19 2006
@@ -33,6 +33,7 @@
#include <streambuf> // for basic_streambuf
#include <testdefs.h>
+#include <rw_char.h> // for make_char
enum MemFun {
@@ -210,7 +211,7 @@
buf_ = new charT [bufsize_];
// invalidate the contents of the buffer
- traits_type::assign (buf_, bufsize_, charT ('\xfe'));
+ traits_type::assign (buf_, bufsize_, make_char ('\xfe', buf_));
// set the put area to 0 size to force a call to overflow()
// on the first write attempt to the buffer
@@ -248,7 +249,7 @@
for (std::streamsize inx = 0; inx != bufsize_; ++inx) {
typedef unsigned char UChar;
- buf_ [inx] = UChar (buf [inx]);
+ buf_ [inx] = make_char (buf [inx], buf_);
}
// zero out the (non-dereferenceable) element just past the end
@@ -359,7 +360,7 @@
const int_type last = traits_type::to_int_type (*this->gptr ());
if (!traits_type::eq_int_type (c, traits_type::eof ()))
- traits_type::assign (*this->gptr (), c);
+ traits_type::assign (*this->gptr (), traits_type::to_char_type (c));
return last;
}
Modified: incubator/stdcxx/trunk/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/21.strings.cpp?rev=418318&r1=418317&r2=418318&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/21.strings.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Fri Jun 30 09:18:19 2006
@@ -90,7 +90,8 @@
"operator+", "operator==", "operator!=", "operator<", "operator<=",
"operator>", "operator>=", "size", "length", "max_size", "resize",
"capacity", "reserve", "clear", "empty", "begin", "end", "rbegin",
- "rend", "c_str", "data", "get_allocator"
+ "rend", "c_str", "data", "get_allocator", "operator>>", "operator<<",
+ "getline"
};
/**************************************************************************/
@@ -237,6 +238,8 @@
case Ids::fid_op_less_equal: funcname = "op_less_equal"; break;
case Ids::fid_op_greater: funcname = "op_greater"; break;
case Ids::fid_op_greater_equal: funcname = "op_greater_equal"; break;
+ case Ids::fid_extractor: funcname = "extractor"; break;
+ case Ids::fid_inserter: funcname = "inserter"; break;
case Ids::fid_compare:
case Ids::fid_copy:
@@ -319,6 +322,9 @@
tname = _rw_class_name (*func);
sfx = "&";
break;
+
+ case Ids::arg_istream: tname = "istream&"; break;
+ case Ids::arg_ostream: tname = "ostream&"; break;
}
}
else {
@@ -335,23 +341,34 @@
case Ids::arg_alloc: tname = "alloc"; break;
case Ids::arg_str: tname = "str"; break;
case Ids::arg_cstr: tname = "cstr"; break;
+ case Ids::arg_istream: tname = "istream"; break;
+ case Ids::arg_ostream: tname = "ostream"; break;
}
}
RW_ASSERT (0 != tname);
if ( 0 == func || is_member
- || Ids::arg_str != argtype && Ids::arg_cstr != argtype) {
+ || Ids::arg_str != argtype && Ids::arg_cstr != argtype
+ && Ids::arg_istream != argtype && Ids::arg_ostream != argtype) {
// append the name or mnemonic of the argument type
rw_asnprintf (pbuf, pbufsize, "%{+}%{?}_%{:}%{?}, %{;}%{;}%s%s%s",
0 == func, 0 < argno, pfx, tname, sfx);
}
+ else if (Ids::arg_istream == argtype || Ids::arg_ostream == argtype) {
+ // in non-member functions use ${{I|O}STREAM} to format
+ // the basic_{i|o}stream argument in order to expand
+ // its template argument list
+ rw_asnprintf (pbuf, pbufsize,
+ "%{+}%{?}, %{;}%{?}%{$ISTREAM}%{:}%{$OSTREAM}%{;}&",
+ 0 < argno, Ids::arg_istream == argtype);
+ }
else {
// in non-member functions use ${CLASS} to format
// the basic_string argument in order to expand
// its template argument list
rw_asnprintf (pbuf, pbufsize,
- "%{+}%{?}, %{;}%{?}const %{$CLASS}&%{;}",
+ "%{+}%{?}, %{;}%{?}const %{;}%{$CLASS}&",
0 < argno, Ids::arg_cstr == argtype);
}
@@ -446,17 +463,64 @@
// set the {CLASS} variable to the name of the specialization
// of basic_string
rw_fprintf (0, "%{$CLASS!:*}", buf);
+ free (buf);
+ buf = 0;
+ bufsize = 0;
- // determine the string function name
- const size_t funcinx = func.which_ & StringIds::fid_mask;
- const size_t nfuncs = sizeof _rw_func_names / sizeof *_rw_func_names;
+ // set the {ISTREAM} environment variable
+ // to the name of the specialization of the template basic_istream
- RW_ASSERT (funcinx < nfuncs);
+ if ( StringIds::DefaultTraits == func.traits_id_
+ && ( StringIds::Char == func.char_id_
+ || StringIds::WChar == func.char_id_)) {
+ // format std::istream and std::wistream
+ rw_asnprintf (&buf, &bufsize, "std::%{?}w%{;}istream",
+ StringIds::WChar == func.char_id_);
+ }
+ else {
+ // format std::basic_istream specializations other than
+ // std::istream and std::wistream
+ rw_asnprintf (&buf, &bufsize,
+ "std::basic_istream<%s, %s<%1$s>>",
+ _rw_char_names [func.char_id_],
+ _rw_traits_names [func.traits_id_]);
+ }
+ rw_fprintf (0, "%{$ISTREAM!:*}", buf);
free (buf);
buf = 0;
bufsize = 0;
+ // set the {OSTREAM} environment variable
+ // to the name of the specialization of the template basic_ostream
+
+ if ( StringIds::DefaultTraits == func.traits_id_
+ && ( StringIds::Char == func.char_id_
+ || StringIds::WChar == func.char_id_)) {
+ // format std::ostream and std::wostream
+ rw_asnprintf (&buf, &bufsize, "std::%{?}w%{;}ostream",
+ StringIds::WChar == func.char_id_);
+ }
+ else {
+ // format std::basic_ostream specializations other than
+ // std::ostream and std::wostream
+ rw_asnprintf (&buf, &bufsize,
+ "std::basic_ostream<%s, %s<%1$s>>",
+ _rw_char_names [func.char_id_],
+ _rw_traits_names [func.traits_id_]);
+ }
+
+ rw_fprintf (0, "%{$OSTREAM!:*}", buf);
+ free (buf);
+ buf = 0;
+ bufsize = 0;
+
+ // determine the string function name
+ const size_t funcinx = func.which_ & StringIds::fid_mask;
+ const size_t nfuncs = sizeof _rw_func_names / sizeof *_rw_func_names;
+
+ RW_ASSERT (funcinx < nfuncs);
+
// get the undecorated function name; ctors are treated
// specially so that we can have string, wstring, or
// basic_string, depending on the template arguments
@@ -979,6 +1043,22 @@
pcase->val, int (arg_len), arg);
break;
+ case StringIds::extractor_istream_str:
+ case StringIds::getline_istream_str:
+ rw_asnprintf (&buf, &bufsize,
+ "%{+} (%{$ISTREAM}&, %{$CLASS}&)");
+ break;
+
+ case StringIds::getline_istream_str_val:
+ rw_asnprintf (&buf, &bufsize,
+ "%{+} (%{$ISTREAM}&, %{$CLASS}&, %{#c})", pcase->val);
+ break;
+
+ case StringIds::inserter_ostream_cstr:
+ rw_asnprintf (&buf, &bufsize,
+ "%{+} (%{$OSTREAM}&, const %{$CLASS}&)");
+ break;
+
case StringIds::resize_size_val:
rw_asnprintf (&buf, &bufsize,
"%{+} (%zu, %{#c})", pcase->size, pcase->val);
@@ -1602,7 +1682,7 @@
free (optbuf);
return status;
-}
+}