Create an STM32F4Discovery configuration for testing uClibc++

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5300 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-11-02 23:22:48 +00:00
parent 708ebb52f0
commit 23e8d5321a
50 changed files with 15444 additions and 11451 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+519 -363
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <cstddef>
@@ -29,395 +29,551 @@
#pragma GCC visibility push(default)
namespace std{
template <size_t N> class bitset;
extern "C++"
{
namespace std
{
template <size_t N> class bitset;
template <size_t N> bitset<N> operator&(const bitset<N>&, const bitset<N>&);
template <size_t N> bitset<N> operator|(const bitset<N>&, const bitset<N>&);
template <size_t N> bitset<N> operator^(const bitset<N>&, const bitset<N>&);
template <class charT, class traits, size_t N> basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
template <size_t N> bitset<N> operator&(const bitset<N>&, const bitset<N>&);
template <size_t N> bitset<N> operator|(const bitset<N>&, const bitset<N>&);
template <size_t N> bitset<N> operator^(const bitset<N>&, const bitset<N>&);
template <class charT, class traits, size_t N> basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
template <class charT, class traits, size_t N> basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
// Actual Code
template <class charT, class traits, size_t N> basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
//Actual Code
template<size_t N> class _UCXXEXPORT bitset {
private:
//Number of characters allocated to hold the bits
static const size_t WORD_SIZE = CHAR_BIT; //Use int maybe?
static const size_t num_bytes = (N + WORD_SIZE - 1) / WORD_SIZE;
template<size_t N> class _UCXXEXPORT bitset {
private:
//Number of characters allocated to hold the bits
static const size_t WORD_SIZE = CHAR_BIT; //Use int maybe?
static const size_t num_bytes = (N + WORD_SIZE - 1) / WORD_SIZE;
//From the bit number, figure out which byte we are working with
//From the bit number, figure out which byte we are working with
size_t byte_num(size_t bit_num) const{
if(WORD_SIZE == 8){
return (bit_num >> 3);
}
if(WORD_SIZE == 16){
return (bit_num >> 4);
}
if(WORD_SIZE == 32){
return (bit_num >> 5);
}
if(WORD_SIZE == 64){
return (bit_num >> 6);
}
return bit_num / WORD_SIZE;
}
//From the bit number, figure out which bit inside the byte we need
size_t bit_num(const size_t bit_num) const{
return bit_num % WORD_SIZE;
}
size_t byte_num(size_t bit_num) const
{
if (WORD_SIZE == 8)
{
return (bit_num >> 3);
}
if (WORD_SIZE == 16)
{
return (bit_num >> 4);
}
//Point to the actual data
char data[num_bytes];
public:
if (WORD_SIZE == 32)
{
return (bit_num >> 5);
}
class _UCXXEXPORT reference {
friend class bitset;
reference() : bit_num(0), parent(0) { }
size_t bit_num;
bitset * parent;
public:
~reference() { }
reference& operator=(bool x){ // for b[i] = x;
parent->set(bit_num, x);
return *this;
}
reference& operator=(const reference& x){ // for b[i] = b[j];
parent->set(bit_num, x);
return *this;
}
bool operator~() const{ // flips the bit
return !parent->test(bit_num);
}
operator bool() const{ // for x = b[i];
return parent->test(bit_num);
}
reference& flip(){ // for b[i].flip();
parent->flip(bit_num);
return *this;
}
};
if (WORD_SIZE == 64)
{
return (bit_num >> 6);
}
bitset(){
reset();
}
bitset(unsigned long val){
reset();
size_t count = sizeof(val) * CHAR_BIT;
if(count > N){
count = N;
}
for(size_t i = 0; i < count; ++i){
set(i, ((val >> i) & 1));
}
}
return bit_num / WORD_SIZE;
}
bitset(const bitset & val){
for(size_t i = 0; i < num_bytes; ++i){
data[i] = val.data[i];
}
}
// From the bit number, figure out which bit inside the byte we need
template<class charT, class traits, class Allocator> _UCXXEXPORT
explicit bitset(
const basic_string<charT,traits,Allocator>& str,
typename basic_string<charT,traits,Allocator>::size_type pos = 0,
typename basic_string<charT,traits,Allocator>::size_type n =
basic_string<charT>::npos
){
reset();
if(n > str.length()){
n = str.length();
}
size_t width = n;
if (width + pos > str.length()){
width = str.length() - pos;
}
size_t bit_num(const size_t bit_num) const
{
return bit_num % WORD_SIZE;
}
for(size_t i = 0; i < width; ++i){
switch(str[pos + width - i - 1]){
case '0':
break;
case '1':
set(i);
break;
default:
__throw_invalid_argument();
}
}
}
//Point to the actual data
bitset<N>& operator&=(const bitset<N>& rhs){
for(size_t i =0; i < num_bytes; ++i){
data[i] &= rhs.data[i];
}
return *this;
}
char data[num_bytes];
bitset<N>& operator|=(const bitset<N>& rhs){
for(size_t i =0; i < num_bytes; ++i){
data[i] |= rhs.data[i];
}
return *this;
}
bitset<N>& operator^=(const bitset<N>& rhs){
for(size_t i=0; i < num_bytes; ++i){
data[i] ^= rhs.data[i];
}
return *this;
}
public:
bitset<N>& operator<<=(size_t pos){
for(size_t i = N-1; i >=pos; --i){
set(i, test(i - pos));
}
for(size_t i = 0; i < pos; ++i){
reset(i);
}
return *this;
}
class _UCXXEXPORT reference
{
friend class bitset;
reference() : bit_num(0), parent(0) { }
size_t bit_num;
bitset * parent;
public:
~reference() { }
bitset<N>& operator>>=(size_t pos){
for(size_t i = 0; i < (N - pos); ++i){
set(i, test(i + pos));
}
for(size_t i = pos; i > 0; --i){
reset(N - i);
}
return *this;
}
reference& operator=(bool x)
{
// for b[i] = x;
bitset<N>& set(){
size_t i;
for(i = 0; i < N ; ++i){
data[byte_num(i)] |= (1<<bit_num(i));
}
return *this;
}
bitset<N>& set(size_t pos, int val = true){
if(val == true){
data[byte_num(pos)] |= (1<<bit_num(pos));
}else{
data[byte_num(pos)] &= ~(1<<bit_num(pos));
}
return *this;
}
bitset<N>& reset(){
for(size_t i = 0; i < num_bytes; ++i){
data[i] = 0;
}
return *this;
}
bitset<N>& reset(size_t pos){
data[byte_num(pos)] &= ~(1<<bit_num(pos));
return *this;
}
bitset<N> operator~() const{
bitset<N> retval(*this);
retval.flip();
return retval;
}
parent->set(bit_num, x);
return *this;
}
bitset<N>& flip(){
for(size_t i = 0; i < num_bytes; ++i){
data[i] = ~data[i];
}
return *this;
}
bitset<N>& flip(size_t pos){
char temp = data[byte_num(pos)] & (1 << bit_num(pos));
if(temp == 0){ //Bit was 0
data[byte_num(pos)] |= (1 << bit_num(pos));
}else{ //Bit was 1
data[byte_num(pos)] &= ~(1<<bit_num(pos));
}
return *this;
}
reference& operator=(const reference& x)
{
// for b[i] = b[j];
reference operator[](size_t pos){ // for b[i];
reference retval;
retval.parent = this;
retval.bit_num = pos;
return retval;
}
parent->set(bit_num, x);
return *this;
}
unsigned long to_ulong() const{
if(N > sizeof(unsigned long) * CHAR_BIT){
__throw_overflow_error();
}
unsigned long retval = 0;
size_t count = N;
for(size_t i = count; i > 0; --i){
if(test(i)){
retval +=1;
}
retval<<=1;
}
if(test(0)){
retval +=1;
}
return retval;
}
bool operator~() const
{
// flips the bit
template <class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator> to_string() const
{
basic_string<charT, traits, Allocator> retval;
retval.reserve(N);
for(size_t i = N ; i > 0; --i){
if(test(i-1) == true){
retval.append("1");
}else{
retval.append("0");
}
}
return retval;
}
return !parent->test(bit_num);
}
operator bool() const
{
// for x = b[i];
size_t count() const{
size_t retval = 0;
for(size_t i =0; i < N; ++i){
if(test(i)){
++retval;
}
}
return retval;
}
size_t size() const{
return N;
}
return parent->test(bit_num);
}
bitset<N>& operator=(const bitset<N> & rhs){
if(&rhs == this){
return *this;
}
for(size_t i = 0; i <= byte_num(N); ++i){
data[i] = rhs.data[i];
}
return *this;
}
reference& flip()
{
// for b[i].flip();
parent->flip(bit_num);
return *this;
}
};
bool operator==(const bitset<N>& rhs) const{
for(size_t i =0; i< N; ++i){
if(test(i) != rhs.test(i)){
return false;
}
}
return true;
}
bitset()
{
reset();
}
bool operator!=(const bitset<N>& rhs) const{
for(size_t i =0; i< N; ++i){
if(test(i) != rhs.test(i)){
return true;
}
}
return false;
}
bitset(unsigned long val)
{
reset();
size_t count = sizeof(val) * CHAR_BIT;
if (count > N)
{
count = N;
}
bool test(size_t pos) const{
return (data[byte_num(pos)] & (1<<bit_num(pos)) ) != 0;
}
for (size_t i = 0; i < count; ++i)
{
set(i, ((val >> i) & 1));
}
}
bool any() const{
for(size_t i = 0; i< N; ++i){
if(test(i)==true){
return true;
}
}
return false;
}
bitset(const bitset & val)
{
for (size_t i = 0; i < num_bytes; ++i)
{
data[i] = val.data[i];
}
}
bool none() const{
if(any() == true){
return false;
}
return true;
}
template<class charT, class traits, class Allocator> _UCXXEXPORT
explicit bitset
(
const basic_string<charT,traits,Allocator>& str,
typename basic_string<charT,traits,Allocator>::size_type pos = 0,
typename basic_string<charT,traits,Allocator>::size_type n =
basic_string<charT>::npos
)
{
reset();
if (n > str.length())
{
n = str.length();
}
bitset<N> operator<<(size_t pos) const{
bitset retval(*this);
retval<<=pos;
return retval;
}
bitset<N> operator>>(size_t pos) const{
bitset retval(*this);
retval>>=pos;
return retval;
}
};
size_t width = n;
if (width + pos > str.length())
{
width = str.length() - pos;
}
//Non-member functions
for (size_t i = 0; i < width; ++i)
{
switch (str[pos + width - i - 1])
{
case '0':
break;
case '1':
set(i);
break;
default:
__throw_invalid_argument();
}
}
}
bitset<N>& operator&=(const bitset<N>& rhs)
{
for (size_t i =0; i < num_bytes; ++i)
{
data[i] &= rhs.data[i];
}
template <size_t N> _UCXXEXPORT bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs){
bitset<N> retval(lhs);
retval &= rhs;
return retval;
}
return *this;
}
template <size_t N> _UCXXEXPORT bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs){
bitset<N> retval(lhs);
retval |= rhs;
return retval;
}
bitset<N>& operator|=(const bitset<N>& rhs)
{
for (size_t i =0; i < num_bytes; ++i)
{
data[i] |= rhs.data[i];
}
template <size_t N> _UCXXEXPORT bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs){
bitset<N> retval(lhs);
retval ^= rhs;
return retval;
}
return *this;
}
template <class charT, class traits, size_t N> _UCXXEXPORT basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, bitset<N>& x)
{
string s;
charT c;
for(size_t i = 0; i < N; ++i){
is.get(c);
if(!is.good()){
break;
}
if(c != '1' && c !='0'){
is.putback(c);
break;
}
s+=c;
}
bitset<N> temp(s);
x = temp;
return is;
}
bitset<N>& operator^=(const bitset<N>& rhs)
{
for (size_t i=0; i < num_bytes; ++i)
{
data[i] ^= rhs.data[i];
}
template <class charT, class traits, size_t N> _UCXXEXPORT basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x)
{
for(size_t i = N ; i > 0; --i){
if(x.test(i-1) == true){
os << "1";
}else{
os << "0";
}
}
return os;
}
return *this;
}
bitset<N>& operator<<=(size_t pos)
{
for (size_t i = N-1; i >=pos; --i)
{
set(i, test(i - pos));
}
for (size_t i = 0; i < pos; ++i)
{
reset(i);
}
return *this;
}
}
bitset<N>& operator>>=(size_t pos)
{
for (size_t i = 0; i < (N - pos); ++i)
{
set(i, test(i + pos));
}
for (size_t i = pos; i > 0; --i)
{
reset(N - i);
}
return *this;
}
bitset<N>& set()
{
size_t i;
for (i = 0; i < N ; ++i)
{
data[byte_num(i)] |= (1<<bit_num(i));
}
return *this;
}
bitset<N>& set(size_t pos, int val = true)
{
if (val == true)
{
data[byte_num(pos)] |= (1<<bit_num(pos));
}
else
{
data[byte_num(pos)] &= ~(1<<bit_num(pos));
}
return *this;
}
bitset<N>& reset()
{
for (size_t i = 0; i < num_bytes; ++i)
{
data[i] = 0;
}
return *this;
}
bitset<N>& reset(size_t pos)
{
data[byte_num(pos)] &= ~(1<<bit_num(pos));
return *this;
}
bitset<N> operator~() const
{
bitset<N> retval(*this);
retval.flip();
return retval;
}
bitset<N>& flip()
{
for (size_t i = 0; i < num_bytes; ++i)
{
data[i] = ~data[i];
}
return *this;
}
bitset<N>& flip(size_t pos)
{
char temp = data[byte_num(pos)] & (1 << bit_num(pos));
if (temp == 0)
{
// Bit was 0
data[byte_num(pos)] |= (1 << bit_num(pos));
}
else
{
// Bit was 1
data[byte_num(pos)] &= ~(1<<bit_num(pos));
}
return *this;
}
reference operator[](size_t pos)
{
// for b[i];
reference retval;
retval.parent = this;
retval.bit_num = pos;
return retval;
}
unsigned long to_ulong() const
{
if (N > sizeof(unsigned long) * CHAR_BIT)
{
__throw_overflow_error();
}
unsigned long retval = 0;
size_t count = N;
for (size_t i = count; i > 0; --i)
{
if (test(i))
{
retval +=1;
}
retval <<= 1;
}
if (test(0))
{
retval +=1;
}
return retval;
}
template <class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator> to_string() const
{
basic_string<charT, traits, Allocator> retval;
retval.reserve(N);
for (size_t i = N ; i > 0; --i)
{
if (test(i-1) == true)
{
retval.append("1");
}
else
{
retval.append("0");
}
}
return retval;
}
size_t count() const
{
size_t retval = 0;
for (size_t i =0; i < N; ++i)
{
if (test(i))
{
++retval;
}
}
return retval;
}
size_t size() const
{
return N;
}
bitset<N>& operator=(const bitset<N> & rhs)
{
if (&rhs == this)
{
return *this;
}
for (size_t i = 0; i <= byte_num(N); ++i)
{
data[i] = rhs.data[i];
}
return *this;
}
bool operator==(const bitset<N>& rhs) const
{
for (size_t i =0; i< N; ++i)
{
if (test(i) != rhs.test(i))
{
return false;
}
}
return true;
}
bool operator!=(const bitset<N>& rhs) const
{
for (size_t i =0; i< N; ++i)
{
if (test(i) != rhs.test(i))
{
return true;
}
}
return false;
}
bool test(size_t pos) const
{
return (data[byte_num(pos)] & (1<<bit_num(pos)) ) != 0;
}
bool any() const
{
for (size_t i = 0; i< N; ++i)
{
if (test(i)==true)
{
return true;
}
}
return false;
}
bool none() const
{
if (any() == true)
{
return false;
}
return true;
}
bitset<N> operator<<(size_t pos) const
{
bitset retval(*this);
retval<<=pos;
return retval;
}
bitset<N> operator>>(size_t pos) const
{
bitset retval(*this);
retval>>=pos;
return retval;
}
};
// Non-member functions
template <size_t N> _UCXXEXPORT bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs)
{
bitset<N> retval(lhs);
retval &= rhs;
return retval;
}
template <size_t N> _UCXXEXPORT bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs)
{
bitset<N> retval(lhs);
retval |= rhs;
return retval;
}
template <size_t N> _UCXXEXPORT bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs)
{
bitset<N> retval(lhs);
retval ^= rhs;
return retval;
}
template <class charT, class traits, size_t N> _UCXXEXPORT basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, bitset<N>& x)
{
string s;
charT c;
for (size_t i = 0; i < N; ++i)
{
is.get(c);
if (!is.good())
{
break;
}
if (c != '1' && c !='0')
{
is.putback(c);
break;
}
s += c;
}
bitset<N> temp(s);
x = temp;
return is;
}
template <class charT, class traits, size_t N> _UCXXEXPORT basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x)
{
for (size_t i = N ; i > 0; --i)
{
if (x.test(i-1) == true)
{
os << "1";
}
else
{
os << "0";
}
}
return os;
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
#endif
+188 -135
View File
@@ -32,8 +32,7 @@
// POSSIBILITY OF SUCH DAMAGE.
//
//***************************************************************************
//#ifndef __INCLUDE_CXX_CHAR1_TRAITS
//#define __INCLUDE_CXX_CHAR1_TRAITS
#include <basic_definitions>
#include <string.h>
#include <exception>
@@ -47,169 +46,223 @@
#ifndef __HEADER_CHAR_TRAITS
#define __HEADER_CHAR_TRAITS 1
namespace std{
/* Inlining all wrapped function calls to shrink the amount of code generated*/
//Typedefs to use for stuff
typedef signed int char_traits_off_type;
extern "C++"
{
//Generic char_traits
template<class charT> struct _UCXXEXPORT char_traits { };
namespace std
{
/* Inlining all wrapped function calls to shrink the amount of code generated */
// Typedefs to use for stuff
//Specialize for char
template<> struct _UCXXEXPORT char_traits<char> {
typedef char char_type;
typedef short int int_type;
typedef char_traits_off_type off_type;
typedef char_traits_off_type pos_type;
typedef char state_type;
inline static void assign(char_type & c, const char_type & d) { c = d; }
typedef signed int char_traits_off_type;
static bool eq(const char_type& c1, const char_type& c2);
// Generic char_traits
static char_type to_char_type(const int_type & i);
template<class charT> struct _UCXXEXPORT char_traits { };
inline static int_type to_int_type(const char_type & c){
return (short int)(unsigned char)c;
}
// Specialize for char
inline static bool eq_int_type(const int_type & a, const int_type & b){
if(a==b){
return true;
}
return false;
}
template<> struct _UCXXEXPORT char_traits<char>
{
typedef char char_type;
typedef short int int_type;
typedef char_traits_off_type off_type;
typedef char_traits_off_type pos_type;
typedef char state_type;
inline static void assign(char_type & c, const char_type & d) { c = d; }
static bool eq(const char_type& c1, const char_type& c2);
inline static bool lt(const char_type& c1, const char_type& c2){
if(strncmp(&c1, &c2, 1) < 0){
return true;
}
return false;
}
static char_type to_char_type(const int_type & i);
inline static char_type* move(char_type* s1, const char_type* s2, size_t n){
return (char*) memmove(s1, s2, n);
}
inline static int_type to_int_type(const char_type & c)
{
return (short int)(unsigned char)c;
}
inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){
for(unsigned long int i=0; i< n; ++i){
assign(s1[i], s2[i]);
}
return s1 + n;
}
inline static bool eq_int_type(const int_type & a, const int_type & b)
{
if (a==b)
{
return true;
}
inline static char_type* assign(char_type* s, size_t n, char_type a){
return (char *)memset(s, a, n);
}
return false;
}
inline static int compare(const char_type* s1, const char_type* s2, size_t n){
return strncmp(s1, s2, n);
}
inline static bool lt(const char_type& c1, const char_type& c2)
{
if (strncmp(&c1, &c2, 1) < 0)
{
return true;
}
inline static size_t length(const char_type* s){
return strlen(s);
}
return false;
}
static const char_type* find(const char_type* s, int n, const char_type& a);
inline static char_type* move(char_type* s1, const char_type* s2, size_t n)
{
return (char*) memmove(s1, s2, n);
}
inline static char_type eos() { return 0; }
inline static int_type eof() { return -1; }
inline static int_type not_eof(const int_type & i) {
if(i == -1){
return 0;
} else {
return i;
}
}
static state_type get_state(pos_type p){
p = p;
state_type a;
return a;
}
};
inline static char_type* copy(char_type* s1, const char_type* s2, size_t n)
{
for (unsigned long int i=0; i< n; ++i)
{
assign(s1[i], s2[i]);
}
return s1 + n;
}
inline static char_type* assign(char_type* s, size_t n, char_type a)
{
return (char *)memset(s, a, n);
}
inline static int compare(const char_type* s1, const char_type* s2, size_t n)
{
return strncmp(s1, s2, n);
}
inline static size_t length(const char_type* s)
{
return strlen(s);
}
static const char_type* find(const char_type* s, int n, const char_type& a);
inline static char_type eos() { return 0; }
inline static int_type eof() { return -1; }
inline static int_type not_eof(const int_type & i)
{
if (i == -1)
{
return 0;
}
else
{
return i;
}
}
static state_type get_state(pos_type p)
{
p = p;
state_type a;
return a;
}
};
#ifdef __UCLIBCXX_HAS_WCHAR__
template<> struct _UCXXEXPORT char_traits<wchar_t> {
typedef wchar_t char_type;
typedef wint_t int_type;
typedef char_traits_off_type off_type;
typedef char_traits_off_type pos_type;
typedef mbstate_t state_type;
template<> struct _UCXXEXPORT char_traits<wchar_t>
{
typedef wchar_t char_type;
typedef wint_t int_type;
typedef char_traits_off_type off_type;
typedef char_traits_off_type pos_type;
typedef mbstate_t state_type;
static void assign(char_type & c, const char_type & d){ c=d; }
static void assign(char_type & c, const char_type & d){ c=d; }
static char_type to_char_type(const int_type & i){
return i;
}
static char_type to_char_type(const int_type & i)
{
return i;
}
static int_type to_int_type(const char_type & c){
return c;
}
static int_type to_int_type(const char_type & c)
{
return c;
}
inline static bool eq_int_type(const int_type & a, const int_type & b){
if(a==b){
return true;
}
return false;
}
inline static bool eq_int_type(const int_type & a, const int_type & b)
{
if (a == b)
{
return true;
}
inline static bool eq(const char_type& c1, const char_type& c2){
if(wcsncmp(&c1, &c2, 1) == 0){
return true;
}
return false;
}
return false;
}
inline static bool lt(const char_type& c1, const char_type& c2){
if(wcsncmp(&c1, &c2, 1) < 0){
return true;
}
return false;
}
inline static bool eq(const char_type& c1, const char_type& c2)
{
if (wcsncmp(&c1, &c2, 1) == 0)
{
return true;
}
inline static char_type* move(char_type* s1, const char_type* s2, size_t n){
return (char_type*) memmove(s1, s2, n * sizeof(char_type));
}
return false;
}
inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){
for(unsigned long int i=0; i< n; ++i){
assign(s1[i], s2[i]);
}
return s1 + n;
}
inline static bool lt(const char_type& c1, const char_type& c2)
{
if(wcsncmp(&c1, &c2, 1) < 0)
{
return true;
}
inline static char_type* assign(char_type* s, size_t n, char_type a){
return (char_type *)memset(s, a, n); /*FIXME*/
}
return false;
}
inline static int compare(const char_type* s1, const char_type* s2, size_t n){
return wcsncmp(s1, s2, n);
}
inline static char_type* move(char_type* s1, const char_type* s2, size_t n)
{
return (char_type*) memmove(s1, s2, n * sizeof(char_type));
}
inline static size_t length(const char_type* s){
return wcslen(s);
}
inline static char_type* copy(char_type* s1, const char_type* s2, size_t n)
{
for (unsigned long int i = 0; i< n; ++i)
{
assign(s1[i], s2[i]);
}
static const char_type* find(const char_type* s, int n, const char_type& a);
return s1 + n;
}
inline static char_type eos() { return 0; }
inline static int_type eof() { return WEOF; }
inline static int_type not_eof(const int_type & i) {
if(i == WEOF){
return (int_type)0;
} else {
return i;
}
}
static state_type get_state(pos_type){
state_type a;
return a;
}
};
#endif
inline static char_type* assign(char_type* s, size_t n, char_type a)
{
return (char_type *)memset(s, a, n); /*FIXME*/
}
}
inline static int compare(const char_type* s1, const char_type* s2, size_t n)
{
return wcsncmp(s1, s2, n);
}
#endif
inline static size_t length(const char_type* s)
{
return wcslen(s);
}
static const char_type* find(const char_type* s, int n, const char_type& a);
inline static char_type eos() { return 0; }
inline static int_type eof() { return WEOF; }
inline static int_type not_eof(const int_type & i)
{
if (i == WEOF)
{
return (int_type)0;
}
else
{
return i;
}
}
static state_type get_state(pos_type)
{
state_type a;
return a;
}
};
#endif // __UCLIBCXX_HAS_WCHAR__
} // namespace
} // extern "C++"
#endif // __HEADER_CHAR_TRAITS
+392 -286
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <istream>
#include <ostream>
@@ -23,305 +23,411 @@
#ifndef __STD_HEADER_COMPLEX
#define __STD_HEADER_COMPLEX 1
extern "C++"
{
namespace std
{
// class complex<float>;
// class complex<double>;
// class complex<long double>;
namespace std {
// class complex<float>;
// class complex<double>;
// class complex<long double>;
template<class T> class _UCXXEXPORT complex{
public:
typedef T value_type;
template<class T> class _UCXXEXPORT complex{
public:
typedef T value_type;
complex(const T& re = T(), const T& im = T()) : r(re), i(im) { }
complex(const complex& c): r(c.r), i(c.i){ }
template<class X> complex(const complex<X>& c): r(c.r), i(c.i){ }
complex(const T& re = T(), const T& im = T()) : r(re), i(im) { }
complex(const complex& c): r(c.r), i(c.i){ }
template<class X> complex(const complex<X>& c): r(c.r), i(c.i){ }
inline T real() const
{
return r;
}
inline T real() const{
return r;
}
inline T imag() const{
return i;
}
inline T imag() const
{
return i;
}
complex<T>& operator= (const T& v){
r = v;
i = 0;
return *this;
}
complex<T>& operator+=(const T& v){
r +=v;
return *this;
}
complex<T>& operator-=(const T& v){
r -=v;
return *this;
}
complex<T>& operator*=(const T& v){
r*=v;
i*=v;
return *this;
}
complex<T>& operator/=(const T& v){
r/=v;
i/=v;
return *this;
}
complex& operator=(const complex& v){
if(&v != this){
r = v.r;
i = v.i;
}
return *this;
}
template<class X> complex<T>& operator= (const complex<X>& v){
r = v.r;
i = v.i;
return *this;
}
template<class X> complex<T>& operator+=(const complex<X>& v){
r+=v.r;
i+=v.i;
return *this;
}
template<class X> complex<T>& operator-=(const complex<X>& v){
r-=v.r;
i-=v.i;
return *this;
}
template<class X> complex<T>& operator*=(const complex<X>& v){
T tempr = r*v.r - i*v.i;
T tempi = r*v.i + i*v.r;
r = tempr;
i = tempi;
return *this;
}
template<class X> complex<T>& operator/=(const complex<X>& v){
T tempr = (r*v.r + i*v.i) / (v.r*v.r + v.i*v.i);
T tempi = (i*v.r - r*v.i) / (v.r*v.r + v.i*v.i);
r = tempr;
i = tempi;
return *this;
}
private:
T r;
T i;
};
complex<T>& operator= (const T& v)
{
r = v;
i = 0;
return *this;
}
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& ls, const complex<T>& rs){
complex<T> retval(ls);
retval += rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& ls, const T& rs){
complex<T> retval(ls);
ls += rs;
return retval;
}
template<class T> _UCXXEXPORT inline complex<T> operator+(const T& ls, const complex<T>& rs){
return rs + ls;
}
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& ls, const complex<T>& rs){
complex<T> retval(ls);
retval -= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& ls, const T& rs){
complex<T> retval(ls);
retval -= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator-(const T& ls, const complex<T>& rs){
complex<T> retval(ls);
retval -= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator*(const complex<T>& ls, const complex<T>& rs){
complex<T> retval(ls);
retval *= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator*(const complex<T>& ls, const T& rs){
complex<T> retval(ls);
retval *= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator*(const T& ls, const complex<T>& rs){
complex<T> retval(ls);
retval *=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator/(const complex<T>& ls, const complex<T>& rs){
complex<T> retval(ls);
retval/=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator/(const complex<T>& ls, const T& rs){
complex<T> retval(ls);
retval/=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator/(const T& ls, const complex<T>& rs){
complex<T> retval(ls);
retval/=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& v){
return v;
}
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& v){
return complex<T> (-v.real(), -v.imag());
}
template<class T> _UCXXEXPORT bool operator==(const complex<T>& ls, const complex<T>& rs){
if( ls.real() == rs.real() && ls.imag() == rs.image()){
return true;
}
return false;
}
template<class T> _UCXXEXPORT bool operator==(const complex<T>& ls, const T& rs){
if(ls.real() == rs && ls.imag() == T()){
return true;
}
return false;
}
template<class T> _UCXXEXPORT bool operator==(const T& ls, const complex<T>& rs){
if(ls == rs.real() && rs.imag() == T()){
return true;
}
return false;
}
template<class T> _UCXXEXPORT bool operator!=(const complex<T>& ls, const complex<T>& rs){
if(ls == rs){
return false;
}
return true;
}
template<class T> _UCXXEXPORT bool operator!=(const complex<T>& ls, const T& rs){
if(ls == rs){
return false;
}
return true;
}
template<class T> _UCXXEXPORT bool operator!=(const T& ls, const complex<T>& rs){
if(ls == rs){
return false;
}
return true;
}
template<class T, class charT, class traits> _UCXXEXPORT basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, complex<T>& v)
{
T tempr;
T tempi;
is >> tempr;
is.get();
is >> tempi;
v = complex<T>(tempr, tempi);
return is;
}
complex<T>& operator+=(const T& v)
{
r +=v;
return *this;
}
template<class T, class charT, class traits> _UCXXEXPORT basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const complex<T>&v)
{
os << v.real() << ", " << v.imag();
return os;
}
complex<T>& operator-=(const T& v)
{
r -=v;
return *this;
}
template<class T> _UCXXEXPORT T real(const complex<T>& v){
return v.real();
}
complex<T>& operator*=(const T& v)
{
r*=v;
i*=v;
return *this;
}
template<class T> _UCXXEXPORT T imag(const complex<T>& v){
return v.imag();
}
complex<T>& operator/=(const T& v)
{
r/=v;
i/=v;
return *this;
}
template<class T> _UCXXEXPORT T norm(const complex<T>& v){
return (v.real() * v.real() + v.imag() * v.imag());
}
complex& operator=(const complex& v)
{
if (&v != this){
r = v.r;
i = v.i;
}
return *this;
}
template<class T> _UCXXEXPORT complex<T> conj(const complex<T>& v){
return complex<T>(v.real(), -v.imag());
}
template<class X> complex<T>& operator= (const complex<X>& v)
{
r = v.r;
i = v.i;
return *this;
}
#ifdef __UCLIBCXX_SUPPORT_MATH__ //Can we link with libm?
template<class X> complex<T>& operator+=(const complex<X>& v)
{
r+=v.r;
i+=v.i;
return *this;
}
template<class T> _UCXXEXPORT T abs(const complex<T>& v){
return sqrt(v.real() * v.real() + v.imag() * v.imag());
}
template<class X> complex<T>& operator-=(const complex<X>& v)
{
r-=v.r;
i-=v.i;
return *this;
}
template<class T> _UCXXEXPORT T arg(const complex<T>& v){
return atan2(v.imag(), v.real());
}
template<class X> complex<T>& operator*=(const complex<X>& v)
{
T tempr = r*v.r - i*v.i;
T tempi = r*v.i + i*v.r;
r = tempr;
i = tempi;
return *this;
}
template<class T> _UCXXEXPORT complex<T> polar(const T& rho, const T& theta){
return complex<T>(rho * cos(theta), rho * sin(theta));
}
template<class X> complex<T>& operator/=(const complex<X>& v)
{
T tempr = (r*v.r + i*v.i) / (v.r*v.r + v.i*v.i);
T tempi = (i*v.r - r*v.i) / (v.r*v.r + v.i*v.i);
r = tempr;
i = tempi;
return *this;
}
template<class T> _UCXXEXPORT complex<T> cos (const complex<T>& v){
return complex<T>(cos(v.real()) * cosh(v.imag()), -sin(v.real()) * sinh(v.imag()));
}
private:
T r;
T i;
};
template<class T> _UCXXEXPORT complex<T> cosh (const complex<T>& v){
return complex<T>(cosh(v.real()) * cos(v.imag()), sinh(v.real()) * sin(v.imag()));
}
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval += rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> exp (const complex<T>& v){
return polar(exp(v.real()), v.imag());
}
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& ls, const T& rs)
{
complex<T> retval(ls);
ls += rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> log (const complex<T>& v){
return complex<T>(log(abs(v)), arg(v));
}
template<class T> _UCXXEXPORT inline complex<T> operator+(const T& ls, const complex<T>& rs)
{
return rs + ls;
}
template<class T> _UCXXEXPORT complex<T> log10(const complex<T>& v){
return (log(v) / log(T(10.0)));
}
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval -= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, int p){
T rho = pow(abs(v), p);
T theta = arg(v);
return complex<T>(rho * cos(p * theta), rho * sin(p * theta) );
}
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& ls, const T& rs)
{
complex<T> retval(ls);
retval -= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, const T& p){
return polar( pow(abs(v),p), arg(v)*p );
}
template<class T> _UCXXEXPORT complex<T> operator-(const T& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval -= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, const complex<T>& p){
if(v == T()){
//We are using "0" as the value
return T();
}
return exp(p * log(v));
}
template<class T> _UCXXEXPORT complex<T> operator*(const complex<T>& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval *= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> pow(const T& v, const complex<T>& p){
if(v == T()){
return T();
}
return polar(pow(v,p.real()), y.imag() * log(x) );
}
template<class T> _UCXXEXPORT complex<T> operator*(const complex<T>& ls, const T& rs)
{
complex<T> retval(ls);
retval *= rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> sin (const complex<T>& v){
return complex<T>(sin(v.real()) * cosh(v.imag()), cosh(v.real()) * sin(v.imag()));
}
template<class T> _UCXXEXPORT complex<T> operator*(const T& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval *=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> sinh (const complex<T>& v){
return complext<T>(sinh(v.real()) * cos(v.imag()), cosh(v.real()) * sin(v.imag()) );
}
template<class T> _UCXXEXPORT complex<T> operator/(const complex<T>& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval/=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> sqrt (const complex<T>&);
template<class T> _UCXXEXPORT complex<T> tan (const complex<T>& v){
return sin(v) / cos(v);
}
template<class T> _UCXXEXPORT complex<T> operator/(const complex<T>& ls, const T& rs)
{
complex<T> retval(ls);
retval/=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> tanh (const complex<T>& v){
return sinh(v) / cosh(v);
}
template<class T> _UCXXEXPORT complex<T> operator/(const T& ls, const complex<T>& rs)
{
complex<T> retval(ls);
retval/=rs;
return retval;
}
template<class T> _UCXXEXPORT complex<T> operator+(const complex<T>& v)
{
return v;
}
template<class T> _UCXXEXPORT complex<T> operator-(const complex<T>& v)
{
return complex<T> (-v.real(), -v.imag());
}
template<class T> _UCXXEXPORT bool operator==(const complex<T>& ls, const complex<T>& rs)
{
if (ls.real() == rs.real() && ls.imag() == rs.image())
{
return true;
}
return false;
}
template<class T> _UCXXEXPORT bool operator==(const complex<T>& ls, const T& rs)
{
if (ls.real() == rs && ls.imag() == T())
{
return true;
}
return false;
}
template<class T> _UCXXEXPORT bool operator==(const T& ls, const complex<T>& rs)
{
if (ls == rs.real() && rs.imag() == T())
{
return true;
}
return false;
}
template<class T> _UCXXEXPORT bool operator!=(const complex<T>& ls, const complex<T>& rs)
{
if (ls == rs)
{
return false;
}
return true;
}
template<class T> _UCXXEXPORT bool operator!=(const complex<T>& ls, const T& rs)
{
if (ls == rs)
{
return false;
}
return true;
}
template<class T> _UCXXEXPORT bool operator!=(const T& ls, const complex<T>& rs)
{
if (ls == rs)
{
return false;
}
return true;
}
template<class T, class charT, class traits> _UCXXEXPORT basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, complex<T>& v)
{
T tempr;
T tempi;
is >> tempr;
is.get();
is >> tempi;
v = complex<T>(tempr, tempi);
return is;
}
template<class T, class charT, class traits> _UCXXEXPORT basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const complex<T>&v)
{
os << v.real() << ", " << v.imag();
return os;
}
template<class T> _UCXXEXPORT T real(const complex<T>& v)
{
return v.real();
}
template<class T> _UCXXEXPORT T imag(const complex<T>& v)
{
return v.imag();
}
template<class T> _UCXXEXPORT T norm(const complex<T>& v)
{
return (v.real() * v.real() + v.imag() * v.imag());
}
template<class T> _UCXXEXPORT complex<T> conj(const complex<T>& v)
{
return complex<T>(v.real(), -v.imag());
}
#ifdef __UCLIBCXX_SUPPORT_MATH__ //Can we link with libm?
template<class T> _UCXXEXPORT T abs(const complex<T>& v)
{
return sqrt(v.real() * v.real() + v.imag() * v.imag());
}
template<class T> _UCXXEXPORT T arg(const complex<T>& v)
{
return atan2(v.imag(), v.real());
}
template<class T> _UCXXEXPORT complex<T> polar(const T& rho, const T& theta)
{
return complex<T>(rho * cos(theta), rho * sin(theta));
}
template<class T> _UCXXEXPORT complex<T> cos (const complex<T>& v)
{
return complex<T>(cos(v.real()) * cosh(v.imag()), -sin(v.real()) * sinh(v.imag()));
}
template<class T> _UCXXEXPORT complex<T> cosh (const complex<T>& v)
{
return complex<T>(cosh(v.real()) * cos(v.imag()), sinh(v.real()) * sin(v.imag()));
}
template<class T> _UCXXEXPORT complex<T> exp (const complex<T>& v)
{
return polar(exp(v.real()), v.imag());
}
template<class T> _UCXXEXPORT complex<T> log (const complex<T>& v)
{
return complex<T>(log(abs(v)), arg(v));
}
template<class T> _UCXXEXPORT complex<T> log10(const complex<T>& v)
{
return (log(v) / log(T(10.0)));
}
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, int p)
{
T rho = pow(abs(v), p);
T theta = arg(v);
return complex<T>(rho * cos(p * theta), rho * sin(p * theta));
}
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, const T& p)
{
return polar(pow(abs(v),p), arg(v)*p);
}
template<class T> _UCXXEXPORT complex<T> pow(const complex<T>& v, const complex<T>& p)
{
if (v == T())
{
// We are using "0" as the value
return T();
}
return exp(p * log(v));
}
template<class T> _UCXXEXPORT complex<T> pow(const T& v, const complex<T>& p)
{
if (v == T())
{
return T();
}
return polar(pow(v,p.real()), y.imag() * log(x));
}
template<class T> _UCXXEXPORT complex<T> sin (const complex<T>& v)
{
return complex<T>(sin(v.real()) * cosh(v.imag()), cosh(v.real()) * sin(v.imag()));
}
template<class T> _UCXXEXPORT complex<T> sinh (const complex<T>& v)
{
return complext<T>(sinh(v.real()) * cos(v.imag()), cosh(v.real()) * sin(v.imag()));
}
template<class T> _UCXXEXPORT complex<T> sqrt (const complex<T>&);
template<class T> _UCXXEXPORT complex<T> tan (const complex<T>& v)
{
return sin(v) / cos(v);
}
template<class T> _UCXXEXPORT complex<T> tanh (const complex<T>& v)
{
return sinh(v) / cosh(v);
}
#endif
}
} // namespace
} // extern "C++"
#endif
+20 -16
View File
@@ -1,20 +1,20 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*
* This file is part of the uClibc++ Library.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <memory>
#include <iterator>
@@ -25,6 +25,8 @@
#ifndef __STD_HEADER_DEQUE
#define __STD_HEADER_DEQUE
extern "C++"
{
namespace std
{
template <class T, class Allocator = allocator<T> > class deque;
@@ -1057,7 +1059,9 @@ namespace std
template <class T, class Allocator> _UCXXEXPORT void swap(deque<T,Allocator>& x, deque<T,Allocator>& y){
x.swap(y);
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
File diff suppressed because it is too large Load Diff
+456 -404
View File
@@ -1,20 +1,20 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __STD_HEADER_FUNCTIONAL
#define __STD_HEADER_FUNCTIONAL 1
@@ -23,414 +23,466 @@
#pragma GCC visibility push(default)
namespace std{
template <class Arg, class Result> struct unary_function;
template <class Arg1, class Arg2, class Result> struct binary_function;
template <class T> struct plus;
template <class T> struct minus;
template <class T> struct multiplies;
template <class T> struct divides;
template <class T> struct modulus;
template <class T> struct negate;
template <class T> struct equal_to;
template <class T> struct not_equal_to;
template <class T> struct greater;
template <class T> struct less;
template <class T> struct greater_equal;
template <class T> struct less_equal;
template <class T> struct logical_and;
template <class T> struct logical_or;
template <class T> struct logical_not;
template <class Predicate> struct unary_negate;
template <class Predicate> unary_negate<Predicate> not1(const Predicate&);
template <class Predicate> struct binary_negate;
template <class Predicate> binary_negate<Predicate> not2(const Predicate&);
template <class Operation> class binder1st;
template <class Operation, class T> binder1st<Operation> bind1st(const Operation&, const T&);
template <class Operation> class binder2nd;
template <class Operation, class T> binder2nd<Operation> bind2nd(const Operation&, const T&);
template <class Arg, class Result> class pointer_to_unary_function;
template <class Arg, class Result> pointer_to_unary_function<Arg,Result> ptr_fun(Result (*)(Arg));
template <class Arg1, class Arg2, class Result> class pointer_to_binary_function;
template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*)(Arg1,Arg2));
template<class S, class T> class mem_fun_t;
template<class S, class T, class A> class mem_fun1_t;
template<class S, class T> class const_mem_fun_t;
template<class S, class T, class A> class const_mem_fun1_t;
template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
template<class S, class T> class mem_fun_ref_t;
template<class S, class T, class A> class mem_fun1_ref_t;
template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A));
//Implementation
template <class Arg, class Result> struct _UCXXEXPORT unary_function{
typedef Arg argument_type;
typedef Result result_type;
};
template <class Arg1, class Arg2, class Result> struct _UCXXEXPORT binary_function{
typedef Arg1 first_argument_type;
typedef Arg2 second_argument_type;
typedef Result result_type;
};
template <class T> struct _UCXXEXPORT plus : binary_function<T,T,T>{
T operator()(const T& x, const T& y) const{
return x + y;
}
};
template <class T> struct _UCXXEXPORT minus : binary_function<T,T,T>{
T operator()(const T& x, const T& y) const{
return x - y;
}
};
template <class T> struct _UCXXEXPORT multiplies : binary_function<T,T,T>{
T operator()(const T& x, const T& y) const{
return x * y;
}
};
template <class T> struct _UCXXEXPORT divides : binary_function<T,T,T>{
T operator()(const T& x, const T& y) const{
return x / y;
}
};
template <class T> struct _UCXXEXPORT modulus : binary_function<T,T,T>{
T operator()(const T& x, const T& y) const{
return x % y;
}
};
template <class T> struct _UCXXEXPORT negate : unary_function<T,T>{
T operator()(const T& x) const{
return -x;
}
};
template <class T> struct _UCXXEXPORT equal_to : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
return (x == y);
}
};
template <class T> struct _UCXXEXPORT not_equal_to : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
return (x != y);
}
};
template <class T> struct _UCXXEXPORT greater : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
return (x > y);
}
};
template <class T> struct _UCXXEXPORT less : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
return (x < y);
}
};
template <class T> struct _UCXXEXPORT greater_equal : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
return (x >= y);
}
};
template <class T> struct _UCXXEXPORT less_equal : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
return (x <= y);
}
};
template <class T> struct _UCXXEXPORT logical_and : binary_function<T,T,bool> {
bool operator()(const T& x, const T& y) const{
return (x && y);
}
};
template <class T> struct _UCXXEXPORT logical_or : binary_function<T,T,bool> {
bool operator()(const T& x, const T& y) const{
return (x || y);
}
};
template <class T> struct _UCXXEXPORT logical_not : unary_function<T,bool> {
bool operator()(const T& x) const{
return !x;
}
};
template <class Predicate> class _UCXXEXPORT unary_negate
: public unary_function<typename Predicate::argument_type,bool>
{
public:
explicit unary_negate(const Predicate& pred) : p(pred) { }
bool operator()(const typename Predicate::argument_type& x) const{
return !p(x);
}
private:
Predicate p;
};
template <class Predicate> _UCXXEXPORT unary_negate<Predicate> not1(const Predicate& pred){
return unary_negate<Predicate>(pred);
}
template <class Predicate> class _UCXXEXPORT binary_negate : public
binary_function<typename Predicate::first_argument_type,
typename Predicate::second_argument_type, bool>
{
public:
explicit binary_negate(const Predicate& pred) : p(pred) { }
bool operator()(const typename Predicate::first_argument_type& x,
const typename Predicate::second_argument_type& y) const
{
return !p(x, y);
}
private:
Predicate p;
};
template <class Predicate> _UCXXEXPORT binary_negate<Predicate> not2(const Predicate& pred){
return binary_negate<Predicate>(pred);
}
template <class Operation> class _UCXXEXPORT binder1st
: public unary_function<typename Operation::second_argument_type,
typename Operation::result_type>
{
protected:
Operation op;
typename Operation::first_argument_type value;
public:
binder1st(const Operation& x, const typename Operation::first_argument_type& y) : op(x), value(y){ }
typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const{
return op(value,x);
}
};
template <class Operation, class T> _UCXXEXPORT binder1st<Operation> bind1st(const Operation& op, const T& x){
return binder1st<Operation>(op, typename Operation::first_argument_type(x));
}
template <class Operation> class _UCXXEXPORT binder2nd
: public unary_function<typename Operation::first_argument_type,
typename Operation::result_type>
{
protected:
Operation op;
typename Operation::second_argument_type value;
public:
binder2nd(const Operation& x, const typename Operation::second_argument_type& y) : op(x), value(y) { }
typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const{
return op(x,value);
}
};
template <class Operation, class T> _UCXXEXPORT
binder2nd<Operation> bind2nd(const Operation& op, const T& x)
{
return binder2nd<Operation>(op, typename Operation::second_argument_type(x));
}
template <class Arg, class Result> class _UCXXEXPORT
pointer_to_unary_function : public unary_function<Arg, Result>
{
protected:
Result (*func)(Arg);
public:
explicit pointer_to_unary_function(Result (*f)(Arg)) : func(f) { }
Result operator()(Arg x) const{
return func(x);
}
};
template <class Arg, class Result> _UCXXEXPORT pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg)){
return pointer_to_unary_function<Arg, Result>(f);
}
template <class Arg1, class Arg2, class Result> class _UCXXEXPORT
pointer_to_binary_function : public binary_function<Arg1,Arg2,Result>
{
protected:
Result (*func)(Arg1, Arg2);
public:
explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : func(f) { }
Result operator()(Arg1 x, Arg2 y) const{
return func(x, y);
}
};
template <class Arg1, class Arg2, class Result> _UCXXEXPORT
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1, Arg2))
{
return pointer_to_binary_function<Arg1,Arg2,Result>(f);
}
template <class S, class T> class _UCXXEXPORT mem_fun_t
: public unary_function<T*, S>
{
public:
explicit mem_fun_t(S (T::*p)()) : m(p) { }
S operator()(T* p) const { return (p->*m)(); }
private:
S (T::*m)();
};
template <class S, class T, class A> class _UCXXEXPORT mem_fun1_t
: public binary_function<T*, A, S>
{
public:
explicit mem_fun1_t(S (T::*p)(A)) : m(p) { }
S operator()(T* p, A x) const { return (p->*m)(x); }
private:
S (T::*m)(A);
};
template <class S, class T> class _UCXXEXPORT const_mem_fun_t
: public unary_function<const T*, S>
{
public:
explicit const_mem_fun_t(S (T::*p)() const) : m(p) { }
S operator()(const T* p) const { return (p->*m)(); }
private:
S (T::*m)() const;
};
template <class S, class T, class A> class _UCXXEXPORT const_mem_fun1_t
: public binary_function<T*, A, S>
{
public:
explicit const_mem_fun1_t(S (T::*p)(A) const) : m(p) { }
S operator()(const T* p, A x) const { return (p->*m)(x); }
private:
S (T::*m)(A) const;
};
template<class S, class T> _UCXXEXPORT mem_fun_t<S,T> mem_fun(S (T::*f)()){
return mem_fun_t<S, T>(f);
}
template<class S, class T> _UCXXEXPORT const_mem_fun_t<S,T> mem_fun(S (T::*f)() const){
return const_mem_fun_t<S, T>(f);
}
template<class S, class T, class A> _UCXXEXPORT mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)){
return mem_fun1_t<S, T, A>(f);
}
template<class S, class T, class A> _UCXXEXPORT const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const){
return const_mem_fun1_t<S, T, A>(f);
}
template <class S, class T> class _UCXXEXPORT mem_fun_ref_t
: public unary_function<T, S>
{
public:
explicit mem_fun_ref_t(S (T::*p)()) : mf(p) { }
S operator()(T& p) { return (p.*mf)(); }
private:
S (T::*mf)();
};
template <class S, class T, class A> class _UCXXEXPORT mem_fun1_ref_t
: public binary_function<T, A, S>
{
public:
explicit mem_fun1_ref_t(S (T::*p)(A)) : mf(p) { }
S operator()(T& p, A x) { return (p.*mf)(x); }
private:
S (T::*mf)(A);
};
template<class S, class T> _UCXXEXPORT mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()){
return mem_fun_ref_t<S,T>(f);
}
template<class S, class T, class A> _UCXXEXPORT mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A)){
return mem_fun1_ref_t<S,T,A>(f);
}
}
//These are SGI extensions which are checked for by some conformance checks. They
extern "C++"
{
namespace std
{
template <class Arg, class Result> struct unary_function;
template <class Arg1, class Arg2, class Result> struct binary_function;
template <class T> struct plus;
template <class T> struct minus;
template <class T> struct multiplies;
template <class T> struct divides;
template <class T> struct modulus;
template <class T> struct negate;
template <class T> struct equal_to;
template <class T> struct not_equal_to;
template <class T> struct greater;
template <class T> struct less;
template <class T> struct greater_equal;
template <class T> struct less_equal;
template <class T> struct logical_and;
template <class T> struct logical_or;
template <class T> struct logical_not;
template <class Predicate> struct unary_negate;
template <class Predicate> unary_negate<Predicate> not1(const Predicate&);
template <class Predicate> struct binary_negate;
template <class Predicate> binary_negate<Predicate> not2(const Predicate&);
template <class Operation> class binder1st;
template <class Operation, class T> binder1st<Operation> bind1st(const Operation&, const T&);
template <class Operation> class binder2nd;
template <class Operation, class T> binder2nd<Operation> bind2nd(const Operation&, const T&);
template <class Arg, class Result> class pointer_to_unary_function;
template <class Arg, class Result> pointer_to_unary_function<Arg,Result> ptr_fun(Result (*)(Arg));
template <class Arg1, class Arg2, class Result> class pointer_to_binary_function;
template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*)(Arg1,Arg2));
template<class S, class T> class mem_fun_t;
template<class S, class T, class A> class mem_fun1_t;
template<class S, class T> class const_mem_fun_t;
template<class S, class T, class A> class const_mem_fun1_t;
template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
template<class S, class T> class mem_fun_ref_t;
template<class S, class T, class A> class mem_fun1_ref_t;
template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A));
// Implementation
template <class Arg, class Result> struct _UCXXEXPORT unary_function
{
typedef Arg argument_type;
typedef Result result_type;
};
template <class Arg1, class Arg2, class Result> struct _UCXXEXPORT binary_function
{
typedef Arg1 first_argument_type;
typedef Arg2 second_argument_type;
typedef Result result_type;
};
template <class T> struct _UCXXEXPORT plus : binary_function<T,T,T>
{
T operator()(const T& x, const T& y) const{
return x + y;
}
};
template <class T> struct _UCXXEXPORT minus : binary_function<T,T,T>
{
T operator()(const T& x, const T& y) const
{
return x - y;
}
};
template <class T> struct _UCXXEXPORT multiplies : binary_function<T,T,T>
{
T operator()(const T& x, const T& y) const{
return x * y;
}
};
template <class T> struct _UCXXEXPORT divides : binary_function<T,T,T>
{
T operator()(const T& x, const T& y) const{
return x / y;
}
};
template <class T> struct _UCXXEXPORT modulus : binary_function<T,T,T>
{
T operator()(const T& x, const T& y) const
{
return x % y;
}
};
template <class T> struct _UCXXEXPORT negate : unary_function<T,T>
{
T operator()(const T& x) const{
return -x;
}
};
template <class T> struct _UCXXEXPORT equal_to : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x == y);
}
};
template <class T> struct _UCXXEXPORT not_equal_to : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x != y);
}
};
template <class T> struct _UCXXEXPORT greater : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x > y);
}
};
template <class T> struct _UCXXEXPORT less : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x < y);
}
};
template <class T> struct _UCXXEXPORT greater_equal : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x >= y);
}
};
template <class T> struct _UCXXEXPORT less_equal : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x <= y);
}
};
template <class T> struct _UCXXEXPORT logical_and : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x && y);
}
};
template <class T> struct _UCXXEXPORT logical_or : binary_function<T,T,bool>
{
bool operator()(const T& x, const T& y) const
{
return (x || y);
}
};
template <class T> struct _UCXXEXPORT logical_not : unary_function<T,bool>
{
bool operator()(const T& x) const
{
return !x;
}
};
template <class Predicate> class _UCXXEXPORT unary_negate
: public unary_function<typename Predicate::argument_type,bool>
{
public:
explicit unary_negate(const Predicate& pred) : p(pred) { }
bool operator()(const typename Predicate::argument_type& x) const
{
return !p(x);
}
private:
Predicate p;
};
template <class Predicate> _UCXXEXPORT unary_negate<Predicate> not1(const Predicate& pred)
{
return unary_negate<Predicate>(pred);
}
template <class Predicate> class _UCXXEXPORT binary_negate : public
binary_function<typename Predicate::first_argument_type,
typename Predicate::second_argument_type, bool>
{
public:
explicit binary_negate(const Predicate& pred) : p(pred) { }
bool operator()(const typename Predicate::first_argument_type& x,
const typename Predicate::second_argument_type& y) const
{
return !p(x, y);
}
private:
Predicate p;
};
template <class Predicate> _UCXXEXPORT binary_negate<Predicate> not2(const Predicate& pred){
return binary_negate<Predicate>(pred);
}
template <class Operation> class _UCXXEXPORT binder1st
: public unary_function<typename Operation::second_argument_type,
typename Operation::result_type>
{
protected:
Operation op;
typename Operation::first_argument_type value;
public:
binder1st(const Operation& x, const typename Operation::first_argument_type& y) : op(x), value(y){ }
typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const
{
return op(value,x);
}
};
template <class Operation, class T> _UCXXEXPORT binder1st<Operation> bind1st(const Operation& op, const T& x)
{
return binder1st<Operation>(op, typename Operation::first_argument_type(x));
}
template <class Operation> class _UCXXEXPORT binder2nd
: public unary_function<typename Operation::first_argument_type,
typename Operation::result_type>
{
protected:
Operation op;
typename Operation::second_argument_type value;
public:
binder2nd(const Operation& x, const typename Operation::second_argument_type& y) : op(x), value(y) { }
typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const
{
return op(x,value);
}
};
template <class Operation, class T> _UCXXEXPORT
binder2nd<Operation> bind2nd(const Operation& op, const T& x)
{
return binder2nd<Operation>(op, typename Operation::second_argument_type(x));
}
template <class Arg, class Result> class _UCXXEXPORT
pointer_to_unary_function : public unary_function<Arg, Result>
{
protected:
Result (*func)(Arg);
public:
explicit pointer_to_unary_function(Result (*f)(Arg)) : func(f) { }
Result operator()(Arg x) const
{
return func(x);
}
};
template <class Arg, class Result> _UCXXEXPORT pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg))
{
return pointer_to_unary_function<Arg, Result>(f);
}
template <class Arg1, class Arg2, class Result> class _UCXXEXPORT
pointer_to_binary_function : public binary_function<Arg1,Arg2,Result>
{
protected:
Result (*func)(Arg1, Arg2);
public:
explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : func(f) { }
Result operator()(Arg1 x, Arg2 y) const
{
return func(x, y);
}
};
template <class Arg1, class Arg2, class Result> _UCXXEXPORT
pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1, Arg2))
{
return pointer_to_binary_function<Arg1,Arg2,Result>(f);
}
template <class S, class T> class _UCXXEXPORT mem_fun_t
: public unary_function<T*, S>
{
public:
explicit mem_fun_t(S (T::*p)()) : m(p) { }
S operator()(T* p) const { return (p->*m)(); }
private:
S (T::*m)();
};
template <class S, class T, class A> class _UCXXEXPORT mem_fun1_t
: public binary_function<T*, A, S>
{
public:
explicit mem_fun1_t(S (T::*p)(A)) : m(p) { }
S operator()(T* p, A x) const { return (p->*m)(x); }
private:
S (T::*m)(A);
};
template <class S, class T> class _UCXXEXPORT const_mem_fun_t
: public unary_function<const T*, S>
{
public:
explicit const_mem_fun_t(S (T::*p)() const) : m(p) { }
S operator()(const T* p) const { return (p->*m)(); }
private:
S (T::*m)() const;
};
template <class S, class T, class A> class _UCXXEXPORT const_mem_fun1_t
: public binary_function<T*, A, S>
{
public:
explicit const_mem_fun1_t(S (T::*p)(A) const) : m(p) { }
S operator()(const T* p, A x) const { return (p->*m)(x); }
private:
S (T::*m)(A) const;
};
template<class S, class T> _UCXXEXPORT mem_fun_t<S,T> mem_fun(S (T::*f)())
{
return mem_fun_t<S, T>(f);
}
template<class S, class T> _UCXXEXPORT const_mem_fun_t<S,T> mem_fun(S (T::*f)() const)
{
return const_mem_fun_t<S, T>(f);
}
template<class S, class T, class A> _UCXXEXPORT mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A))
{
return mem_fun1_t<S, T, A>(f);
}
template<class S, class T, class A> _UCXXEXPORT const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const)
{
return const_mem_fun1_t<S, T, A>(f);
}
template <class S, class T> class _UCXXEXPORT mem_fun_ref_t
: public unary_function<T, S>
{
public:
explicit mem_fun_ref_t(S (T::*p)()) : mf(p) { }
S operator()(T& p) { return (p.*mf)(); }
private:
S (T::*mf)();
};
template <class S, class T, class A> class _UCXXEXPORT mem_fun1_ref_t
: public binary_function<T, A, S>
{
public:
explicit mem_fun1_ref_t(S (T::*p)(A)) : mf(p) { }
S operator()(T& p, A x) { return (p.*mf)(x); }
private:
S (T::*mf)(A);
};
template<class S, class T> _UCXXEXPORT mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)())
{
return mem_fun_ref_t<S,T>(f);
}
template<class S, class T, class A> _UCXXEXPORT mem_fun1_ref_t<S,T,A> mem_fun1_ref(S (T::*f)(A))
{
return mem_fun1_ref_t<S,T,A>(f);
}
} // namespace
// These are SGI extensions which are checked for by some conformance checks. They
// are *NOT* part of the C++ standard, however
template <class Op1, class Op2> class _UCXXEXPORT unary_compose :
public std::unary_function<typename Op2::argument_type,
typename Op1::result_type>
public std::unary_function<typename Op2::argument_type,
typename Op1::result_type>
{
protected:
Op1 mf1;
Op2 mf2;
Op1 mf1;
Op2 mf2;
public:
unary_compose(const Op1& x, const Op2& y) : mf1(x), mf2(y) { }
typename Op1::result_type operator()(const typename Op2::argument_type& x) const {
return mf1(mf2(x));
}
unary_compose(const Op1& x, const Op2& y) : mf1(x), mf2(y) { }
typename Op1::result_type operator()(const typename Op2::argument_type& x) const
{
return mf1(mf2(x));
}
};
template <class Op1, class Op2> _UCXXEXPORT
inline unary_compose<Op1, Op2>
compose1(const Op1& fn1, const Op2& fn2){
return unary_compose<Op1, Op2>(fn1, fn2);
compose1(const Op1& fn1, const Op2& fn2)
{
return unary_compose<Op1, Op2>(fn1, fn2);
}
template <class Op1, class Op2, class Op3> class _UCXXEXPORT binary_compose :
public std::unary_function<typename Op2::argument_type, typename Op1::result_type>
public std::unary_function<typename Op2::argument_type, typename Op1::result_type>
{
protected:
Op1 mf1;
Op2 mf2;
Op3 mf3;
Op1 mf1;
Op2 mf2;
Op3 mf3;
public:
binary_compose(const Op1 & x, const Op2 & y, const Op3 & z)
: mf1(x), mf2(y), mf3(z){ }
typename Op1::result_type operator()(const typename Op2::argument_type & x) const {
return mf1(mf2(x), mf3(x));
}
binary_compose(const Op1 & x, const Op2 & y, const Op3 & z)
: mf1(x), mf2(y), mf3(z){ }
typename Op1::result_type operator()(const typename Op2::argument_type & x) const
{
return mf1(mf2(x), mf3(x));
}
};
template <class Op1, class Op2, class Op3> inline _UCXXEXPORT binary_compose<Op1, Op2, Op3>
compose2(const Op1 & fn1, const Op2 & fn2, const Op3 & fn3){
return binary_compose<Op1, Op2, Op3>(fn1, fn2, fn3);
compose2(const Op1 & fn1, const Op2 & fn2, const Op3 & fn3)
{
return binary_compose<Op1, Op2, Op3>(fn1, fn2, fn3);
}
} // extern "C++"
#pragma GCC visibility pop
#endif
+104 -91
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2005 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2005 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <exception>
#include <ios>
@@ -25,144 +25,157 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
// These are the helper classes which we are going to be using to
// hold the required data
class _UCXXEXPORT __resetiosflags{
class _UCXXEXPORT __resetiosflags
{
public:
ios_base::fmtflags m;
_UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ }
ios_base::fmtflags m;
_UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ }
};
class _UCXXEXPORT __setiosflags{
class _UCXXEXPORT __setiosflags
{
public:
ios_base::fmtflags m;
_UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ }
ios_base::fmtflags m;
_UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ }
};
class _UCXXEXPORT __setbase{
class _UCXXEXPORT __setbase
{
public:
int base;
_UCXXEXPORT __setbase(int b) : base(b){ }
int base;
_UCXXEXPORT __setbase(int b) : base(b){ }
};
class _UCXXEXPORT __setfill{
class _UCXXEXPORT __setfill
{
public:
int character;
_UCXXEXPORT __setfill(int c): character(c){ }
int character;
_UCXXEXPORT __setfill(int c): character(c){ }
};
class _UCXXEXPORT __setprecision{
class _UCXXEXPORT __setprecision
{
public:
int digits;
_UCXXEXPORT __setprecision(int n): digits(n) { }
int digits;
_UCXXEXPORT __setprecision(int n): digits(n) { }
};
class _UCXXEXPORT __setw{
class _UCXXEXPORT __setw
{
public:
int width;
_UCXXEXPORT __setw(int n): width(n) { }
int width;
_UCXXEXPORT __setw(int n): width(n) { }
};
// Actual manipulator functions
//Actual manipulator functions
inline __resetiosflags resetiosflags(ios_base::fmtflags mask){
return __resetiosflags(mask);
inline __resetiosflags resetiosflags(ios_base::fmtflags mask)
{
return __resetiosflags(mask);
}
inline __setiosflags setiosflags(ios_base::fmtflags mask){
return __setiosflags(mask);
inline __setiosflags setiosflags(ios_base::fmtflags mask)
{
return __setiosflags(mask);
}
inline __setbase setbase(int b){
return __setbase(b);
inline __setbase setbase(int b)
{
return __setbase(b);
}
inline __setfill setfill(int c){
return __setfill(c);
inline __setfill setfill(int c)
{
return __setfill(c);
}
inline __setprecision setprecision(int n){
return __setprecision(n);
inline __setprecision setprecision(int n)
{
return __setprecision(n);
}
inline __setw setw(int n){
return __setw(n);
inline __setw setw(int n)
{
return __setw(n);
}
//How to handle interaction with [i|o]stream classes
// How to handle interaction with [i|o]stream classes
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __resetiosflags s)
operator<<(basic_ostream<Ch, Tr>& os, const __resetiosflags s)
{
os.setf(ios_base::fmtflags(0),s.m);
return os;
os.setf(ios_base::fmtflags(0),s.m);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_istream<Ch, Tr>&
operator>>(basic_istream<Ch, Tr>& is, const __resetiosflags s)
operator>>(basic_istream<Ch, Tr>& is, const __resetiosflags s)
{
is.setf(ios_base::fmtflags(0),s.m);
return is;
is.setf(ios_base::fmtflags(0),s.m);
return is;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setiosflags s)
operator<<(basic_ostream<Ch, Tr>& os, const __setiosflags s)
{
os.setf(s.m);
return os;
os.setf(s.m);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setbase s)
operator<<(basic_ostream<Ch, Tr>& os, const __setbase s)
{
ios_base::fmtflags f(0);
switch(s.base){
case 8:
f = ios_base::oct;
break;
case 10:
f = ios_base::dec;
break;
case 16:
f = ios_base::hex;
break;
default:
break;
ios_base::fmtflags f(0);
switch(s.base)
{
case 8:
f = ios_base::oct;
break;
case 10:
f = ios_base::dec;
break;
case 16:
f = ios_base::hex;
break;
default:
break;
}
}
os.setf(f, ios_base::basefield);
return os;
os.setf(f, ios_base::basefield);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setfill s)
operator<<(basic_ostream<Ch, Tr>& os, const __setfill s)
{
os.fill(s.character);
return os;
os.fill(s.character);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setprecision s)
operator<<(basic_ostream<Ch, Tr>& os, const __setprecision s)
{
os.precision(s.digits);
return os;
os.precision(s.digits);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, const __setw s)
operator<<(basic_ostream<Ch, Tr>& os, const __setw s)
{
os.width(s.width);
return os;
os.width(s.width);
return os;
}
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
File diff suppressed because it is too large Load Diff
+79 -74
View File
@@ -1,114 +1,119 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <char_traits>
#include <memory>
#ifndef __HEADER_STD_IOSFWD
#define __HEADER_STD_IOSFWD 1
#pragma GCC visibility push(default)
namespace std {
class ios_base;
template<> class char_traits<char>;
extern "C++"
{
namespace std
{
class ios_base;
template<> class char_traits<char>;
#ifdef __UCLIBCXX_HAS_WCHAR__
template<> class char_traits<wchar_t>;
template<> class char_traits<wchar_t>;
#endif
template <class charT, class traits = char_traits<charT> > class basic_ios;
template <class charT, class traits = char_traits<charT> > class basic_ios;
template <class charT, class traits = char_traits<charT> > class basic_streambuf;
template <class charT, class traits = char_traits<charT> > class basic_istream;
template <class charT, class traits = char_traits<charT> > class basic_ostream;
template <class charT, class traits = char_traits<charT> > class basic_iostream;
template <class charT, class traits = char_traits<charT> > class basic_streambuf;
template <class charT, class traits = char_traits<charT> > class basic_istream;
template <class charT, class traits = char_traits<charT> > class basic_ostream;
template <class charT, class traits = char_traits<charT> > class basic_iostream;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_stringbuf;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_stringbuf;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_istringstream;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_istringstream;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_ostringstream;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_ostringstream;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_stringstream;
template <class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> > class basic_stringstream;
template <class charT, class traits = char_traits<charT> > class basic_filebuf;
template <class charT, class traits = char_traits<charT> > class basic_filebuf;
template <class charT, class traits = char_traits<charT> > class basic_ifstream;
template <class charT, class traits = char_traits<charT> > class basic_ifstream;
template <class charT, class traits = char_traits<charT> > class basic_ofstream;
template <class charT, class traits = char_traits<charT> > class basic_ofstream;
template <class charT, class traits = char_traits<charT> > class basic_fstream;
template <class charT, class traits = char_traits<charT> > class basic_fstream;
template <class charT, class traits = char_traits<charT> > class basic_istreambuf_iterator;
template <class charT, class traits = char_traits<charT> > class basic_istreambuf_iterator;
template <class charT, class traits = char_traits<charT> > class basic_ostreambuf_iterator;
template <class charT, class traits = char_traits<charT> > class basic_ostreambuf_iterator;
typedef basic_ios<char> ios;
typedef basic_ios<char> ios;
#ifdef __UCLIBCXX_HAS_WCHAR__
typedef basic_ios<wchar_t> wios;
typedef basic_ios<wchar_t> wios;
#endif
typedef basic_streambuf<char> streambuf;
typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
typedef basic_iostream<char> iostream;
typedef basic_streambuf<char> streambuf;
typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
typedef basic_iostream<char> iostream;
typedef basic_stringbuf<char> stringbuf;
typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_stringbuf<char> stringbuf;
typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
#ifdef __UCLIBCXX_HAS_WCHAR__
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_istream<wchar_t> wistream;
typedef basic_ostream<wchar_t> wostream;
typedef basic_iostream<wchar_t> wiostream;
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_istream<wchar_t> wistream;
typedef basic_ostream<wchar_t> wostream;
typedef basic_iostream<wchar_t> wiostream;
typedef basic_stringbuf<wchar_t> wstringbuf;
typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;
typedef basic_stringbuf<wchar_t> wstringbuf;
typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
#endif
template <class state> class fpos;
typedef fpos<char_traits<char>::state_type> streampos;
template <class state> class fpos;
typedef fpos<char_traits<char>::state_type> streampos;
#ifdef __UCLIBCXX_HAS_WCHAR__
typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
#endif
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
#endif
#endif // __HEADER_STD_IOSFWD
+53 -53
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
@@ -31,70 +31,70 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
#ifdef __UCLIBCXX_SUPPORT_CIN__
extern istream cin;
extern istream cin;
#endif
#ifdef __UCLIBCXX_SUPPORT_COUT__
extern ostream cout;
extern ostream cout;
#endif
#ifdef __UCLIBCXX_SUPPORT_CERR__
extern ostream cerr;
extern ostream cerr;
#endif
#ifdef __UCLIBCXX_SUPPORT_CLOG__
extern ostream clog;
extern ostream clog;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCIN__
extern wistream wcin;
extern wistream wcin;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCOUT__
extern wostream wcout;
extern wostream wcout;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCERR__
extern wostream wcerr;
extern wostream wcerr;
#endif
#ifdef __UCLIBCXX_SUPPORT_WCLOG__
extern wostream wclog;
extern wostream wclog;
#endif
template <class charT, class traits> class _UCXXEXPORT basic_iostream :
public basic_istream<charT,traits>, public basic_ostream<charT,traits>
{
public:
// constructor/destructor
explicit _UCXXEXPORT basic_iostream(basic_streambuf<charT,traits>* sb);
virtual _UCXXEXPORT ~basic_iostream(); //Below
};
template <class charT, class traits> class _UCXXEXPORT basic_iostream :
public basic_istream<charT,traits>, public basic_ostream<charT,traits>
{
public:
// constructor/destructor
explicit _UCXXEXPORT basic_iostream(basic_streambuf<charT,traits>* sb);
virtual _UCXXEXPORT ~basic_iostream(); //Below
};
template <class charT, class traits> _UCXXEXPORT
basic_iostream<charT, traits>:: basic_iostream(basic_streambuf<charT,traits>* sb)
: basic_ios<charT, traits>(sb), basic_istream<charT,traits>(sb), basic_ostream<charT,traits>(sb)
{
return;
}
template <class charT, class traits> _UCXXEXPORT basic_iostream<charT, traits>::~basic_iostream(){
return;
}
template <class charT, class traits> _UCXXEXPORT
basic_iostream<charT, traits>:: basic_iostream(basic_streambuf<charT,traits>* sb)
: basic_ios<charT, traits>(sb), basic_istream<charT,traits>(sb), basic_ostream<charT,traits>(sb)
{
return;
}
template <class charT, class traits> _UCXXEXPORT basic_iostream<charT, traits>::~basic_iostream(){
return;
}
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
#ifndef __UCLIBCXX_COMPILE_IOSTREAM__
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::
basic_iostream(basic_streambuf<char, char_traits<char> >* sb);
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::~basic_iostream();
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::
basic_iostream(basic_streambuf<char, char_traits<char> >* sb);
template <> _UCXXEXPORT basic_iostream<char, char_traits<char> >::~basic_iostream();
#endif
#endif
#endif
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
File diff suppressed because it is too large Load Diff
+428 -319
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ios>
#include <cctype>
@@ -28,343 +28,452 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
/* We are making the following template class for serveral reasons. Firstly,
* we want to keep the main istream code neat and tidy. Secondly, we want it
* to be easy to do partial specialization of the istream code so that it can
* be expanded and put into the library. This will allow us to make application
* code smaller at the expense of increased library size. This is a fair
* trade-off when there are multiple applications being compiled. Also, this
* feature will be used optionally via configuration options. It will also
* allow us to keep the code bases in sync, dramatically simplifying the
* maintenance required. We specialized for char because wchar and others
* require different scanf functions
*/
template <class C, class traits> _UCXXEXPORT
basic_string<C, traits> _readToken(basic_istream<C, traits>& stream)
{
basic_string<C, traits> temp;
typename traits::int_type c;
while (true)
{
c = stream.rdbuf()->sgetc();
if (c != traits::eof() && isspace(c) == false)
{
stream.rdbuf()->sbumpc();
temp.append(1, traits::to_char_type(c));
}
else
{
break;
}
}
/* We are making the following template class for serveral reasons. Firstly,
* we want to keep the main istream code neat and tidy. Secondly, we want it
* to be easy to do partial specialization of the istream code so that it can
* be expanded and put into the library. This will allow us to make application
* code smaller at the expense of increased library size. This is a fair
* trade-off when there are multiple applications being compiled. Also, this
* feature will be used optionally via configuration options. It will also
* allow us to keep the code bases in sync, dramatically simplifying the
* maintenance required. We specialized for char because wchar and others
* require different scanf functions
*/
if (temp.size() == 0)
{
stream.setstate(ios_base::eofbit|ios_base::failbit);
}
template <class C, class traits> _UCXXEXPORT
basic_string<C, traits> _readToken(basic_istream<C, traits>& stream)
{
basic_string<C, traits> temp;
typename traits::int_type c;
while(true){
c = stream.rdbuf()->sgetc();
if(c != traits::eof() && isspace(c) == false){
stream.rdbuf()->sbumpc();
temp.append(1, traits::to_char_type(c));
}else{
break;
}
}
if (temp.size() == 0)
stream.setstate(ios_base::eofbit|ios_base::failbit);
return temp;
}
return temp;
}
template <class C, class traits> _UCXXEXPORT
basic_string<C, traits> _readTokenDecimal(basic_istream<C, traits>& stream)
{
basic_string<C, traits> temp;
typename traits::int_type c;
while (true)
{
c = stream.rdbuf()->sgetc();
if (c != traits::eof() && isspace(c) == false && (
isdigit(c) ||
c == '.' ||
c == ',' ||
((c == '-' || c == '+') && temp.size() == 0)))
{
stream.rdbuf()->sbumpc();
temp.append(1, traits::to_char_type(c));
}
else
{
break;
}
}
template <class C, class traits> _UCXXEXPORT
basic_string<C, traits> _readTokenDecimal(basic_istream<C, traits>& stream)
{
basic_string<C, traits> temp;
typename traits::int_type c;
while(true){
c = stream.rdbuf()->sgetc();
if(c != traits::eof() && isspace(c) == false && (
isdigit(c) ||
c == '.' ||
c == ',' ||
((c == '-' || c == '+') && temp.size() == 0) )
){
stream.rdbuf()->sbumpc();
temp.append(1, traits::to_char_type(c));
}else{
break;
}
}
if (temp.size() == 0)
stream.setstate(ios_base::eofbit|ios_base::failbit);
if (temp.size() == 0)
{
stream.setstate(ios_base::eofbit|ios_base::failbit);
}
return temp;
}
return temp;
}
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
template <> _UCXXEXPORT string _readToken<char, char_traits<char> >(istream & stream);
template <> _UCXXEXPORT string _readToken<char, char_traits<char> >(istream & stream);
#endif
template <class traits, class charT, class dataType> class _UCXXEXPORT __istream_readin
{
public:
static void readin(basic_istream<charT,traits>& stream, dataType & var);
};
template <class traits, class charT, class dataType> class _UCXXEXPORT __istream_readin{
public:
static void readin(basic_istream<charT,traits>& stream, dataType & var);
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, bool>
{
public:
inline static void readin(basic_istream<char, traits >& stream, bool & var)
{
/* 22.4.2.1.2.4 */
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, bool>{
public:
inline static void readin(basic_istream<char, traits >& stream, bool & var)
{
/* 22.4.2.1.2.4 */
basic_string<char, traits > temp;
temp = _readToken( stream);
if (stream.flags() & ios_base::boolalpha) {
if (temp == "true") // truename()
var = true;
else {
var = false;
if (temp != "false") // falsename()
stream.setstate(ios_base::failbit);
}
} else {
long int i = 0;
int ret;
if (stream.flags() & ios_base::dec) {
ret = sscanf(temp.c_str(), "%ld", &i );
} else {
if (stream.flags() & ios_base::oct) {
ret = sscanf(temp.c_str(), "%lo", (unsigned long int *)(&i));
} else if (stream.flags() & ios_base::hex) {
if (stream.flags() & ios_base::uppercase) {
ret = sscanf(temp.c_str(), "%lX", (unsigned long int *)(&i));
} else {
ret = sscanf(temp.c_str(), "%lx", (unsigned long int *)(&i));
}
} else {
ret = sscanf(temp.c_str(), "%li", &i);
}
}
if (ret != 1 || i >> 1)
stream.setstate(ios_base::failbit);
var = ret == 1 && bool(i);
}
}
};
basic_string<char, traits > temp;
temp = _readToken(stream);
if (stream.flags() & ios_base::boolalpha)
{
if (temp == "true") // truename()
{
var = true;
}
else
{
var = false;
if (temp != "false") // falsename()
{
stream.setstate(ios_base::failbit);
}
}
}
else
{
long int i = 0;
int ret;
if (stream.flags() & ios_base::dec)
{
ret = sscanf(temp.c_str(), "%ld", &i);
}
else
{
if (stream.flags() & ios_base::oct)
{
ret = sscanf(temp.c_str(), "%lo", (unsigned long int *)(&i));
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
ret = sscanf(temp.c_str(), "%lX", (unsigned long int *)(&i));
}
else
{
ret = sscanf(temp.c_str(), "%lx", (unsigned long int *)(&i));
}
}
else
{
ret = sscanf(temp.c_str(), "%li", &i);
}
}
if (ret != 1 || i >> 1)
{
stream.setstate(ios_base::failbit);
}
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, short>{
public:
inline static void readin(basic_istream<char, traits >& stream, short & var)
{
basic_string<char, traits > temp;
var = ret == 1 && bool(i);
}
}
};
if(stream.flags() & ios_base::dec){
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%hd", &var );
}else{
temp = _readToken( stream);
if( stream.flags() & ios_base::oct){
sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) );
}else if(stream.flags() & ios_base::hex){
if(stream.flags() & ios_base::uppercase){
sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) );
}else{
sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) );
}
}else{
sscanf(temp.c_str(), "%hi", &var);
}
}
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, short>
{
public:
inline static void readin(basic_istream<char, traits >& stream, short & var)
{
basic_string<char, traits > temp;
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned short>{
public:
inline static void readin(basic_istream<char, traits >& stream, unsigned short & var)
{
basic_string<char, traits > temp;
if (stream.flags() & ios_base::dec)
{
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%hd", &var);
}
else
{
temp = _readToken(stream);
if (stream.flags() & ios_base::oct)
{
sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var));
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var));
}
else
{
sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var));
}
}
else
{
sscanf(temp.c_str(), "%hi", &var);
}
}
}
};
if(stream.flags() & ios_base::dec){
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%hu", &var );
}else{
temp = _readToken( stream);
if( stream.flags() & ios_base::oct){
sscanf(temp.c_str(), "%ho", &var);
}else if(stream.flags() & ios_base::hex){
if(stream.flags() & ios_base::uppercase){
sscanf(temp.c_str(), "%hX", &var );
}else{
sscanf(temp.c_str(), "%hx", &var);
}
}else{
sscanf(temp.c_str(), "%hi", (signed short int*)(&var) );
}
}
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned short>{
public:
inline static void readin(basic_istream<char, traits >& stream, unsigned short & var)
{
basic_string<char, traits > temp;
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, int>{
public:
inline static void readin(basic_istream<char, traits >& stream, int & var)
{
basic_string<char, traits > temp;
if (stream.flags() & ios_base::dec)
{
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%hu", &var);
}
else
{
temp = _readToken(stream);
if (stream.flags() & ios_base::oct)
{
sscanf(temp.c_str(), "%ho", &var);
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
sscanf(temp.c_str(), "%hX", &var);
}
else
{
sscanf(temp.c_str(), "%hx", &var);
}
}
else
{
sscanf(temp.c_str(), "%hi", (signed short int*)(&var));
}
}
}
};
if(stream.flags() & ios_base::dec){
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%d", &var );
}else{
temp = _readToken( stream);
if( stream.flags() & ios_base::oct){
sscanf(temp.c_str(), "%o", (unsigned int *)(&var) );
}else if(stream.flags() & ios_base::hex){
if(stream.flags() & ios_base::uppercase){
sscanf(temp.c_str(), "%X", (unsigned int *)(&var) );
}else{
sscanf(temp.c_str(), "%x", (unsigned int *)(&var) );
}
}else{
sscanf(temp.c_str(), "%i", &var);
}
}
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, int>{
public:
inline static void readin(basic_istream<char, traits >& stream, int & var)
{
basic_string<char, traits > temp;
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned int>{
public:
inline static void readin(basic_istream<char, traits >& stream, unsigned int & var)
{
basic_string<char, traits > temp;
if (stream.flags() & ios_base::dec)
{
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%d", &var);
}
else
{
temp = _readToken(stream);
if (stream.flags() & ios_base::oct)
{
sscanf(temp.c_str(), "%o", (unsigned int *)(&var));
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
sscanf(temp.c_str(), "%X", (unsigned int *)(&var));
}
else
{
sscanf(temp.c_str(), "%x", (unsigned int *)(&var));
}
}
else
{
sscanf(temp.c_str(), "%i", &var);
}
}
}
};
if(stream.flags() & ios_base::dec){
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%u", &var );
}else{
temp = _readToken( stream);
if( stream.flags() & ios_base::oct){
sscanf(temp.c_str(), "%o", (unsigned int *)(&var) );
}else if(stream.flags() & ios_base::hex){
if(stream.flags() & ios_base::uppercase){
sscanf(temp.c_str(), "%X", (unsigned int *)(&var) );
}else{
sscanf(temp.c_str(), "%x", (unsigned int *)(&var) );
}
}else{
sscanf(temp.c_str(), "%i", (int *)(&var) );
}
}
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned int>{
public:
inline static void readin(basic_istream<char, traits >& stream, unsigned int & var)
{
basic_string<char, traits > temp;
}
};
if (stream.flags() & ios_base::dec)
{
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%u", &var);
}
else
{
temp = _readToken(stream);
if (stream.flags() & ios_base::oct)
{
sscanf(temp.c_str(), "%o", (unsigned int *)(&var));
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
sscanf(temp.c_str(), "%X", (unsigned int *)(&var));
}
else
{
sscanf(temp.c_str(), "%x", (unsigned int *)(&var));
}
}
else
{
sscanf(temp.c_str(), "%i", (int *)(&var));
}
}
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long int>{
public:
inline static void readin(basic_istream<char, traits >& stream, long int & var)
{
basic_string<char, traits > temp;
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long int>{
public:
inline static void readin(basic_istream<char, traits >& stream, long int & var)
{
basic_string<char, traits > temp;
if (stream.flags() & ios_base::dec)
{
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%ld", &var);
}
else
{
temp = _readToken(stream);
if (stream.flags() & ios_base::oct)
{
sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var));
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var));
}
else
{
sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var));
}
}
else
{
sscanf(temp.c_str(), "%li", (long int *)(&var));
}
}
}
};
if(stream.flags() & ios_base::dec){
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%ld", &var );
}else{
temp = _readToken( stream);
if( stream.flags() & ios_base::oct){
sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) );
}else if(stream.flags() & ios_base::hex){
if(stream.flags() & ios_base::uppercase){
sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) );
}else{
sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) );
}
}else{
sscanf(temp.c_str(), "%li", (long int *)(&var) );
}
}
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned long int>{
public:
inline static void readin(basic_istream<char, traits >& stream, unsigned long int & var)
{
basic_string<char, traits > temp;
if(stream.flags() & ios_base::dec){
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%lu", &var );
}else{
temp = _readToken( stream);
if( stream.flags() & ios_base::oct){
sscanf(temp.c_str(), "%lo", &var );
}else if(stream.flags() & ios_base::hex){
if(stream.flags() & ios_base::uppercase){
sscanf(temp.c_str(), "%lX", &var );
}else{
sscanf(temp.c_str(), "%lx", &var);
}
}else{
sscanf(temp.c_str(), "%li", (long int *)(&var) );
}
}
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, unsigned long int>
{
public:
inline static void readin(basic_istream<char, traits >& stream, unsigned long int & var)
{
basic_string<char, traits > temp;
if (stream.flags() & ios_base::dec)
{
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%lu", &var);
}
else
{
temp = _readToken(stream);
if (stream.flags() & ios_base::oct)
{
sscanf(temp.c_str(), "%lo", &var);
}
else if (stream.flags() & ios_base::hex)
{
if (stream.flags() & ios_base::uppercase)
{
sscanf(temp.c_str(), "%lX", &var);
}
else
{
sscanf(temp.c_str(), "%lx", &var);
}
}
else
{
sscanf(temp.c_str(), "%li", (long int *)(&var));
}
}
}
};
#ifdef CONFIG_HAVE_FLOAT
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, float>{
public:
inline static void readin(basic_istream<char, traits >& stream, float & var)
{
basic_string<char, traits > temp;
temp = _readTokenDecimal( stream);
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, float>
{
public:
inline static void readin(basic_istream<char, traits >& stream, float & var)
{
basic_string<char, traits > temp;
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%g", &var);
}
};
sscanf(temp.c_str(), "%g", &var);
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, double>{
public:
inline static void readin(basic_istream<char, traits >& stream, double & var)
{
basic_string<char, traits > temp;
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%lg", &var);
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, double>
{
public:
inline static void readin(basic_istream<char, traits >& stream, double & var)
{
basic_string<char, traits > temp;
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%lg", &var);
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long double>{
public:
inline static void readin(basic_istream<char, traits >& stream, long double & var)
{
basic_string<char, traits > temp;
temp = _readTokenDecimal( stream);
sscanf(temp.c_str(), "%Lg", &var);
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long double>
{
public:
inline static void readin(basic_istream<char, traits >& stream, long double & var)
{
basic_string<char, traits > temp;
temp = _readTokenDecimal(stream);
sscanf(temp.c_str(), "%Lg", &var);
}
};
#endif // ifdef CONFIG_HAVE_FLOAT
#endif // ifdef CONFIG_HAVE_FLOAT
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, void*>{
public:
inline static void readin(basic_istream<char, traits >& stream, void* & var)
{
basic_string<char, traits > temp;
temp = _readToken( stream);
sscanf(temp.c_str(), "%p", &var);
}
};
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, void*>
{
public:
inline static void readin(basic_istream<char, traits >& stream, void* & var)
{
basic_string<char, traits > temp;
temp = _readToken(stream);
sscanf(temp.c_str(), "%p", &var);
}
};
template<class charT, class traits> void __skipws(basic_istream<charT,traits>& is)
{
const typename basic_istream<charT,traits>::int_type eof = traits::eof();
typename basic_istream<charT,traits>::int_type c;
template<class charT, class traits> void __skipws(basic_istream<charT,traits>& is){
const typename basic_istream<charT,traits>::int_type eof = traits::eof();
typename basic_istream<charT,traits>::int_type c;
//While the next character normally read doesn't equal eof
//and that character is a space, advance to the next read position
//Thus itterating through all whitespace until we get to the meaty stuff
while (
!traits::eq_int_type((c = is.rdbuf()->sgetc()), eof)
&& isspace(c)
) {
is.rdbuf()->sbumpc();
}
if(traits::eq_int_type(c, eof)){
is.setstate(ios_base::eofbit);
}
}
}
// While the next character normally read doesn't equal eof
// and that character is a space, advance to the next read position
// Thus itterating through all whitespace until we get to the meaty stuff
while (
!traits::eq_int_type((c = is.rdbuf()->sgetc()), eof)
&& isspace(c))
{
is.rdbuf()->sbumpc();
}
if (traits::eq_int_type(c, eof))
{
is.setstate(ios_base::eofbit);
}
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+239 -193
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <iosfwd>
@@ -23,204 +23,250 @@
#include <char_traits>
#include <iterator_base>
#ifndef __STD_HEADER_ITERATOR
#define __STD_HEADER_ITERATOR 1
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
// subclause _lib.stream.iterators_, stream iterators:
template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t> class istream_iterator;
template <class T, class charT, class traits, class Distance> bool
operator==(const istream_iterator<T,charT,traits,Distance>& x, const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT, class traits, class Distance> bool
operator!=(const istream_iterator<T,charT,traits,Distance>& x, const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT = char, class traits = char_traits<charT> > class ostream_iterator;
template<class charT, class traits = char_traits<charT> > class istreambuf_iterator;
template <class charT, class traits> bool
operator==(const istreambuf_iterator<charT,traits>& a, const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits> bool
operator!=(const istreambuf_iterator<charT,traits>& a, const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
namespace std
{
// Subclause _lib.stream.iterators_, stream iterators:
template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator
: public iterator<input_iterator_tag,T,Distance,const T*, const T&>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_istream<charT,traits> istream_type;
istream_iterator() : in_stream(0), value(0) {}
istream_iterator(istream_type& s) : in_stream(&s), value() {
*in_stream >> value;
}
istream_iterator(const istream_iterator<T,charT,traits,Distance>& x)
: in_stream(x.in_stream), value(x.value)
{ }
~istream_iterator() { }
const T& operator*() const{
return value;
}
const T* operator->() const{
return &value;
}
istream_iterator<T,charT,traits,Distance>& operator++() {
*in_stream >> value;
return *this;
}
istream_iterator<T,charT,traits,Distance> operator++(int){
istream_iterator<T,charT,traits,Distance> tmp = *this;
*in_stream >> value;
return (tmp);
}
bool m_equal(const istream_iterator<T,charT,traits,Distance>& x) const{
return (in_stream == x.in_stream);
}
private:
basic_istream<charT,traits>* in_stream;
T value;
};
template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t> class istream_iterator;
template <class T, class charT, class traits, class Distance> bool
operator==(const istream_iterator<T,charT,traits,Distance>& x, const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT, class traits, class Distance> bool
operator!=(const istream_iterator<T,charT,traits,Distance>& x, const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT = char, class traits = char_traits<charT> > class ostream_iterator;
template<class charT, class traits = char_traits<charT> > class istreambuf_iterator;
template <class charT, class traits> bool
operator==(const istreambuf_iterator<charT,traits>& a, const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits> bool
operator!=(const istreambuf_iterator<charT,traits>& a, const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
template <class T, class charT, class traits, class Distance> _UCXXEXPORT
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y)
{
return x.m_equal(y);
}
template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator
: public iterator<input_iterator_tag,T,Distance,const T*, const T&>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_istream<charT,traits> istream_type;
istream_iterator() : in_stream(0), value(0) {}
template <class T, class charT, class traits, class Distance> _UCXXEXPORT
bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y)
{
return !(x == y);
}
istream_iterator(istream_type& s) : in_stream(&s), value()
{
*in_stream >> value;
}
template <class T, class charT, class traits> class _UCXXEXPORT ostream_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_ostream<charT,traits> ostream_type;
istream_iterator(const istream_iterator<T,charT,traits,Distance>& x)
: in_stream(x.in_stream), value(x.value)
{ }
ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { }
ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { }
ostream_iterator(const ostream_iterator<T,charT,traits>& x) : out_stream(x.out_stream), delim(x.delim) { }
~ostream_iterator() { }
ostream_iterator<T,charT,traits>& operator=(const T& value){
*out_stream << value;
if(delim != 0){
*out_stream << delim;
}
return (*this);
}
ostream_iterator<T,charT,traits>& operator*(){ return *this; }
ostream_iterator<T,charT,traits>& operator++() { return *this; }
ostream_iterator<T,charT,traits> operator++(int) { return *this; }
private:
basic_ostream<charT,traits>* out_stream;
const char* delim;
};
~istream_iterator() { }
template<class charT, class traits > class _UCXXEXPORT istreambuf_iterator :
public iterator<input_iterator_tag, charT, typename traits::off_type, charT*, charT&>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits::int_type int_type;
typedef basic_streambuf<charT,traits> streambuf_type;
typedef basic_istream<charT,traits> istream_type;
const T& operator*() const
{
return value;
}
class _UCXXEXPORT proxy{
charT val;
basic_streambuf<charT, traits> * buf;
const T* operator->() const
{
return &value;
}
proxy(charT v, basic_streambuf<charT, traits> * b) : val(v), buf(b) { }
public:
charT operator*() { return val; }
};
istream_iterator<T,charT,traits,Distance>& operator++()
{
*in_stream >> value;
return *this;
}
istreambuf_iterator() throw() : sbuf(0) { }
istreambuf_iterator(istream_type& s) throw() : sbuf(s.rdbuf()) { }
istreambuf_iterator(streambuf_type* s) throw() : sbuf(s) { }
istreambuf_iterator(const proxy& p) throw() : sbuf(&p.buf) { }
istream_iterator<T,charT,traits,Distance> operator++(int)
{
istream_iterator<T,charT,traits,Distance> tmp = *this;
*in_stream >> value;
return (tmp);
}
charT operator*() const{
return sbuf->sgetc();
}
istreambuf_iterator<charT,traits>& operator++(){
sbuf->sbumpc();
return *this;
}
proxy operator++(int){
istreambuf_iterator<charT,traits> tmp = *this;
sbuf->sbumpc();
return(tmp);
}
bool m_equal(const istream_iterator<T,charT,traits,Distance>& x) const
{
return (in_stream == x.in_stream);
}
bool equal(const istreambuf_iterator& b) const{
return sbuf == b.sbuf || is_eof() && b.is_eof();
}
private:
streambuf_type* sbuf;
inline bool is_eof() const{
return sbuf == 0 || sbuf->sgetc() == traits_type::eof();
}
};
private:
basic_istream<charT,traits>* in_stream;
T value;
};
template <class charT, class traits> _UCXXEXPORT bool
operator==(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b)
{
return a.equal(b);
}
template <class T, class charT, class traits, class Distance> _UCXXEXPORT
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y)
{
return x.m_equal(y);
}
template <class charT, class traits> bool _UCXXEXPORT
operator!=(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b)
{
return !a.equal(b);
}
template <class T, class charT, class traits, class Distance> _UCXXEXPORT
bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y)
{
return !(x == y);
}
template <class charT, class traits> class _UCXXEXPORT ostreambuf_iterator
: iterator<output_iterator_tag,void,void,void,void>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_streambuf<charT,traits> streambuf_type;
typedef basic_ostream<charT,traits> ostream_type;
public:
ostreambuf_iterator(ostream_type& s) throw() : sbuf(s.rdbuf()), f(false) { }
ostreambuf_iterator(streambuf_type* s) throw() : sbuf(s), f(false) { }
ostreambuf_iterator& operator=(charT c){
if(failed() == false){
if(sbuf->sputc(c) == traits::eof()){
f = true;
}
}
return *this;
}
ostreambuf_iterator& operator*(){
return *this;
}
ostreambuf_iterator& operator++() { return *this; }
ostreambuf_iterator operator++(int) { return *this; }
bool failed() const throw(){
return f;
}
template <class T, class charT, class traits> class _UCXXEXPORT ostream_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_ostream<charT,traits> ostream_type;
private:
streambuf_type* sbuf;
bool f;
};
ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { }
ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { }
ostream_iterator(const ostream_iterator<T,charT,traits>& x) : out_stream(x.out_stream), delim(x.delim) { }
}
~ostream_iterator() { }
ostream_iterator<T,charT,traits>& operator=(const T& value)
{
*out_stream << value;
if (delim != 0)
{
*out_stream << delim;
}
return (*this);
}
ostream_iterator<T,charT,traits>& operator*(){ return *this; }
ostream_iterator<T,charT,traits>& operator++() { return *this; }
ostream_iterator<T,charT,traits> operator++(int) { return *this; }
private:
basic_ostream<charT,traits>* out_stream;
const char* delim;
};
template<class charT, class traits > class _UCXXEXPORT istreambuf_iterator :
public iterator<input_iterator_tag, charT, typename traits::off_type, charT*, charT&>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits::int_type int_type;
typedef basic_streambuf<charT,traits> streambuf_type;
typedef basic_istream<charT,traits> istream_type;
class _UCXXEXPORT proxy
{
charT val;
basic_streambuf<charT, traits> * buf;
proxy(charT v, basic_streambuf<charT, traits> * b) : val(v), buf(b) { }
public:
charT operator*() { return val; }
};
istreambuf_iterator() throw() : sbuf(0) { }
istreambuf_iterator(istream_type& s) throw() : sbuf(s.rdbuf()) { }
istreambuf_iterator(streambuf_type* s) throw() : sbuf(s) { }
istreambuf_iterator(const proxy& p) throw() : sbuf(&p.buf) { }
charT operator*() const
{
return sbuf->sgetc();
}
istreambuf_iterator<charT,traits>& operator++()
{
sbuf->sbumpc();
return *this;
}
proxy operator++(int)
{
istreambuf_iterator<charT,traits> tmp = *this;
sbuf->sbumpc();
return(tmp);
}
bool equal(const istreambuf_iterator& b) const
{
return sbuf == b.sbuf || is_eof() && b.is_eof();
}
private:
streambuf_type* sbuf;
inline bool is_eof() const
{
return sbuf == 0 || sbuf->sgetc() == traits_type::eof();
}
};
template <class charT, class traits> _UCXXEXPORT bool
operator==(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b)
{
return a.equal(b);
}
template <class charT, class traits> bool _UCXXEXPORT
operator!=(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b)
{
return !a.equal(b);
}
template <class charT, class traits> class _UCXXEXPORT ostreambuf_iterator
: iterator<output_iterator_tag,void,void,void,void>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_streambuf<charT,traits> streambuf_type;
typedef basic_ostream<charT,traits> ostream_type;
public:
ostreambuf_iterator(ostream_type& s) throw() : sbuf(s.rdbuf()), f(false) { }
ostreambuf_iterator(streambuf_type* s) throw() : sbuf(s), f(false) { }
ostreambuf_iterator& operator=(charT c)
{
if (failed() == false)
{
if (sbuf->sputc(c) == traits::eof())
{
f = true;
}
}
return *this;
}
ostreambuf_iterator& operator*()
{
return *this;
}
ostreambuf_iterator& operator++() { return *this; }
ostreambuf_iterator operator++(int) { return *this; }
bool failed() const throw()
{
return f;
}
private:
streambuf_type* sbuf;
bool f;
};
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+302 -264
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
@@ -24,282 +24,320 @@
#pragma GCC visibility push(default)
namespace std{
template<class Iterator> struct iterator_traits;
template<class T> struct iterator_traits<T*>;
extern "C++"
{
template<class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&> struct iterator;
namespace std
{
template<class Iterator> struct iterator_traits;
template<class T> struct iterator_traits<T*>;
struct _UCXXEXPORT input_iterator_tag {};
struct _UCXXEXPORT output_iterator_tag {};
struct _UCXXEXPORT forward_iterator_tag: public input_iterator_tag {};
struct _UCXXEXPORT bidirectional_iterator_tag: public forward_iterator_tag {};
struct _UCXXEXPORT random_access_iterator_tag: public bidirectional_iterator_tag {};
template<class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&> struct iterator;
template <class InputIterator, class Distance> _UCXXEXPORT void advance(InputIterator& i, Distance n){
while(n > 0){
--n;
++i;
}
}
struct _UCXXEXPORT input_iterator_tag {};
struct _UCXXEXPORT output_iterator_tag {};
struct _UCXXEXPORT forward_iterator_tag: public input_iterator_tag {};
struct _UCXXEXPORT bidirectional_iterator_tag: public forward_iterator_tag {};
struct _UCXXEXPORT random_access_iterator_tag: public bidirectional_iterator_tag {};
template <class InputIterator> _UCXXEXPORT typename iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last)
{
typename iterator_traits<InputIterator>::difference_type d = 0;
while(first++ !=last){
d++;
}
return d;
}
template <class InputIterator, class Distance> _UCXXEXPORT void advance(InputIterator& i, Distance n)
{
while (n > 0)
{
--n;
++i;
}
}
template <class InputIterator> _UCXXEXPORT typename iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last)
{
typename iterator_traits<InputIterator>::difference_type d = 0;
while (first++ !=last)
{
d++;
}
return d;
}
// subclause _lib.predef.iterators_, predefined iterators:
template <class Iterator> class reverse_iterator;
template <class Iterator> bool operator==(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator<(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator!=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator>=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator<=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> typename reverse_iterator<Iterator>::difference_type
operator-( const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> reverse_iterator<Iterator>
operator+( typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x);
template <class Container> class back_insert_iterator;
template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
template <class Container> class front_insert_iterator;
template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
template <class Container> class insert_iterator;
template <class Container, class Iterator>
insert_iterator<Container> inserter(Container& x, Iterator i);
//Actual Template definitions
template <class Iterator> class reverse_iterator;
template <class Iterator> bool operator==(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator<(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator!=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator>=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> bool operator<=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> typename reverse_iterator<Iterator>::difference_type
operator-( const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
template <class Iterator> reverse_iterator<Iterator>
operator+( typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x);
template <class Container> class back_insert_iterator;
template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
template <class Container> class front_insert_iterator;
template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
template <class Container> class insert_iterator;
template <class Container, class Iterator>
insert_iterator<Container> inserter(Container& x, Iterator i);
template<class Iterator> struct _UCXXEXPORT iterator_traits {
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::value_type value_type;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::reference reference;
typedef typename Iterator::iterator_category iterator_category;
};
// Actual Template definitions
//Pointer specialization - required by standard
template<class T> struct _UCXXEXPORT iterator_traits<T*> {
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef random_access_iterator_tag iterator_category;
};
template<class Iterator> struct _UCXXEXPORT iterator_traits
{
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::value_type value_type;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::reference reference;
typedef typename Iterator::iterator_category iterator_category;
};
//Specialization recomended by standard
/* template<class T> struct _UCXXEXPORT iterator_traits<T __far*> {
typedef long difference_type;
typedef T value_type;
typedef T __far* pointer;
typedef T __far& reference;
typedef random_access_iterator_tag iterator_category;
};*/
//Pointer specialization - required by standard
/* template <class BidirectionalIterator> _UCXXEXPORT void
reverse(BidirectionalIterator first, BidirectionalIterator last)
{
typename iterator_traits<BidirectionalIterator>::difference_type n = distance(first, last);
--n;
while(n > 0){
typename iterator_traits<BidirectionalIterator>::value_type tmp = *first;
*first++ = * --last;
*last = tmp;
n -= 2;
}
};*/
template<class T> struct _UCXXEXPORT iterator_traits<T*>
{
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef random_access_iterator_tag iterator_category;
};
//Specialization recomended by standard
/* template<class T> struct _UCXXEXPORT iterator_traits<T __far*>
{
typedef long difference_type;
typedef T value_type;
typedef T __far* pointer;
typedef T __far& reference;
typedef random_access_iterator_tag iterator_category;
};*/
/* template <class BidirectionalIterator> _UCXXEXPORT void
reverse(BidirectionalIterator first, BidirectionalIterator last)
{
typename iterator_traits<BidirectionalIterator>::difference_type n = distance(first, last);
--n;
while(n > 0)
{
typename iterator_traits<BidirectionalIterator>::value_type tmp = *first;
*first++ = * --last;
*last = tmp;
n -= 2;
}
};*/
template <class Category, class T, class Distance, class Pointer, class Reference>
struct _UCXXEXPORT iterator
{
typedef T value_type;
typedef Distance difference_type;
typedef Pointer pointer;
typedef Reference reference;
typedef Category iterator_category;
};
template <class Category, class T, class Distance, class Pointer, class Reference>
struct _UCXXEXPORT iterator
{
typedef T value_type;
typedef Distance difference_type;
typedef Pointer pointer;
typedef Reference reference;
typedef Category iterator_category;
};
template <class Iterator> class _UCXXEXPORT reverse_iterator
: public iterator<typename iterator_traits<Iterator>::iterator_category,
typename iterator_traits<Iterator>::value_type, typename iterator_traits<Iterator>::difference_type,
typename iterator_traits<Iterator>::pointer, typename iterator_traits<Iterator>::reference>
{
protected:
Iterator current;
friend bool operator== <Iterator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
friend bool operator< <Iterator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
public:
typedef Iterator iterator_type;
template <class Iterator> class _UCXXEXPORT reverse_iterator
: public iterator<typename iterator_traits<Iterator>::iterator_category,
typename iterator_traits<Iterator>::value_type, typename iterator_traits<Iterator>::difference_type,
typename iterator_traits<Iterator>::pointer, typename iterator_traits<Iterator>::reference>
{
protected:
Iterator current;
friend bool operator== <Iterator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
friend bool operator< <Iterator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y);
reverse_iterator() : current(){};
explicit reverse_iterator(Iterator x) : current(x) { }
template<class U> reverse_iterator(const reverse_iterator<U> &x) : current(x.base()){}
public:
typedef Iterator iterator_type;
Iterator base() const { return current; } // explicit
reverse_iterator() : current(){};
explicit reverse_iterator(Iterator x) : current(x) { }
template<class U> reverse_iterator(const reverse_iterator<U> &x) : current(x.base()){}
typename iterator_traits<Iterator>::reference operator*() const { Iterator tmp = current; return *--tmp; }
typename iterator_traits<Iterator>::pointer operator->() const { return &(operator*()); }
typename iterator_traits<Iterator>::reference operator[](typename iterator_traits<Iterator>::difference_type n) const
{
return current[-n-1];
}
Iterator base() const { return current; } // explicit
reverse_iterator& operator++(){ --current; return *this; }
reverse_iterator operator++(int) {reverse_iterator tmp = *this; --current; return tmp; }
reverse_iterator& operator--() { ++ current; return *this; }
reverse_iterator operator--(int) {reverse_iterator tmp = *this; ++current; return tmp; }
typename iterator_traits<Iterator>::reference operator*() const { Iterator tmp = current; return *--tmp; }
typename iterator_traits<Iterator>::pointer operator->() const { return &(operator*()); }
typename iterator_traits<Iterator>::reference operator[](typename iterator_traits<Iterator>::difference_type n) const{
return current[-n-1];
}
reverse_iterator operator+ (typename iterator_traits<Iterator>::difference_type n) const
{
reverse_iterator retval( *this );
retval+=n;
return retval;
}
reverse_iterator& operator++(){ --current; return *this; }
reverse_iterator operator++(int) {reverse_iterator tmp = *this; --current; return tmp; }
reverse_iterator& operator--() { ++ current; return *this; }
reverse_iterator operator--(int) {reverse_iterator tmp = *this; ++current; return tmp; }
reverse_iterator& operator+=(typename iterator_traits<Iterator>::difference_type n)
{
current -= n;
return *this;
}
reverse_iterator operator+ (typename iterator_traits<Iterator>::difference_type n) const{
reverse_iterator retval( *this );
retval+=n;
return retval;
}
reverse_iterator& operator+=(typename iterator_traits<Iterator>::difference_type n){
current -= n;
return *this;
}
reverse_iterator operator- (typename iterator_traits<Iterator>::difference_type n) const{
reverse_iterator retval( *this );
retval-=n;
return retval;
}
reverse_iterator& operator-=(typename iterator_traits<Iterator>::difference_type n){
current += n;
return *this;
}
};
reverse_iterator operator- (typename iterator_traits<Iterator>::difference_type n) const
{
reverse_iterator retval( *this );
retval-=n;
return retval;
}
reverse_iterator& operator-=(typename iterator_traits<Iterator>::difference_type n)
{
current += n;
return *this;
}
};
template <class Iterator> _UCXXEXPORT bool
operator==(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() == y.base();
}
template <class Iterator> _UCXXEXPORT bool
operator<(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() < y.base();
}
template <class Iterator> _UCXXEXPORT bool
operator!=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() != y.base();
}
template <class Iterator> _UCXXEXPORT bool
operator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() > y.base();
}
template <class Iterator> _UCXXEXPORT bool
operator>=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() >= y.base();
}
template <class Iterator> _UCXXEXPORT bool
operator<=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() <= y.base();
}
template <class Iterator> _UCXXEXPORT typename reverse_iterator<Iterator>::difference_type
operator-( const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return y.base() - x.base();
}
template <class Iterator> _UCXXEXPORT reverse_iterator<Iterator>
operator+(typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x)
{
return reverse_iterator<Iterator> (x.base() - n);
}
template <class Iterator> _UCXXEXPORT bool
operator==(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() == y.base();
}
template <class Container> class _UCXXEXPORT back_insert_iterator :
public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container& container;
public:
typedef Container container_type;
explicit back_insert_iterator(Container& x):container(x) {};
back_insert_iterator<Container>& operator=(const typename Container::value_type& value){
container.push_back(value);
return *this;
}
back_insert_iterator<Container>& operator*(){
return *this;
}
back_insert_iterator<Container>& operator++(){
return *this;
}
back_insert_iterator<Container> operator++(int){
return *this;
}
};
template <class Iterator> _UCXXEXPORT bool
operator<(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() < y.base();
}
template <class Container> _UCXXEXPORT back_insert_iterator<Container>
back_inserter(Container& x)
{
return back_insert_iterator<Container>(x);
}
template <class Iterator> _UCXXEXPORT bool
operator!=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() != y.base();
}
template <class Container> class _UCXXEXPORT front_insert_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container& container;
public:
typedef Container container_type;
explicit front_insert_iterator(Container& x): container(x) {}
front_insert_iterator<Container>& operator=(const typename Container::value_type& value){
container.push_front(value);
return *this;
}
template <class Iterator> _UCXXEXPORT bool
operator>(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() > y.base();
}
front_insert_iterator<Container>& operator*() { return *this; }
front_insert_iterator<Container>& operator++() { return *this; }
front_insert_iterator<Container> operator++(int) { return *this; }
};
template <class Iterator> _UCXXEXPORT bool
operator>=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() >= y.base();
}
template <class Container> _UCXXEXPORT front_insert_iterator<Container>
front_inserter(Container& x)
{
return front_insert_iterator<Container>(x);
}
template <class Iterator> _UCXXEXPORT bool
operator<=(const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return x.base() <= y.base();
}
template <class Container> class _UCXXEXPORT insert_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container& container;
typename Container::iterator iter;
public:
typedef Container container_type;
insert_iterator(Container& x, typename Container::iterator i) : container(x), iter(i) {}
insert_iterator<Container>& operator=(const typename Container::value_type& value){
iter = container.insert(iter, value);
++iter;
return *this;
}
insert_iterator<Container>& operator*() { return *this; }
insert_iterator<Container>& operator++() { return *this; }
insert_iterator<Container> operator++(int) { return *this; }
};
template <class Iterator> _UCXXEXPORT typename reverse_iterator<Iterator>::difference_type
operator-( const reverse_iterator<Iterator>& x, const reverse_iterator<Iterator>& y)
{
return y.base() - x.base();
}
template <class Container, class Iterator> _UCXXEXPORT insert_iterator<Container>
inserter(Container& x, Iterator i)
{
return insert_iterator<Container>(x,typename Container::iterator(i));
}
template <class Iterator> _UCXXEXPORT reverse_iterator<Iterator>
operator+(typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x)
{
return reverse_iterator<Iterator> (x.base() - n);
}
}
template <class Container> class _UCXXEXPORT back_insert_iterator :
public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container& container;
public:
typedef Container container_type;
explicit back_insert_iterator(Container& x):container(x) {};
back_insert_iterator<Container>& operator=(const typename Container::value_type& value)
{
container.push_back(value);
return *this;
}
back_insert_iterator<Container>& operator*()
{
return *this;
}
back_insert_iterator<Container>& operator++()
{
return *this;
}
back_insert_iterator<Container> operator++(int)
{
return *this;
}
};
template <class Container> _UCXXEXPORT back_insert_iterator<Container>
back_inserter(Container& x)
{
return back_insert_iterator<Container>(x);
}
template <class Container> class _UCXXEXPORT front_insert_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container& container;
public:
typedef Container container_type;
explicit front_insert_iterator(Container& x): container(x) {}
front_insert_iterator<Container>& operator=(const typename Container::value_type& value)
{
container.push_front(value);
return *this;
}
front_insert_iterator<Container>& operator*() { return *this; }
front_insert_iterator<Container>& operator++() { return *this; }
front_insert_iterator<Container> operator++(int) { return *this; }
};
template <class Container> _UCXXEXPORT front_insert_iterator<Container>
front_inserter(Container& x)
{
return front_insert_iterator<Container>(x);
}
template <class Container> class _UCXXEXPORT insert_iterator
: public iterator<output_iterator_tag,void,void,void,void>
{
protected:
Container& container;
typename Container::iterator iter;
public:
typedef Container container_type;
insert_iterator(Container& x, typename Container::iterator i) : container(x), iter(i) {}
insert_iterator<Container>& operator=(const typename Container::value_type& value)
{
iter = container.insert(iter, value);
++iter;
return *this;
}
insert_iterator<Container>& operator*() { return *this; }
insert_iterator<Container>& operator++() { return *this; }
insert_iterator<Container> operator++(int) { return *this; }
};
template <class Container, class Iterator> _UCXXEXPORT insert_iterator<Container>
inserter(Container& x, Iterator i)
{
return insert_iterator<Container>(x,typename Container::iterator(i));
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
#endif
#endif // __STD_HEADER_ITERATOR_BASE
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+192 -187
View File
@@ -1,63 +1,60 @@
/* Copyright (C) 2004-2007 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004-2007 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <memory>
#include <utility>
#include <iterator>
#include <associative_base>
#ifndef __STD_HEADER_MAP
#define __STD_HEADER_MAP
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class map;
template<class Key, class T, class Compare = less<Key>, class Allocator = allocator<T> > class multimap;
//Compare the keys of the two items
//Compare the keys of the two items
/* template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT
__base_map<Key, T, Compare, Allocator>::value_compare : public binary_function<
typename map<Key, T, Compare, Allocator>::value_type,
typename map<Key, T, Compare, Allocator>::value_type,
bool>
{
friend class __base_map<Key, T, Compare, Allocator>;
protected:
Compare comp;
value_compare(Compare c) : comp(c) { }
~value_compare() { }
public:
bool operator()(const value_type& x, const value_type& y) const {
return comp(x.first, y.first);
}
};
/* template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT
__base_map<Key, T, Compare, Allocator>::value_compare : public binary_function<
typename map<Key, T, Compare, Allocator>::value_type,
typename map<Key, T, Compare, Allocator>::value_type,
bool>
{
friend class __base_map<Key, T, Compare, Allocator>;
protected:
Compare comp;
value_compare(Compare c) : comp(c) { }
~value_compare() { }
public:
bool operator()(const value_type& x, const value_type& y) const
{
return comp(x.first, y.first);
}
};
*/
// value_compare value_comp() const;
// value_compare value_comp() const;
/* This is the implementation for the map container. As noted above, it deviates
* from ISO spec by deriving from a base class in order to reduce code redundancy.
@@ -66,199 +63,207 @@ template<class Key, class T, class Compare = less<Key>, class Allocator = alloca
* the specifications too much to be worth the risk.
*/
//Implementation of map
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT map
: public __single_associative<Key, pair<Key, T>, Compare, Allocator>
: public __single_associative<Key, pair<Key, T>, Compare, Allocator>
{
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
// Default value of allocator does not meet C++ standard specs, but it works for this library
// Deal with it
public:
typedef __single_associative<Key, pair<Key, T>, Compare, Allocator> base;
typedef T mapped_type;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
typedef __single_associative<Key, pair<Key, T>, Compare, Allocator> base;
typedef T mapped_type;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
static const key_type v_t_k(const value_type v){
return v.first;
}
static const key_type v_t_k(const value_type v)
{
return v.first;
}
// using base::value_compare;
// using base::value_compare;
explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
template <class InputIterator> map(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
template <class InputIterator> map(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
map(const map<Key,T,Compare,Allocator>& x) : base(x) { }
~map() { }
map(const map<Key,T,Compare,Allocator>& x) : base(x) { }
~map() { }
using base::operator=;
using base::operator==;
using base::operator!=;
using base::operator=;
using base::operator==;
using base::operator!=;
using base::insert;
using base::erase;
using base::insert;
using base::erase;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::empty;
using base::size;
using base::max_size;
using base::empty;
using base::size;
using base::max_size;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
using base::swap;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
using base::swap;
reference operator[](const key_type& k){
iterator i = lower_bound(k);
if (i == end() || base::c(k, i->first)) {
i = insert(make_pair(k, T())).first;
}
return i->second;
}
reference operator[](const key_type& k)
{
iterator i = lower_bound(k);
if (i == end() || base::c(k, i->first))
{
i = insert(make_pair(k, T())).first;
}
return i->second;
}
protected:
using base::backing;
using base::backing;
};
//Implementation of multimap
// Implementation of multimap
template<class Key, class T, class Compare, class Allocator> class _UCXXEXPORT multimap
: public __multi_associative<Key, pair<Key, T>, Compare, Allocator>
: public __multi_associative<Key, pair<Key, T>, Compare, Allocator>
{
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
// Default value of allocator does not meet C++ standard specs, but it works for this library
// Deal with it
public:
typedef __multi_associative<Key, pair<Key, T>, Compare, Allocator> base;
typedef T mapped_type;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
typedef __multi_associative<Key, pair<Key, T>, Compare, Allocator> base;
typedef T mapped_type;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
static const key_type v_t_k(const value_type v){
return v.first;
}
static const key_type v_t_k(const value_type v)
{
return v.first;
}
explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
template <class InputIterator> multimap(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
template <class InputIterator> multimap(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
multimap(const multimap<Key,T,Compare,Allocator>& x) : base(x) { }
~multimap() { }
multimap(const multimap<Key,T,Compare,Allocator>& x) : base(x) { }
~multimap() { }
using base::operator=;
using base::operator==;
using base::operator!=;
using base::operator=;
using base::operator==;
using base::operator!=;
using base::insert;
using base::erase;
using base::insert;
using base::erase;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::empty;
using base::size;
using base::max_size;
using base::empty;
using base::size;
using base::max_size;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
using base::swap;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
using base::swap;
protected:
using base::c;
using base::c;
};
/* Non-member functions. These are at the end because they are not associated with any
particular class. These will be implemented as I figure out exactly what all of
them are supposed to do, and I have time.
* particular class. These will be implemented as I figure out exactly what all of
* them are supposed to do, and I have time.
*/
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator==
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
}
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const map<Key,T,Compare,Allocator>& x, const map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
(map<Key,T,Compare,Allocator>& x, map<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator==
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const multimap<Key,T,Compare,Allocator>& x, const multimap<Key,T,Compare,Allocator>& y);
template <class Key, class T, class Compare, class Allocator> _UCXXEXPORT void swap
(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y);
} // namespace
} // extern "C++"
#pragma GCC visibility pop
#endif
+191 -143
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <new>
#include <cstddef>
@@ -29,166 +29,214 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
template <class T> class allocator;
// Specialize for void:
// Specialize for void:
template <> class _UCXXEXPORT allocator<void> {
template <> class _UCXXEXPORT allocator<void>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class U> struct rebind { typedef allocator<U> other; };
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class U> struct rebind { typedef allocator<U> other; };
};
template <class T> class _UCXXEXPORT allocator{
template <class T> class _UCXXEXPORT allocator
{
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T& reference;
typedef const T& const_reference;
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
allocator() throw(){}
template <class U> allocator(const allocator<U>& ) throw();
~allocator() throw(){}
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
allocator() throw(){}
template <class U> allocator(const allocator<U>& ) throw();
~allocator() throw(){}
//Space for n Ts
pointer allocate(size_type n, typename allocator<void>::const_pointer = 0){
return (T*)(::operator new( n * sizeof(T) ));
}
void deallocate(pointer p, size_type){
::operator delete(p);
}
// Space for n Ts
//Use placement new to engage the constructor
void construct(pointer p, const T& val) { new((void*)p) T(val); }
void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor
pointer allocate(size_type n, typename allocator<void>::const_pointer = 0)
{
return (T*)(::operator new( n * sizeof(T) ));
}
size_type max_size() const throw();
template<class U> struct rebind { typedef allocator<U> other; };
void deallocate(pointer p, size_type)
{
::operator delete(p);
}
// Use placement new to engage the constructor
void construct(pointer p, const T& val) { new((void*)p) T(val); }
void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor
size_type max_size() const throw();
template<class U> struct rebind { typedef allocator<U> other; };
};
template <class Out, class T> class _UCXXEXPORT raw_storage_iterator
: public iterator<output_iterator_tag, void, void, void, void>
: public iterator<output_iterator_tag, void, void, void, void>
{
Out p;
Out p;
public:
explicit raw_storage_iterator(Out pp) : p (pp) { }
raw_storage_iterator & operator*() { return *this; }
raw_storage_iterator & operator=(const T& val) {
T* pp = &*p;
new(pp) T(val);
return *this;
}
explicit raw_storage_iterator(Out pp) : p (pp) { }
raw_storage_iterator & operator*() { return *this; }
raw_storage_iterator & operator++() { ++p; return *this; }
raw_storage_iterator operator++(int) {
raw_storage_iterator t = *this;
++p;
return t;
}
raw_storage_iterator & operator=(const T& val)
{
T* pp = &*p;
new(pp) T(val);
return *this;
}
raw_storage_iterator & operator++() { ++p; return *this; }
raw_storage_iterator operator++(int)
{
raw_storage_iterator t = *this;
++p;
return t;
}
};
template <class T> _UCXXEXPORT pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n){
pair<T*, ptrdiff_t> retval;
retval.first = static_cast<T*>(malloc(n * sizeof(T)));
if(retval.first == 0){
retval.second = 0;
}else{
retval.second = n;
}
return retval;
template <class T> _UCXXEXPORT pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n)
{
pair<T*, ptrdiff_t> retval;
retval.first = static_cast<T*>(malloc(n * sizeof(T)));
if (retval.first == 0)
{
retval.second = 0;
}
else
{
retval.second = n;
}
return retval;
}
template <class T> _UCXXEXPORT void return_temporary_buffer(T* p){
free(p);
template <class T> _UCXXEXPORT void return_temporary_buffer(T* p)
{
free(p);
}
template <class T> class _UCXXEXPORT auto_ptr{
template <class T> class _UCXXEXPORT auto_ptr
{
private:
T * object;
template <class Y> struct auto_ptr_ref{
Y * p;
};
T * object;
template <class Y> struct auto_ptr_ref
{
Y * p;
};
public:
typedef T element_type;
typedef T element_type;
explicit auto_ptr(T* p =0) throw() : object(p){ }
auto_ptr(auto_ptr& p) throw() : object(p.release()){ }
auto_ptr(auto_ptr_ref<T> r) throw() : object(r.p){
r.p = 0;
}
template<class Y> auto_ptr(auto_ptr<Y>& p) throw() : object(p.release()){ }
auto_ptr& operator=(auto_ptr& p) throw(){
if(&p == this){
return *this;
}
delete object;
object = p.release();
return *this;
}
template<class Y> auto_ptr& operator=(auto_ptr<Y>& p) throw(){
if(&p == this){
return *this;
}
delete object;
object = p.release();
return *this;
}
~auto_ptr(){
delete object;
}
explicit auto_ptr(T* p =0) throw() : object(p){ }
auto_ptr(auto_ptr& p) throw() : object(p.release()){ }
T& operator*() const throw(){
return *object;
}
T* operator->() const throw(){
return object;
}
T* get() const throw(){
return object;
}
T* release() throw(){
T * temp(object);
object = 0;
return temp;
}
void reset(T * p=0) throw(){
if(p != object){
delete object;
object = p;
}
}
template<class Y> operator auto_ptr_ref<Y>() throw(){
auto_ptr_ref<Y> retval;
retval.p = object;
object = 0;
return retval;
}
template<class Y> operator auto_ptr<Y>() throw(){
auto_ptr<Y> retval(object);
object = 0;
return retval;
}
auto_ptr(auto_ptr_ref<T> r) throw() : object(r.p)
{
r.p = 0;
}
template<class Y> auto_ptr(auto_ptr<Y>& p) throw() : object(p.release()){ }
auto_ptr& operator=(auto_ptr& p) throw()
{
if (&p == this)
{
return *this;
}
delete object;
object = p.release();
return *this;
}
template<class Y> auto_ptr& operator=(auto_ptr<Y>& p) throw()
{
if (&p == this)
{
return *this;
}
delete object;
object = p.release();
return *this;
}
~auto_ptr()
{
delete object;
}
T& operator*() const throw()
{
return *object;
}
T* operator->() const throw()
{
return object;
}
T* get() const throw()
{
return object;
}
T* release() throw()
{
T * temp(object);
object = 0;
return temp;
}
void reset(T * p=0) throw()
{
if(p != object)
{
delete object;
object = p;
}
}
template<class Y> operator auto_ptr_ref<Y>() throw()
{
auto_ptr_ref<Y> retval;
retval.p = object;
object = 0;
return retval;
}
template<class Y> operator auto_ptr<Y>() throw()
{
auto_ptr<Y> retval(object);
object = 0;
return retval;
}
};
} //namespace std
} // namespace std
} // extern "C++"
#pragma GCC visibility pop
+34 -29
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* * Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/
#include <basic_definitions>
#include <exception>
@@ -26,16 +26,19 @@
#pragma GCC visibility push(default)
namespace std{
class _UCXXEXPORT bad_alloc : public exception {};
extern "C++"
{
struct _UCXXEXPORT nothrow_t {};
extern const nothrow_t nothrow;
namespace std
{
class _UCXXEXPORT bad_alloc : public exception {};
typedef void (*new_handler)();
_UCXXEXPORT new_handler set_new_handler(new_handler new_p) throw();
}
struct _UCXXEXPORT nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
_UCXXEXPORT new_handler set_new_handler(new_handler new_p) throw();
} // namespace
_UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc);
_UCXXEXPORT void operator delete(void* ptr) throw();
@@ -51,14 +54,16 @@ _UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) t
_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw();
#endif
/* Placement operators */
/* Placement operators */
inline void* operator new(std::size_t, void* ptr) throw() {return ptr; }
inline void operator delete(void* , void *) throw() { }
inline void* operator new[](std::size_t, void *p) throw() { return p; }
inline void operator delete[](void* , void *) throw() {}
} // extern "C++"
#pragma GCC visibility pop
#endif
#endif // __STD_NEW_OPERATOR
+156 -141
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <exception>
@@ -25,135 +25,150 @@
#pragma GCC visibility push(default)
namespace std{
template <class InputIterator, class T> _UCXXEXPORT
T accumulate(InputIterator first, InputIterator last, T init)
{
while(first != last){
init = init + *first;
++first;
}
return init;
}
extern "C++"
{
namespace std
{
template <class InputIterator, class T> _UCXXEXPORT
T accumulate(InputIterator first, InputIterator last, T init)
{
while (first != last)
{
init = init + *first;
++first;
}
template <class InputIterator, class T, class BinaryOperation> _UCXXEXPORT
T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op)
{
while(first != last){
init = binary_op(init, *first);
++first;
}
return init;
}
return init;
}
template <class InputIterator, class T, class BinaryOperation> _UCXXEXPORT
T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op)
{
while (first != last)
{
init = binary_op(init, *first);
++first;
}
return init;
}
template <class InputIterator1, class InputIterator2, class T> _UCXXEXPORT
T inner_product(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init)
{
while (first1 != last1)
{
init = init + *first1 * *first2;
++first1;
++first2;
}
return init;
}
template <class InputIterator1, class InputIterator2, class T,
class BinaryOperation1, class BinaryOperation2> _UCXXEXPORT
T inner_product(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init,
BinaryOperation1 binary_op1,
BinaryOperation2 binary_op2)
{
while (first1 != last1)
{
init = binary_op1(init, binary_op2(*first1, *first2));
++first1;
++first2;
}
return init;
}
template <class InputIterator, class OutputIterator> _UCXXEXPORT
OutputIterator partial_sum(InputIterator first, InputIterator last,
OutputIterator result)
{
OutputIterator temp(result);
*result = *first;
++first;
++result;
while (first != last)
{
*result = *first + *temp;
temp = result;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
OutputIterator partial_sum(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op)
{
OutputIterator temp(result);
*result = *first;
++first;
++result;
while(first != last)
{
*result = binary_op(*first, *temp);
temp = result;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator> _UCXXEXPORT
OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
OutputIterator result)
{
OutputIterator temp(first);
*result = *first;
++first;
++result;
while(first != last)
{
*result = *first - *temp;
temp = first;
++first;
++result;
}
return result;
}
template <class InputIterator1, class InputIterator2, class T> _UCXXEXPORT
T inner_product(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init)
{
while(first1 != last1){
init = init + *first1 * *first2;
++first1;
++first2;
}
return init;
}
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op)
{
OutputIterator temp(first);
*result = *first;
++first;
++result;
template <class InputIterator1, class InputIterator2, class T,
class BinaryOperation1, class BinaryOperation2> _UCXXEXPORT
T inner_product(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init,
BinaryOperation1 binary_op1,
BinaryOperation2 binary_op2)
{
while(first1 != last1){
init = binary_op1(init, binary_op2(*first1, *first2));
++first1;
++first2;
}
return init;
}
while(first != last)
{
*result = binary_op(*first, *temp);
temp = first;
++first;
++result;
}
template <class InputIterator, class OutputIterator> _UCXXEXPORT
OutputIterator partial_sum(InputIterator first, InputIterator last,
OutputIterator result)
{
OutputIterator temp(result);
*result = *first;
++first;
++result;
return result;
}
while(first != last){
*result = *first + *temp;
temp = result;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
OutputIterator partial_sum(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op)
{
OutputIterator temp(result);
*result = *first;
++first;
++result;
while(first != last){
*result = binary_op(*first, *temp);
temp = result;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator> _UCXXEXPORT
OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
OutputIterator result)
{
OutputIterator temp(first);
*result = *first;
++first;
++result;
while(first != last){
*result = *first - *temp;
temp = first;
++first;
++result;
}
return result;
}
template <class InputIterator, class OutputIterator, class BinaryOperation> _UCXXEXPORT
OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
OutputIterator result, BinaryOperation binary_op)
{
OutputIterator temp(first);
*result = *first;
++first;
++result;
while(first != last){
*result = binary_op(*first, *temp);
temp = first;
++first;
++result;
}
return result;
}
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+460 -397
View File
@@ -1,20 +1,20 @@
/* Copyright (C) 2004-2008 Garrett A. Kajmowicz
/* Copyright (C) 2004-2008 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
@@ -30,479 +30,542 @@
#pragma GCC visibility push(default)
namespace std {
template <class charT, class traits > class basic_ostream;
typedef basic_ostream<char> ostream;
extern "C++"
{
namespace std
{
template <class charT, class traits > class basic_ostream;
typedef basic_ostream<char> ostream;
#ifdef __UCLIBCXX_HAS_WCHAR__
typedef basic_ostream<wchar_t> wostream;
typedef basic_ostream<wchar_t> wostream;
#endif
template <class charT, class traits> basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
template <class charT, class traits> basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
template <class charT, class traits> basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
template <class charT, class traits> basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
template <class charT, class traits> basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
template <class charT, class traits> basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
template <class charT, class traits > class _UCXXEXPORT basic_ostream
: virtual public basic_ios<charT,traits>
{
public:
template <class charT, class traits > class _UCXXEXPORT basic_ostream
: virtual public basic_ios<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef traits traits_type;
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef traits traits_type;
_UCXXEXPORT basic_ostream(basic_streambuf<charT,traits>* sb)
: basic_ios<charT, traits>(sb)
{
basic_ios<charT,traits>::init(sb);
}
_UCXXEXPORT basic_ostream(basic_streambuf<charT,traits>* sb)
: basic_ios<charT, traits>(sb)
{
basic_ios<charT,traits>::init(sb);
}
virtual _UCXXEXPORT ~basic_ostream();
virtual _UCXXEXPORT ~basic_ostream();
class sentry;
class sentry;
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&)){
return pf(*this);
}
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&)){
pf(*this);
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&)){
pf(*this);
return *this;
}
basic_ostream<charT,traits>& operator<<(bool n);
basic_ostream<charT,traits>& operator<<(short n);
basic_ostream<charT,traits>& operator<<(unsigned short n);
basic_ostream<charT,traits>& operator<<(int n);
basic_ostream<charT,traits>& operator<<(unsigned int n);
basic_ostream<charT,traits>& operator<<(long n);
basic_ostream<charT,traits>& operator<<(unsigned long n);
basic_ostream<charT,traits>& operator<<(float f);
basic_ostream<charT,traits>& operator<<(double f);
basic_ostream<charT,traits>& operator<<(long double f);
basic_ostream<charT,traits>& operator<<(void* p);
basic_ostream<charT,traits>& operator<<(basic_streambuf<char_type,traits>* sb);
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&))
{
return pf(*this);
}
_UCXXEXPORT basic_ostream<charT,traits>& put(char_type c){
if(basic_ostream<charT,traits>::traits_type::eq_int_type(
basic_ios<charT, traits>::mstreambuf->sputc(c),
basic_ostream<charT,traits>::traits_type::eof()))
{
basic_ios<charT,traits>::setstate(ios_base::eofbit);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& write(const char_type* s, streamsize n){
if(basic_ostream<charT,traits>::traits_type::eq_int_type(
basic_ios<charT, traits>::mstreambuf->sputn(s, n),
basic_ostream<charT,traits>::traits_type::eof())
){
basic_ios<charT,traits>::setstate(ios_base::eofbit);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& flush(){
if(basic_ios<charT, traits>::mstreambuf->pubsync() == -1){
basic_ios<charT,traits>::setstate(ios_base::badbit);
}
return *this;
}
_UCXXEXPORT pos_type tellp(){
if(basic_ios<charT,traits>::fail() != false){
return pos_type(-1);
}
return basic_ios<charT,traits>::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
}
_UCXXEXPORT basic_ostream<charT,traits>& seekp(pos_type pos){
if( basic_ios<charT,traits>::fail() != true ){
basic_ios<charT,traits>::rdbuf()->pubseekpos(pos);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir){
if( basic_ios<charT,traits>::fail() != true){
basic_ios<charT,traits>::rdbuf()->pubseekoff(off, dir);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>& (*pf)(basic_ios<charT,traits>&))
{
pf(*this);
return *this;
}
_UCXXEXPORT void printout(const char_type* s, streamsize n){
_UCXXEXPORT basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&))
{
pf(*this);
return *this;
}
basic_ostream<charT,traits>& operator<<(bool n);
basic_ostream<charT,traits>& operator<<(short n);
basic_ostream<charT,traits>& operator<<(unsigned short n);
basic_ostream<charT,traits>& operator<<(int n);
basic_ostream<charT,traits>& operator<<(unsigned int n);
basic_ostream<charT,traits>& operator<<(long n);
basic_ostream<charT,traits>& operator<<(unsigned long n);
basic_ostream<charT,traits>& operator<<(float f);
basic_ostream<charT,traits>& operator<<(double f);
basic_ostream<charT,traits>& operator<<(long double f);
basic_ostream<charT,traits>& operator<<(void* p);
basic_ostream<charT,traits>& operator<<(basic_streambuf<char_type,traits>* sb);
_UCXXEXPORT basic_ostream<charT,traits>& put(char_type c)
{
if (basic_ostream<charT,traits>::traits_type::eq_int_type(
basic_ios<charT, traits>::mstreambuf->sputc(c),
basic_ostream<charT,traits>::traits_type::eof()))
{
basic_ios<charT,traits>::setstate(ios_base::eofbit);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& write(const char_type* s, streamsize n)
{
if (basic_ostream<charT,traits>::traits_type::eq_int_type(
basic_ios<charT, traits>::mstreambuf->sputn(s, n),
basic_ostream<charT,traits>::traits_type::eof())
)
{
basic_ios<charT,traits>::setstate(ios_base::eofbit);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& flush()
{
if (basic_ios<charT, traits>::mstreambuf->pubsync() == -1)
{
basic_ios<charT,traits>::setstate(ios_base::badbit);
}
return *this;
}
_UCXXEXPORT pos_type tellp()
{
if (basic_ios<charT,traits>::fail() != false)
{
return pos_type(-1);
}
return basic_ios<charT,traits>::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
}
_UCXXEXPORT basic_ostream<charT,traits>& seekp(pos_type pos)
{
if (basic_ios<charT,traits>::fail() != true)
{
basic_ios<charT,traits>::rdbuf()->pubseekpos(pos);
}
return *this;
}
_UCXXEXPORT basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir)
{
if (basic_ios<charT,traits>::fail() != true)
{
basic_ios<charT,traits>::rdbuf()->pubseekoff(off, dir);
}
return *this;
}
_UCXXEXPORT void printout(const char_type* s, streamsize n)
{
//david
streamsize extra = ios::width() - n;
if ((ios::flags()&ios::adjustfield) == ios::right){
while (extra > 0) {
--extra;
put(ios::fill());
}
}
write(s, n);
if ((ios::flags()&ios::adjustfield) == ios::left) {
while (extra > 0) {
--extra;
put(ios::fill());
}
}
// Width value only applies for the next output operation. Reset to zero.
ios::width(0);
}
streamsize extra = ios::width() - n;
if ((ios::flags()&ios::adjustfield) == ios::right)
{
while (extra > 0)
{
--extra;
put(ios::fill());
}
}
protected:
basic_ostream(const basic_ostream<charT,traits> &){ }
basic_ostream<charT,traits> & operator=(const basic_ostream<charT,traits> &){ return *this; }
};
write(s, n);
if ((ios::flags()&ios::adjustfield) == ios::left)
{
while (extra > 0)
{
--extra;
put(ios::fill());
}
}
//Implementations of template functions. To allow for partial specialization
// Width value only applies for the next output operation. Reset to zero.
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>::~basic_ostream(){ }
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(bool n){
sentry s(*this);
if( basic_ios<charT,traits>::flags() & ios_base::boolalpha){
if(n){
printout("true", 4);
}else{
printout("false", 5);
}
}else{
if(n){
printout("1", 1);
}else{
printout("0", 1);
}
}
if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
flush();
}
return *this;
}
ios::width(0);
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
basic_ostream<charT, traits>::operator<<(unsigned short n){
sentry s(*this);
__ostream_printout<traits, charT, unsigned long int>::printout(*this, n);
return *this;
}
protected:
basic_ostream(const basic_ostream<charT,traits> &){ }
basic_ostream<charT,traits> & operator=(const basic_ostream<charT,traits> &){ return *this; }
};
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(short n){
sentry s(*this);
__ostream_printout<traits, charT, long int>::printout(*this, n);
return *this;
}
// Implementations of template functions. To allow for partial specialization
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(int n){
sentry s(*this);
__ostream_printout<traits, charT, long int>::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>::~basic_ostream(){ }
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(bool n)
{
sentry s(*this);
if (basic_ios<charT,traits>::flags() & ios_base::boolalpha)
{
if (n)
{
printout("true", 4);
}
else
{
printout("false", 5);
}
}
else
{
if (n)
{
printout("1", 1);
}
else
{
printout("0", 1);
}
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(unsigned int n){
sentry s(*this);
__ostream_printout<traits, charT, unsigned long int>::printout(*this, n);
return *this;
}
if (basic_ios<charT,traits>::flags() & ios_base::unitbuf)
{
flush();
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long n){
sentry s(*this);
__ostream_printout<traits, charT, long >::printout(*this, n);
return *this;
}
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
basic_ostream<charT, traits>::operator<<(unsigned long n)
{
sentry s(*this);
__ostream_printout<traits, charT, unsigned long >::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
basic_ostream<charT, traits>::operator<<(unsigned short n)
{
sentry s(*this);
__ostream_printout<traits, charT, unsigned long int>::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(float f){
sentry s(*this);
__ostream_printout<traits, charT, double >::printout(*this, f);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(short n)
{
sentry s(*this);
__ostream_printout<traits, charT, long int>::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(double f){
sentry s(*this);
__ostream_printout<traits, charT, double >::printout(*this, f);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(int n)
{
sentry s(*this);
__ostream_printout<traits, charT, long int>::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long double f){
sentry s(*this);
__ostream_printout<traits, charT, long double >::printout(*this, f);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(unsigned int n)
{
sentry s(*this);
__ostream_printout<traits, charT, unsigned long int>::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(void* p){
sentry s(*this);
char buffer[20];
printout(buffer, snprintf(buffer, 20, "%p", p) );
if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
flush();
}
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long n)
{
sentry s(*this);
__ostream_printout<traits, charT, long >::printout(*this, n);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
basic_ostream<charT, traits>::operator<<(basic_streambuf<charT,traits>* sb)
{
sentry s(*this);
if(sb == 0){
basic_ios<charT,traits>::setstate(ios_base::badbit);
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
basic_ostream<charT, traits>::operator<<(unsigned long n)
{
sentry s(*this);
__ostream_printout<traits, charT, unsigned long >::printout(*this, n);
return *this;
}
typename traits::int_type c;
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(float f)
{
sentry s(*this);
__ostream_printout<traits, charT, double >::printout(*this, f);
return *this;
}
while(basic_ios<charT,traits>::good() && (c = sb->sbumpc()) != traits::eof() ){
put(c);
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(double f)
{
sentry s(*this);
__ostream_printout<traits, charT, double >::printout(*this, f);
return *this;
}
if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
flush();
}
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long double f)
{
sentry s(*this);
__ostream_printout<traits, charT, long double >::printout(*this, f);
return *this;
}
/*Template Specializations*/
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(void* p)
{
sentry s(*this);
char buffer[20];
printout(buffer, snprintf(buffer, 20, "%p", p));
if (basic_ios<charT,traits>::flags() & ios_base::unitbuf)
{
flush();
}
return *this;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
basic_ostream<charT, traits>::operator<<(basic_streambuf<charT,traits>* sb)
{
sentry s(*this);
if (sb == 0)
{
basic_ios<charT,traits>::setstate(ios_base::badbit);
return *this;
}
typename traits::int_type c;
while (basic_ios<charT,traits>::good() && (c = sb->sbumpc()) != traits::eof())
{
put(c);
}
if (basic_ios<charT,traits>::flags() & ios_base::unitbuf)
{
flush();
}
return *this;
}
/* Template Specializations */
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
#ifndef __UCLIBCXX_COMPILE_OSTREAM__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT ostream::~basic_ostream();
template <> _UCXXEXPORT ostream::~basic_ostream();
#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT ostream & ostream::flush();
template <> _UCXXEXPORT ostream & ostream::flush();
template <> _UCXXEXPORT ostream & ostream::operator<<(bool n);
template <> _UCXXEXPORT ostream & ostream::operator<<(short int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(long n);
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned long n);
template <> _UCXXEXPORT ostream & ostream::operator<<(float f);
template <> _UCXXEXPORT ostream & ostream::operator<<(double f);
template <> _UCXXEXPORT ostream & ostream::operator<<(long double f);
template <> _UCXXEXPORT ostream & ostream::operator<<(void* p);
template <> _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf<char, char_traits<char> >* sb);
template <> _UCXXEXPORT ostream & ostream::operator<<(bool n);
template <> _UCXXEXPORT ostream & ostream::operator<<(short int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned int n);
template <> _UCXXEXPORT ostream & ostream::operator<<(long n);
template <> _UCXXEXPORT ostream & ostream::operator<<(unsigned long n);
template <> _UCXXEXPORT ostream & ostream::operator<<(float f);
template <> _UCXXEXPORT ostream & ostream::operator<<(double f);
template <> _UCXXEXPORT ostream & ostream::operator<<(long double f);
template <> _UCXXEXPORT ostream & ostream::operator<<(void* p);
template <> _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf<char, char_traits<char> >* sb);
#endif
#endif
template <class charT,class traits = char_traits<charT> >
class _UCXXEXPORT basic_ostream<charT,traits>::sentry
{
bool ok;
public:
explicit _UCXXEXPORT sentry(basic_ostream<charT,traits>& os): ok(true){
template <class charT,class traits = char_traits<charT> >
class _UCXXEXPORT basic_ostream<charT,traits>::sentry
{
bool ok;
public:
explicit _UCXXEXPORT sentry(basic_ostream<charT,traits>& os): ok(true){
//david
if(os.good() !=0){ //Prepare for output
}
//Flush any tied buffer
if(os.tie() !=0 ){
os.tie()->flush();
}
}
_UCXXEXPORT ~sentry() { }
_UCXXEXPORT operator bool() {
return ok;
}
};
if (os.good() !=0)
{
// Prepare for output
}
// Flush any tied buffer
if (os.tie() !=0)
{
os.tie()->flush();
}
}
_UCXXEXPORT ~sentry() { }
_UCXXEXPORT operator bool()
{
return ok;
}
};
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
#ifndef __UCLIBCXX_COMPILE_OSTREAM__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os);
template <> _UCXXEXPORT ostream::sentry::~sentry();
template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os);
template <> _UCXXEXPORT ostream::sentry::~sentry();
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
#endif
#endif
// Non - class functions
//Non - class functions
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, charT c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.put(c);
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, char c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.put(c);
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, charT c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.put(c);
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, char c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.put(c);
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, char c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.put(c);
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, char c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.put(c);
return out;
}
// signed and unsigned
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, signed char c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.put(c);
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, unsigned char c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.put(c);
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, const charT* c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.printout(c, traits::length(c) );
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, const char* c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.printout(c, char_traits<char>::length(c) );
return out;
}
//david
// partial specializations
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, const char* c)
{
//add by david
/* printf("hello\n");
int i;
for(i=0;i<traits::length(c);i++)
printf("%c",*(c+i));
traits::length(c);*/
typename basic_ostream<char,traits>::sentry s(out);
out.printout(c, traits::length(c));
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, signed char c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.put(c);
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, unsigned char c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.put(c);
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, const charT* c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.printout(c, traits::length(c));
return out;
}
template<class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& out, const char* c)
{
typename basic_ostream<charT,traits>::sentry s(out);
out.printout(c, char_traits<char>::length(c));
return out;
}
// partial specializations
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, const char* c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.printout(c, traits::length(c));
return out;
}
#ifdef __UCLIBCXX_HAS_WCHAR__
template<class traits> _UCXXEXPORT basic_ostream<wchar_t,traits>&
operator<<(basic_ostream<wchar_t,traits>& out, const char* c)
{
typename basic_ostream<wchar_t, traits>::sentry s(out);
size_t numChars = char_traits<char>::length(c);
wchar_t * temp = new wchar_t[numChars];
template<class traits> _UCXXEXPORT basic_ostream<wchar_t,traits>&
operator<<(basic_ostream<wchar_t,traits>& out, const char* c)
{
typename basic_ostream<wchar_t, traits>::sentry s(out);
size_t numChars = char_traits<char>::length(c);
wchar_t * temp = new wchar_t[numChars];
for(size_t i=0; i < numChars; ++i){
temp[i] = out.widen(c[i]);
}
for (size_t i=0; i < numChars; ++i)
{
temp[i] = out.widen(c[i]);
}
out.printout(temp, numChars);
return out;
}
out.printout(temp, numChars);
return out;
}
#endif
// signed and unsigned
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, const signed char* c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.printout(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, const unsigned char* c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.printout(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
return out;
}
// Signed and unsigned
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
endl(basic_ostream<charT,traits>& os)
{
typename basic_ostream<charT,traits>::sentry s(os);
os.put('\n');
os.flush();
return os;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, const signed char* c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.printout(reinterpret_cast<const char *>(c), traits::length(reinterpret_cast<const char *>(c)));
return out;
}
template<class traits> _UCXXEXPORT basic_ostream<char,traits>&
operator<<(basic_ostream<char,traits>& out, const unsigned char* c)
{
typename basic_ostream<char,traits>::sentry s(out);
out.printout(reinterpret_cast<const char *>(c), traits::length(reinterpret_cast<const char *>(c)));
return out;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
ends(basic_ostream<charT,traits>& os)
{
typename basic_ostream<charT,traits>::sentry s(os);
os.put(traits::eos());
return os;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
endl(basic_ostream<charT,traits>& os)
{
typename basic_ostream<charT,traits>::sentry s(os);
os.put('\n');
os.flush();
return os;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os){
typename basic_ostream<charT,traits>::sentry s(os);
os.flush();
return os;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>&
ends(basic_ostream<charT,traits>& os)
{
typename basic_ostream<charT,traits>::sentry s(os);
os.put(traits::eos());
return os;
}
template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os){
typename basic_ostream<charT,traits>::sentry s(os);
os.flush();
return os;
}
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
#ifndef __UCLIBCXX_COMPILE_OSTREAM__
template <> _UCXXEXPORT ostream & endl(ostream & os);
template <> _UCXXEXPORT ostream & flush(ostream & os);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, char c);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, const char* c);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned const char* c);
template <> _UCXXEXPORT ostream & endl(ostream & os);
template <> _UCXXEXPORT ostream & flush(ostream & os);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, char c);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, const char* c);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c);
template <> _UCXXEXPORT ostream & operator<<(ostream & out, unsigned const char* c);
#endif
#endif
#ifndef __STRICT_ANSI__
//Support for output of long long data types
// Support for output of long long data types
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, signed long long int i)
operator<<(basic_ostream<Ch, Tr>& os, signed long long int i)
{
typename basic_ostream<Ch, Tr>::sentry s(os);
__ostream_printout<Tr, Ch, signed long long int>::printout(os, i);
return os;
typename basic_ostream<Ch, Tr>::sentry s(os);
__ostream_printout<Tr, Ch, signed long long int>::printout(os, i);
return os;
}
template<class Ch, class Tr> _UCXXEXPORT basic_ostream<Ch, Tr>&
operator<<(basic_ostream<Ch, Tr>& os, unsigned long long int i)
operator<<(basic_ostream<Ch, Tr>& os, unsigned long long int i)
{
typename basic_ostream<Ch, Tr>::sentry s(os);
__ostream_printout<Tr, Ch, unsigned long long int>::printout(os, i);
return os;
typename basic_ostream<Ch, Tr>::sentry s(os);
__ostream_printout<Tr, Ch, unsigned long long int>::printout(os, i);
return os;
}
#endif //__STRICT_ANSI__
#endif //__STRICT_ANSI__
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
File diff suppressed because it is too large Load Diff
+115 -102
View File
@@ -1,19 +1,20 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <deque>
@@ -25,102 +26,114 @@
#pragma GCC visibility push(default)
namespace std{
template <class T, class Container = deque<T> > class _UCXXEXPORT queue{
protected:
Container c;
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
extern "C++"
{
namespace std
{
template <class T, class Container = deque<T> > class _UCXXEXPORT queue
{
protected:
Container c;
explicit queue(const Container& a = Container()) : c(a) { }
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
value_type& front() { return c.front(); }
const value_type& front() const { return c.front(); }
value_type& back() { return c.back(); }
const value_type& back() const { return c.back(); }
void push(const value_type& x) { c.push_back(x); }
void pop() { c.pop_front(); }
};
explicit queue(const Container& a = Container()) : c(a) { }
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
value_type& front() { return c.front(); }
const value_type& front() const { return c.front(); }
value_type& back() { return c.back(); }
const value_type& back() const { return c.back(); }
void push(const value_type& x) { c.push_back(x); }
void pop() { c.pop_front(); }
};
template <class T, class Container> _UCXXEXPORT bool
operator==(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c == y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator< (const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c < y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator!=(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c != y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator> (const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c > y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator>=(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c >= y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator<=(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c <= y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator==(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c == y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator< (const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c < y.c);
}
template <class T,
class Container = vector<T>,
class Compare = less<typename Container::value_type>
> class _UCXXEXPORT priority_queue {
protected:
Container c;
Compare comp;
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
template <class T, class Container> _UCXXEXPORT bool
operator!=(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c != y.c);
}
explicit priority_queue(const Compare& x = Compare(), const Container& a = Container())
: c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; }
template <class InputIterator> priority_queue(InputIterator first,
InputIterator last,
const Compare& x = Compare(),
const Container& y= Container())
: c(y), comp(c)
{
c.insert(c.end(), first, last);
make_heap(c.begin(), c.end(), comp);
}
template <class T, class Container> _UCXXEXPORT bool
operator> (const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c > y.c);
}
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
const value_type& top() const { return c.front(); }
void push(const value_type& x){
c.push_back(x);
push_heap(c.begin(), c.end(), comp);
}
void pop(){
pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
};
template <class T, class Container> _UCXXEXPORT bool
operator>=(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c >= y.c);
}
}
template <class T, class Container> _UCXXEXPORT bool
operator<=(const queue<T, Container>& x, const queue<T, Container>& y)
{
return (x.c <= y.c);
}
template <class T,
class Container = vector<T>,
class Compare = less<typename Container::value_type>
> class _UCXXEXPORT priority_queue
{
protected:
Container c;
Compare comp;
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
explicit priority_queue(const Compare& x = Compare(), const Container& a = Container())
: c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; }
template <class InputIterator> priority_queue(InputIterator first,
InputIterator last,
const Compare& x = Compare(),
const Container& y= Container())
: c(y), comp(c)
{
c.insert(c.end(), first, last);
make_heap(c.begin(), c.end(), comp);
}
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
const value_type& top() const { return c.front(); }
void push(const value_type& x)
{
c.push_back(x);
push_heap(c.begin(), c.end(), comp);
}
void pop()
{
pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
};
} // namespace
} // extern "C++"
#pragma GCC visibility pop
#endif
+359 -316
View File
@@ -1,22 +1,20 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include<memory>
#include<utility>
@@ -30,13 +28,14 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class set;
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class multiset;
/* This is the implementation for the set container. As noted above, it deviates
* from ISO spec by deriving from a base class in order to reduce code redundancy.
* More code could be reduced by convirting to virtual functions (thus allowing
@@ -44,361 +43,405 @@ template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>
* the specifications too much to be worth the risk.
*/
//Implementation of set
// Implementation of set
template<class Key, class Compare, class Allocator> class _UCXXEXPORT set
: public __single_associative<Key, Key, Compare, Allocator>
: public __single_associative<Key, Key, Compare, Allocator>
{
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
public:
typedef __single_associative<Key, Key, Compare, Allocator> base;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
typedef __single_associative<Key, Key, Compare, Allocator> base;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
// using base::value_compare;
// using base::value_compare;
static const key_type v_t_k(const value_type v)
{
return v;
}
static const key_type v_t_k(const value_type v){
return v;
}
explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
template <class InputIterator> set(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
template <class InputIterator> set(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
set(const set<Key, Compare,Allocator>& x) : base(x) { }
~set() { }
set(const set<Key, Compare,Allocator>& x) : base(x) { }
~set() { }
using base::operator=;
using base::operator==;
using base::operator!=;
using base::operator=;
using base::operator==;
using base::operator!=;
using base::insert;
using base::erase;
using base::insert;
using base::erase;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::empty;
using base::size;
using base::max_size;
using base::empty;
using base::size;
using base::max_size;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
protected:
};
//Implementation of multiset
// Implementation of multiset
template<class Key, class Compare, class Allocator> class _UCXXEXPORT multiset
: public __multi_associative<Key, Key, Compare, Allocator>
: public __multi_associative<Key, Key, Compare, Allocator>
{
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
//Default value of allocator does not meet C++ standard specs, but it works for this library
//Deal with it
public:
typedef __multi_associative<Key, Key, Compare, Allocator> base;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
typedef __multi_associative<Key, Key, Compare, Allocator> base;
typedef typename base::key_type key_type;
typedef typename base::value_type value_type;
typedef typename base::key_compare key_compare;
typedef typename base::allocator_type allocator_type;
typedef typename base::reference reference;
typedef typename base::const_reference const_reference;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
typedef typename base::size_type size_type;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reverse_iterator reverse_iterator;
typedef typename base::const_reverse_iterator const_reverse_iterator;
static const key_type v_t_k(const value_type v)
{
return v;
}
static const key_type v_t_k(const value_type v){
return v;
}
explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(comp, al, v_t_k) { }
template <class InputIterator> multiset(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
template <class InputIterator> multiset(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& al = Allocator())
: base(first, last, comp, al, v_t_k) { }
multiset(const multiset<Key, Compare, Allocator>& x) : base(x) { }
~multiset() { }
using base::operator=;
using base::operator==;
using base::operator!=;
multiset(const multiset<Key, Compare, Allocator>& x) : base(x) { }
~multiset() { }
using base::insert;
using base::erase;
using base::operator=;
using base::operator==;
using base::operator!=;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::insert;
using base::erase;
using base::begin;
using base::end;
using base::rbegin;
using base::rend;
using base::empty;
using base::size;
using base::max_size;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
using base::empty;
using base::size;
using base::max_size;
using base::find;
using base::count;
using base::lower_bound;
using base::upper_bound;
using base::equal_range;
protected:
};
/* Non-member functions. These are at the end because they are not associated with any
particular class. These will be implemented as I figure out exactly what all of
them are supposed to do, and I have time.
* particular class. These will be implemented as I figure out exactly what all of
* them are supposed to do, and I have time.
*/
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
while(first1 != last1 && first2 != last2){
if( *first1 < *first2 ){
return true;
}
if( *first2 < *first1 ){
return false;
}
++first1;
++first2;
}
return first1==last1 && first2 != last2;
}
while (first1 != last1 && first2 != last2)
{
if (*first1 < *first2)
{
return true;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
if (*first2 < *first1)
{
return false;
}
while(first1 != last1 && first2 != last2){
if( *first1 > *first2 ){
return true;
}
if( *first2 > *first1 ){
return false;
}
++first1;
++first2;
}
return first1!=last1 && first2 == last2;
}
++first1;
++first2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
return first1==last1 && first2 != last2;
}
while(first1 != last1 && first2 != last2){
if( *first1 > *first2 ){
return true;
}
if( *first2 > *first1 ){
return false;
}
++first1;
++first2;
}
return first1!=last1;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
while (first1 != last1 && first2 != last2)
{
if (*first1 > *first2)
{
return true;
}
while(first1 != last1 && first2 != last2){
if( *first1 < *first2 ){
return true;
}
if( *first2 < *first1 ){
return false;
}
++first1;
++first2;
}
return first2!=last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT void swap
(set<Key,Compare,Allocator>& x, set<Key,Compare,Allocator>& y)
{
x.swap(y);
}
if (*first2 > *first1)
{
return false;
}
++first1;
++first2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator==
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
if(x.data == y.data){
return true;
}
return false;
}
return first1!=last1 && first2 == last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
while(first1 != last1 && first2 != last2){
if( *first1 < *first2 ){
return true;
}
if( *first2 < *first1 ){
return false;
}
++first1;
++first2;
}
return first1==last1 && first2 != last2;
}
while (first1 != last1 && first2 != last2)
{
if (*first1 > *first2)
{
return true;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
if (*first2 > *first1)
{
return false;
}
while(first1 != last1 && first2 != last2){
if( *first1 != *first2 ){
return true;
}
++first1;
++first2;
}
return first1!=last1 || first2 != last2;
}
++first1;
++first2;
}
return first1!=last1;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const set<Key,Compare,Allocator>& x, const set<Key,Compare,Allocator>& y)
{
typename set<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename set<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename set<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename set<Key,Compare,Allocator>::const_iterator last2 = y.end();
while(first1 != last1 && first2 != last2){
if( *first1 > *first2 ){
return true;
}
if( *first2 > *first1 ){
return false;
}
++first1;
++first2;
}
return first1!=last1 && first2 == last2;
}
while (first1 != last1 && first2 != last2)
{
if (*first1 < *first2)
{
return true;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
if (*first2 < *first1)
{
return false;
}
while(first1 != last1 && first2 != last2){
if( *first1 > *first2 ){
return true;
}
if( *first2 > *first1 ){
return false;
}
++first1;
++first2;
}
return first1!=last1;
}
++first1;
++first2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
return first2!=last2;
}
while(first1 != last1 && first2 != last2){
if( *first1 < *first2 ){
return true;
}
if( *first2 < *first1 ){
return false;
}
++first1;
++first2;
}
return first2!=last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT void swap
(set<Key,Compare,Allocator>& x, set<Key,Compare,Allocator>& y)
{
x.swap(y);
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT void swap
(multiset<Key,Compare,Allocator>& x, multiset<Key,Compare,Allocator>& y)
{
x.swap(y);
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator==
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
if (x.data == y.data)
{
return true;
}
return false;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
}
while (first1 != last1 && first2 != last2)
{
if (*first1 < *first2)
{
return true;
}
if (*first2 < *first1)
{
return false;
}
++first1;
++first2;
}
return first1==last1 && first2 != last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator!=
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
while (first1 != last1 && first2 != last2)
{
if (*first1 != *first2)
{
return true;
}
++first1;
++first2;
}
return first1!=last1 || first2 != last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
while (first1 != last1 && first2 != last2)
{
if (*first1 > *first2)
{
return true;
}
if (*first2 > *first1)
{
return false;
}
++first1;
++first2;
}
return first1!=last1 && first2 == last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator>=
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
while (first1 != last1 && first2 != last2)
{
if (*first1 > *first2)
{
return true;
}
if (*first2 > *first1)
{
return false;
}
++first1;
++first2;
}
return first1!=last1;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT bool operator<=
(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y)
{
typename multiset<Key,Compare,Allocator>::const_iterator first1 = x.begin();
typename multiset<Key,Compare,Allocator>::const_iterator first2 = y.begin();
typename multiset<Key,Compare,Allocator>::const_iterator last1 = x.end();
typename multiset<Key,Compare,Allocator>::const_iterator last2 = y.end();
while (first1 != last1 && first2 != last2)
{
if (*first1 < *first2)
{
return true;
}
if (*first2 < *first1)
{
return false;
}
++first1;
++first2;
}
return first2!=last2;
}
template <class Key, class Compare, class Allocator> _UCXXEXPORT void swap
(multiset<Key,Compare,Allocator>& x, multiset<Key,Compare,Allocator>& y)
{
x.swap(y);
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+395 -309
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
@@ -31,345 +31,431 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
template <class charT, class traits, class Allocator>
class _UCXXEXPORT basic_stringbuf : public basic_streambuf<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef typename Allocator::size_type size_type;
template <class charT, class traits, class Allocator>
class _UCXXEXPORT basic_stringbuf : public basic_streambuf<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef typename Allocator::size_type size_type;
explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out)
: data(), ielement(0), oelement(0)
{
basic_streambuf<charT,traits>::openedFor = which;
}
explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out)
: data(), ielement(0), oelement(0)
{
basic_streambuf<charT,traits>::openedFor = which;
}
explicit _UCXXEXPORT basic_stringbuf(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::in | ios_base::out)
: data(str), ielement(0), oelement(0)
{
if (which & ios_base::ate)
{
oelement = data.length();
}
explicit _UCXXEXPORT basic_stringbuf(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::in | ios_base::out)
: data(str), ielement(0), oelement(0)
{
if(which & ios_base::ate){
oelement = data.length();
}
basic_streambuf<charT,traits>::openedFor = which;
}
basic_streambuf<charT,traits>::openedFor = which;
}
virtual _UCXXEXPORT ~basic_stringbuf() { }
virtual _UCXXEXPORT ~basic_stringbuf() { }
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
return data;
}
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const
{
return data;
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
data = s;
ielement = 0;
if(basic_streambuf<charT,traits>::openedFor & ios_base::ate){
oelement = data.length();
}else{
oelement = 0;
}
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s)
{
data = s;
ielement = 0;
if (basic_streambuf<charT,traits>::openedFor & ios_base::ate)
{
oelement = data.length();
}
else
{
oelement = 0;
}
}
protected:
virtual _UCXXEXPORT int sync(){
return 0;
}
virtual _UCXXEXPORT int_type underflow(){
if(ielement >= data.length()){
return traits::eof();
}
return traits::to_int_type(data[ielement]);
}
protected:
virtual _UCXXEXPORT int sync()
{
return 0;
}
virtual _UCXXEXPORT int_type uflow(){
int_type retval = underflow();
if(retval != traits::eof()){
++ielement;
}
return retval;
}
virtual _UCXXEXPORT int_type underflow()
{
if (ielement >= data.length())
{
return traits::eof();
}
virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){
//Error possibilities
if(ielement == 0){
return traits::eof();
}
if(ielement > data.length()){
ielement = data.length();
return traits::eof();
}
//eof passed in
if(traits::eq_int_type(c,traits::eof())==true){
--ielement;
return traits::not_eof(c);
}
if(traits::eq(traits::to_char_type(c),data[ielement-1]) == true){
--ielement;
return c;
}
if(basic_streambuf<charT,traits>::openedFor & ios_base::out){
--ielement;
data[ielement] = c;
return c;
}
return traits::eof();
}
return traits::to_int_type(data[ielement]);
}
virtual _UCXXEXPORT int showmanyc(){
return data.length() - ielement;
}
virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n){
streamsize i = 0;
while(ielement < data.length() && i < n ){
c[i] = data[ielement];
++i;
++ielement;
}
return i;
}
virtual _UCXXEXPORT int_type uflow()
{
int_type retval = underflow();
if (retval != traits::eof())
{
++ielement;
}
virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof()){
//Nothing to do
if(traits::eq_int_type(c,traits::eof())){
return traits::not_eof(c);
}
return retval;
}
//Actually add character, if possible
if(basic_streambuf<charT,traits>::openedFor & ios_base::out){
if(oelement >= data.length()){
data.push_back(c);
}else{
data[oelement] = c;
}
++oelement;
return c;
}
//Not possible
return traits::eof();
}
virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof())
{
// Error possibilities
virtual _UCXXEXPORT basic_streambuf<charT,traits>* setbuf(charT*, streamsize){
//This function does nothing
return this;
}
if (ielement == 0)
{
return traits::eof();
}
virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){
data.replace(oelement, n, s, n);
oelement += n;
return n;
}
if (ielement > data.length())
{
ielement = data.length();
return traits::eof();
}
virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out)
{
//Test for invalid option
if( (which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur)){
return -1;
}
// eof passed in
//Calculate new location
size_type newpos = 0;
if (traits::eq_int_type(c,traits::eof())==true)
{
--ielement;
return traits::not_eof(c);
}
if(way == ios_base::beg){
newpos = off;
}else if(way == ios_base::cur){
if(which & ios_base::out){
newpos = data.length() + off;
}
if(which & ios_base::in){
newpos = ielement + off;
}
}else{
newpos = data.length() + off;
}
if (traits::eq(traits::to_char_type(c),data[ielement-1]) == true)
{
--ielement;
return c;
}
//Test for error conditions
if(newpos > data.length()){
return -1;
}
if (basic_streambuf<charT,traits>::openedFor & ios_base::out)
{
--ielement;
data[ielement] = c;
return c;
}
//Shuffle pointers
return traits::eof();
}
if(which & ios_base::in){
ielement = newpos;
}
if(which & ios_base::out){
data.resize(newpos);
if(ielement > data.length()){
ielement = data.length();
}
}
virtual _UCXXEXPORT int showmanyc()
{
return data.length() - ielement;
}
return newpos;
}
virtual _UCXXEXPORT pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out)
{
return seekoff(sp, ios_base::beg, which);
}
virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n)
{
streamsize i = 0;
while (ielement < data.length() && i < n)
{
c[i] = data[ielement];
++i;
++ielement;
}
basic_string<charT,traits,Allocator> data;
size_type ielement;
size_type oelement;
};
return i;
}
virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof())
{
// Nothing to do
if (traits::eq_int_type(c,traits::eof()))
{
return traits::not_eof(c);
}
// Actually add character, if possible
if (basic_streambuf<charT,traits>::openedFor & ios_base::out)
{
if (oelement >= data.length())
{
data.push_back(c);
}
else
{
data[oelement] = c;
}
++oelement;
return c;
}
// Not possible
return traits::eof();
}
virtual _UCXXEXPORT basic_streambuf<charT,traits>* setbuf(charT*, streamsize)
{
//This function does nothing
return this;
}
virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n)
{
data.replace(oelement, n, s, n);
oelement += n;
return n;
}
virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out)
{
// Test for invalid option
if ((which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur))
{
return -1;
}
// Calculate new location
size_type newpos = 0;
if (way == ios_base::beg)
{
newpos = off;
}
else if (way == ios_base::cur)
{
if (which & ios_base::out)
{
newpos = data.length() + off;
}
if (which & ios_base::in)
{
newpos = ielement + off;
}
}
else
{
newpos = data.length() + off;
}
// Test for error conditions
if (newpos > data.length())
{
return -1;
}
// Shuffle pointers
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_istringstream
: public basic_istream<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
if (which & ios_base::in)
{
ielement = newpos;
}
if (which & ios_base::out)
{
data.resize(newpos);
if (ielement > data.length())
{
ielement = data.length();
}
}
return newpos;
}
virtual _UCXXEXPORT pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out)
{
return seekoff(sp, ios_base::beg, which);
}
basic_string<charT,traits,Allocator> data;
size_type ielement;
size_type oelement;
};
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_istringstream
: public basic_istream<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in)
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(m)
{
}
explicit _UCXXEXPORT basic_istringstream(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::in)
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(str, which)
{
}
virtual _UCXXEXPORT ~basic_istringstream() { }
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf() const
{
return &sb;
}
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const
{
return sb.str();
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
sb.str(s);
basic_istream<charT,traits>::clear();
}
private:
basic_stringbuf<charT,traits,Allocator> sb;
};
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_ostringstream
: public basic_ostream<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out)
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(m)
{
}
explicit _UCXXEXPORT basic_ostringstream(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::out)
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(str, which)
{
}
virtual _UCXXEXPORT ~basic_ostringstream() { }
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf() const
{
return &sb;
}
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const
{
return sb.str();
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s)
{
sb.str(s);
basic_ostream<charT,traits>::clear();
}
private:
basic_stringbuf<charT,traits,Allocator> sb;
};
explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in)
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(m)
{
}
explicit _UCXXEXPORT basic_istringstream( const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::in)
: basic_ios<charT, traits>(&sb), basic_istream<charT,traits>(&sb), sb(str, which)
{
}
virtual _UCXXEXPORT ~basic_istringstream() { }
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf() const{
return &sb;
}
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
return sb.str();
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
sb.str(s);
basic_istream<charT,traits>::clear();
}
private:
basic_stringbuf<charT,traits,Allocator> sb;
};
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_stringstream
: public basic_iostream<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in)
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(which)
{
}
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_ostringstream
: public basic_ostream<charT,traits>
{
public:
explicit _UCXXEXPORT basic_stringstream(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::out|ios_base::in)
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(str, which)
{
}
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
virtual _UCXXEXPORT ~basic_stringstream(){ }
explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out)
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(m)
{
}
explicit _UCXXEXPORT basic_ostringstream(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::out)
: basic_ios<charT, traits>(&sb), basic_ostream<charT,traits>(&sb), sb(str, which)
{
}
virtual _UCXXEXPORT ~basic_ostringstream() { }
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf()
{
return &sb;
}
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf() const{
return &sb;
}
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
return sb.str();
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
sb.str(s);
basic_ostream<charT,traits>::clear();
}
private:
basic_stringbuf<charT,traits,Allocator> sb;
};
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const
{
return sb.str();
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s)
{
sb.str(s);
basic_iostream<charT,traits>::clear();
}
template <class charT, class traits, class Allocator> class _UCXXEXPORT basic_stringstream
: public basic_iostream<charT,traits>
{
public:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in)
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(which)
{
}
explicit _UCXXEXPORT basic_stringstream(const basic_string<charT,traits,Allocator>& str,
ios_base::openmode which = ios_base::out|ios_base::in)
: basic_ios<charT, traits>(&sb), basic_iostream<charT,traits>(&sb), sb(str, which)
{
}
virtual _UCXXEXPORT ~basic_stringstream(){ }
_UCXXEXPORT basic_stringbuf<charT,traits,Allocator>* rdbuf(){
return &sb;
}
_UCXXEXPORT basic_string<charT,traits,Allocator> str() const{
return sb.str();
}
_UCXXEXPORT void str(const basic_string<charT,traits,Allocator>& s){
sb.str(s);
basic_iostream<charT,traits>::clear();
}
private:
basic_stringbuf<charT, traits> sb;
};
private:
basic_stringbuf<charT, traits> sb;
};
#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__
#ifndef __UCLIBCXX_COMPILE_SSTREAM__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::
basic_stringbuf(ios_base::openmode which);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::~basic_stringbuf();
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::
basic_stringbuf(ios_base::openmode which);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::~basic_stringbuf();
#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT basic_string<char, char_traits<char>, allocator<char> >
basic_stringbuf<char, char_traits<char>, allocator<char> >::str() const;
template <> _UCXXEXPORT basic_string<char, char_traits<char>, allocator<char> >
basic_stringbuf<char, char_traits<char>, allocator<char> >::str() const;
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::
pbackfail(basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type c);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::
pbackfail(basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type c);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::pos_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::
seekoff (basic_stringbuf<char, char_traits<char>, allocator<char> >::off_type off,
ios_base::seekdir way,
ios_base::openmode which
);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::pos_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::
seekoff (basic_stringbuf<char, char_traits<char>, allocator<char> >::off_type off,
ios_base::seekdir way,
ios_base::openmode which);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::
overflow (basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type c);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::
overflow (basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type c);
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::underflow ();
template <> _UCXXEXPORT basic_stringbuf<char, char_traits<char>, allocator<char> >::int_type
basic_stringbuf<char, char_traits<char>, allocator<char> >::underflow ();
template <> _UCXXEXPORT streamsize basic_stringbuf<char, char_traits<char>, allocator<char> >::
xsputn(const char* s, streamsize n);
template <> _UCXXEXPORT streamsize basic_stringbuf<char, char_traits<char>, allocator<char> >::
xsputn(const char* s, streamsize n);
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT basic_stringstream<char, char_traits<char>, allocator<char> >::
basic_stringstream(ios_base::openmode which);
template <> _UCXXEXPORT basic_stringstream<char, char_traits<char>, allocator<char> >::~basic_stringstream();
template <> _UCXXEXPORT basic_istringstream<char, char_traits<char>, allocator<char> >::~basic_istringstream();
template <> _UCXXEXPORT basic_ostringstream<char, char_traits<char>, allocator<char> >::~basic_ostringstream();
template <> _UCXXEXPORT basic_stringstream<char, char_traits<char>, allocator<char> >::
basic_stringstream(ios_base::openmode which);
template <> _UCXXEXPORT basic_stringstream<char, char_traits<char>, allocator<char> >::~basic_stringstream();
template <> _UCXXEXPORT basic_istringstream<char, char_traits<char>, allocator<char> >::~basic_istringstream();
template <> _UCXXEXPORT basic_ostringstream<char, char_traits<char>, allocator<char> >::~basic_ostringstream();
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
@@ -378,7 +464,7 @@ namespace std{
#pragma GCC visibility pop
}
} // namespace
} // extern "C++"
#endif
+69 -61
View File
@@ -1,19 +1,20 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <deque>
@@ -23,59 +24,66 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
template <class T, class Container = deque<T> > class _UCXXEXPORT stack
{
protected:
Container c;
template <class T, class Container = deque<T> > class _UCXXEXPORT stack{
protected:
Container c;
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
public:
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Container container_type;
explicit stack(const Container& a = Container()) : c(a) { };
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
value_type& top() { return c.back(); }
const value_type& top() const { return c.back(); }
void push(const value_type& x) { c.push_back(x); }
void pop() { c.pop_back(); }
explicit stack(const Container& a = Container()) : c(a) { };
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
value_type& top() { return c.back(); }
const value_type& top() const { return c.back(); }
void push(const value_type& x) { c.push_back(x); }
void pop() { c.pop_back(); }
bool operator==(const stack<T, Container> &x) const
{
return x.c == c;
}
};
bool operator==(const stack<T, Container> &x) const{
return x.c == c;
}
template <class T, class Container> _UCXXEXPORT bool
operator< (const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c < y.c);
}
};
template <class T, class Container> _UCXXEXPORT bool
operator!=(const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c != y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator> (const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c > y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator< (const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c < y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator!=(const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c != y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator> (const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c > y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator>=(const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c >= y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator<=(const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c <= y.c);
}
template <class T, class Container> _UCXXEXPORT bool
operator>=(const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c >= y.c);
}
}
template <class T, class Container> _UCXXEXPORT bool
operator<=(const stack<T, Container>& x, const stack<T, Container>& y)
{
return (x.c <= y.c);
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+333 -254
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <locale>
@@ -29,300 +29,379 @@
#pragma GCC visibility push(default)
namespace std{
template <class charT, class traits> class _UCXXEXPORT basic_streambuf{
public:
extern "C++"
{
namespace std
{
template <class charT, class traits> class _UCXXEXPORT basic_streambuf{
public:
#ifdef __UCLIBCXX_SUPPORT_CDIR__
friend ios_base::Init::Init();
friend ios_base::Init::Init();
#endif
// Types:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef traits traits_type;
// Types:
virtual ~basic_streambuf();
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef traits traits_type;
locale pubimbue(const locale &loc);
virtual ~basic_streambuf();
locale getloc() const{
return myLocale;
}
locale pubimbue(const locale &loc);
basic_streambuf<char_type,traits>* pubsetbuf(char_type* s, streamsize n){
return setbuf(s,n);
}
pos_type pubseekoff(off_type off,
typename ios_base::seekdir way,
ios_base::openmode which = ios_base::in |
ios_base::out
)
{
return seekoff(off,way,which);
}
pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out){
return seekpos(sp,which);
}
int pubsync(){
return sync();
}
locale getloc() const
{
return myLocale;
}
streamsize in_avail();
basic_streambuf<char_type,traits>* pubsetbuf(char_type* s, streamsize n)
{
return setbuf(s,n);
}
int_type snextc();
pos_type pubseekoff(off_type off,
typename ios_base::seekdir way,
ios_base::openmode which = ios_base::in |
ios_base::out)
{
return seekoff(off,way,which);
}
int_type sbumpc();
pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out)
{
return seekpos(sp,which);
}
int_type sgetc();
int pubsync()
{
return sync();
}
streamsize sgetn(char_type* s, streamsize n){
return xsgetn(s,n);
}
streamsize in_avail();
int_type sputbackc(char_type c);
int_type snextc();
int_type sungetc();
int_type sbumpc();
int_type sputc(char_type c);
int_type sgetc();
streamsize sputn(const char_type* s, streamsize n){
if(openedFor & ios_base::app){
seekoff(0, ios_base::end, ios_base::out);
}
return xsputn(s, n);
}
streamsize sgetn(char_type* s, streamsize n)
{
return xsgetn(s,n);
}
protected:
locale myLocale;
//Pointers for the "get" buffers
charT * mgbeg;
charT * mgnext;
charT * mgend;
int_type sputbackc(char_type c);
//Pointers for the "put" buffers
charT * mpbeg;
charT * mpnext;
charT * mpend;
int_type sungetc();
//In the event of null buffers Lets us know what the buffer is opened for
ios_base::openmode openedFor;
basic_streambuf();
int_type sputc(char_type c);
basic_streambuf(const basic_streambuf<char, char_traits<char> > &)
: myLocale(),
mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0),
openedFor(0)
{ }
basic_streambuf<char, char_traits<char> > & operator=(const basic_streambuf<char, char_traits<char> > &){
return *this;
}
char_type* eback() const{
return mgbeg;
}
char_type* gptr() const{
return mgnext;
}
char_type* egptr() const{
return mgend;
}
void gbump(int n){
mgnext+=n;
}
void setg(char_type* gbeg, char_type* gnext, char_type* gend){
mgbeg = gbeg;
mgnext = gnext;
mgend = gend;
}
streamsize sputn(const char_type* s, streamsize n)
{
if (openedFor & ios_base::app)
{
seekoff(0, ios_base::end, ios_base::out);
}
char_type* pbase() const{
return mpbeg;
}
char_type* pptr() const{
return mpnext;
}
char_type* epptr() const{
return mpend;
}
void pbump(int n){
mpnext+=n;
}
void setp(char_type* pbeg, char_type* pend){
mpbeg = pbeg;
mpnext = pbeg;
mpend = pend;
}
return xsputn(s, n);
}
virtual void imbue(const locale &loc){
myLocale = loc;
}
protected:
locale myLocale;
//Virtual functions which we will not implement
// Pointers for the "get" buffers
virtual basic_streambuf<char_type,traits>* setbuf(char_type* , streamsize){
return 0;
}
virtual pos_type seekoff(off_type , ios_base::seekdir,
ios_base::openmode = ios_base::in | ios_base::out)
{
return 0;
}
virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out){
return 0;
}
virtual int sync(){
return 0;
}
charT * mgbeg;
charT * mgnext;
charT * mgend;
virtual int showmanyc(){
return 0;
}
virtual streamsize xsgetn(char_type* , streamsize ){
return 0;
}
virtual int_type underflow(){
return traits_type::eof();
}
virtual int_type uflow(){
int_type ret = underflow();
if (!traits_type::eq_int_type(ret, traits_type::eof()))
gbump(1);
return ret;
}
// Pointers for the "put" buffers
virtual int_type pbackfail(int_type c = traits::eof()){
return c;
}
virtual streamsize xsputn(const char_type* c, streamsize n){
//This function is designed to be replaced by subclasses
for(streamsize i = 0; i< n; ++i){
if(sputc(c[i]) == traits::eof()){
return i;
}
}
return n;
}
virtual int_type overflow (int_type c = traits::eof()){
return c;
}
};
charT * mpbeg;
charT * mpnext;
charT * mpend;
typedef basic_streambuf<char> streambuf;
// In the event of null buffers Lets us know what the buffer is opened for
ios_base::openmode openedFor;
basic_streambuf();
basic_streambuf(const basic_streambuf<char, char_traits<char> > &)
: myLocale(),
mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0),
openedFor(0)
{ }
basic_streambuf<char, char_traits<char> > & operator=(const basic_streambuf<char, char_traits<char> > &)
{
return *this;
}
char_type* eback() const
{
return mgbeg;
}
char_type* gptr() const
{
return mgnext;
}
char_type* egptr() const
{
return mgend;
}
void gbump(int n)
{
mgnext+=n;
}
void setg(char_type* gbeg, char_type* gnext, char_type* gend)
{
mgbeg = gbeg;
mgnext = gnext;
mgend = gend;
}
char_type* pbase() const
{
return mpbeg;
}
char_type* pptr() const
{
return mpnext;
}
char_type* epptr() const
{
return mpend;
}
void pbump(int n)
{
mpnext+=n;
}
void setp(char_type* pbeg, char_type* pend)
{
mpbeg = pbeg;
mpnext = pbeg;
mpend = pend;
}
virtual void imbue(const locale &loc)
{
myLocale = loc;
}
// Virtual functions which we will not implement
virtual basic_streambuf<char_type,traits>* setbuf(char_type* , streamsize)
{
return 0;
}
virtual pos_type seekoff(off_type , ios_base::seekdir,
ios_base::openmode = ios_base::in | ios_base::out)
{
return 0;
}
virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out)
{
return 0;
}
virtual int sync()
{
return 0;
}
virtual int showmanyc()
{
return 0;
}
virtual streamsize xsgetn(char_type* , streamsize)
{
return 0;
}
virtual int_type underflow()
{
return traits_type::eof();
}
virtual int_type uflow()
{
int_type ret = underflow();
if (!traits_type::eq_int_type(ret, traits_type::eof()))
{
gbump(1);
}
return ret;
}
virtual int_type pbackfail(int_type c = traits::eof())
{
return c;
}
virtual streamsize xsputn(const char_type* c, streamsize n)
{
// This function is designed to be replaced by subclasses
for (streamsize i = 0; i< n; ++i)
{
if (sputc(c[i]) == traits::eof())
{
return i;
}
}
return n;
}
virtual int_type overflow (int_type c = traits::eof())
{
return c;
}
};
typedef basic_streambuf<char> streambuf;
#ifdef __UCLIBCXX_HAS_WCHAR__
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_streambuf<wchar_t> wstreambuf;
#endif
// Definitions put below to allow for easy expansion of code
//Definitions put below to allow for easy expansion of code
template <class C, class T> basic_streambuf<C, T>::~basic_streambuf(){ }
template <class C, class T> basic_streambuf<C, T>::~basic_streambuf(){ }
template <class C, class T> locale basic_streambuf<C, T>::pubimbue(const locale &loc)
{
locale temp = myLocale;
myLocale = loc;
return temp;
}
template <class C, class T> locale basic_streambuf<C, T>::pubimbue(const locale &loc){
locale temp = myLocale;
myLocale = loc;
return temp;
}
template <class C, class T> streamsize basic_streambuf<C, T>::in_avail()
{
if (mgend !=0 && mgnext !=0)
{
return mgend - mgnext;
}
template <class C, class T> streamsize basic_streambuf<C, T>::in_avail(){
if(mgend !=0 && mgnext !=0){
return mgend - mgnext;
}
return showmanyc();
}
return showmanyc();
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sbumpc(){
if(mgbeg == 0 || mgnext == mgend){
return uflow();
}
int_type retval = T::to_int_type(*gptr());
gbump(1);
return retval;
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sbumpc()
{
if (mgbeg == 0 || mgnext == mgend)
{
return uflow();
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::snextc(){
if(sbumpc() == T::eof() ){
return T::eof() ;
}
return sgetc();
}
int_type retval = T::to_int_type(*gptr());
gbump(1);
return retval;
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sgetc(){
if(mgbeg == 0 || mgnext == mgend){
return underflow();
}
return T::to_int_type(*gptr());
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::snextc()
{
if (sbumpc() == T::eof())
{
return T::eof() ;
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sputbackc(char_type c){
if(mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1] )){
return pbackfail(T::to_int_type(c));
}
gbump(-1);
return T::to_int_type(*gptr());
}
return sgetc();
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sungetc(){
if(mgbeg == 0 || mgnext == mgbeg){
return ios_base::failbit;
}
gbump(-1);
return T::to_int_type(*gptr());
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sgetc()
{
if (mgbeg == 0 || mgnext == mgend)
{
return underflow();
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sputc(char_type c){
if(openedFor & ios_base::app){
seekoff(0, ios_base::end, ios_base::out);
}
if(mpnext < mpend){
*mpnext = c;
++mpnext;
}else{
return overflow( T::to_int_type(c) );
}
return T::to_int_type(c);
}
return T::to_int_type(*gptr());
}
template <class C, class T> basic_streambuf<C, T>::basic_streambuf()
: myLocale(),
mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0),
openedFor(0)
{ }
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sputbackc(char_type c)
{
if (mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1]))
{
return pbackfail(T::to_int_type(c));
}
gbump(-1);
return T::to_int_type(*gptr());
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sungetc()
{
if (mgbeg == 0 || mgnext == mgbeg)
{
return ios_base::failbit;
}
gbump(-1);
return T::to_int_type(*gptr());
}
template <class C, class T> typename basic_streambuf<C, T>::int_type basic_streambuf<C, T>::sputc(char_type c)
{
if (openedFor & ios_base::app)
{
seekoff(0, ios_base::end, ios_base::out);
}
if (mpnext < mpend)
{
*mpnext = c;
++mpnext;
}
else
{
return overflow(T::to_int_type(c));
}
return T::to_int_type(c);
}
template <class C, class T> basic_streambuf<C, T>::basic_streambuf()
: myLocale(),
mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0),
openedFor(0)
{ }
#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__
#ifndef __UCLIBCXX_COMPILE_STREAMBUF__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT streambuf::basic_streambuf();
template <> _UCXXEXPORT streambuf::~basic_streambuf();
template <> _UCXXEXPORT streambuf::basic_streambuf();
template <> _UCXXEXPORT streambuf::~basic_streambuf();
#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template <> _UCXXEXPORT locale streambuf::pubimbue(const locale &loc);
template <> _UCXXEXPORT streamsize streambuf::in_avail();
template <> _UCXXEXPORT streambuf::int_type streambuf::sbumpc();
template <> _UCXXEXPORT streambuf::int_type streambuf::snextc();
template <> _UCXXEXPORT streambuf::int_type streambuf::sgetc();
template <> _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c);
template <> _UCXXEXPORT streambuf::int_type streambuf::sungetc();
template <> _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c);
template <> _UCXXEXPORT locale streambuf::pubimbue(const locale &loc);
template <> _UCXXEXPORT streamsize streambuf::in_avail();
template <> _UCXXEXPORT streambuf::int_type streambuf::sbumpc();
template <> _UCXXEXPORT streambuf::int_type streambuf::snextc();
template <> _UCXXEXPORT streambuf::int_type streambuf::sgetc();
template <> _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c);
template <> _UCXXEXPORT streambuf::int_type streambuf::sungetc();
template <> _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c);
#endif
#endif
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+4
View File
@@ -35,6 +35,8 @@
#pragma GCC visibility push(default)
extern "C++"
{
namespace std
{
// Basic basic_string
@@ -1331,7 +1333,9 @@ template <> _UCXXEXPORT bool operator< (const string & lhs, const string & rhs);
#endif
#endif
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+97 -87
View File
@@ -1,21 +1,21 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <istream>
#include <ostream>
@@ -31,114 +31,124 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const basic_string<charT,traits,Allocator>& str)
operator<<(basic_ostream<charT, traits>& os, const basic_string<charT,traits,Allocator>& str)
{
return os.write(str.data(), str.length());
return os.write(str.data(), str.length());
}
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_istream<charT,traits>&
operator>>(basic_istream<charT,traits>& is, basic_string<charT,traits,Allocator>& str)
operator>>(basic_istream<charT,traits>& is, basic_string<charT,traits,Allocator>& str)
{
typename basic_istream<charT, traits>::sentry s(is);
if(s == false)
{
return is;
}
typename basic_istream<charT, traits>::sentry s(is);
if(s == false){
return is;
}
str.clear();
str.clear();
typename basic_istream<charT, traits>::int_type c;
typename Allocator::size_type n = is.width();
bool exitnow = false;
if (n == 0)
{
n = str.max_size();
}
typename basic_istream<charT, traits>::int_type c;
typename Allocator::size_type n = is.width();
bool exitnow = false;
if(n == 0){
n = str.max_size();
}
// //Clear out preliminary spaces first
// c = is.get();
// while(isspace(c)){
// c = is.get();
// }
// //Clear out preliminary spaces first
// c = is.get();
// while(isspace(c)){
// c = is.get();
// }
//
// is.putback(c);
// is.putback(c);
do{
c = is.get();
if(c == traits::eof() || isspace(c) || n == 0){
is.putback(c);
exitnow = true;
}else{
str.append(1, traits::to_char_type(c) );
--n;
}
}while(exitnow == false);
return is;
do
{
c = is.get();
if(c == traits::eof() || isspace(c) || n == 0)
{
is.putback(c);
exitnow = true;
}
else
{
str.append(1, traits::to_char_type(c) );
--n;
}
}
while(exitnow == false);
return is;
}
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_istream<charT,traits>&
getline(basic_istream<charT,traits>& is, basic_string<charT,traits,Allocator>& str, charT delim)
getline(basic_istream<charT,traits>& is, basic_string<charT,traits,Allocator>& str, charT delim)
{
typename basic_istream<charT,traits>::sentry s(is);
if(s == false){
return is;
}
typename basic_istream<charT,traits>::sentry s(is);
if (s == false)
{
return is;
}
str.erase();
str.erase();
streamsize i = 0;
typename basic_istream<charT,traits>::int_type c_i;
charT c;
unsigned int n = str.max_size();
for(i=0;i<n;++i){
c_i=is.get();
if(c_i == traits::eof() ){
return is;
}
c = traits::to_char_type(c_i);
if(c == delim){
return is;
}
str.append(1, c);
}
return is;
streamsize i = 0;
typename basic_istream<charT,traits>::int_type c_i;
charT c;
unsigned int n = str.max_size();
for (i = 0; i < n; ++i)
{
c_i=is.get();
if (c_i == traits::eof() )
{
return is;
}
c = traits::to_char_type(c_i);
if (c == delim)
{
return is;
}
str.append(1, c);
}
return is;
}
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_istream<charT,traits>&
getline(basic_istream<charT,traits>& is, basic_string<charT,traits,Allocator>& str)
getline(basic_istream<charT,traits>& is, basic_string<charT,traits,Allocator>& str)
{
return getline(is, str, '\n');
return getline(is, str, '\n');
}
#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__
#ifndef __UCLIBCXX_COMPILE_STRING__
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
template<> _UCXXEXPORT basic_istream<char, char_traits<char> >& operator>>(
basic_istream<char,char_traits<char> >& is,
basic_string<char, char_traits<char>, allocator<char> >& str);
basic_istream<char,char_traits<char> >& is,
basic_string<char, char_traits<char>, allocator<char> >& str);
#endif
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
template<> _UCXXEXPORT basic_ostream<char, char_traits<char> >&
operator<<(basic_ostream<char, char_traits<char> >& os,
const basic_string<char,char_traits<char>, std::allocator<char> >& str);
operator<<(basic_ostream<char, char_traits<char> >& os,
const basic_string<char,char_traits<char>, std::allocator<char> >& str);
#endif
#endif
#endif
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+75 -64
View File
@@ -1,20 +1,20 @@
/* Copyright (C) 2005 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2005 Garrett A. Kajmowicz
*
* This file is part of the uClibc++ Library.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#include <string.h>
@@ -27,64 +27,75 @@
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace std
{
struct _UCXXEXPORT __true_type{};
struct _UCXXEXPORT __false_type{};
struct _UCXXEXPORT __true_type{};
struct _UCXXEXPORT __false_type{};
template <class I> class _UCXXEXPORT __is_integer
{
public:
typedef __false_type value;
};
template <class I> class _UCXXEXPORT __is_integer{
public:
typedef __false_type value;
};
template <> class _UCXXEXPORT __is_integer <unsigned int>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <unsigned int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <signed int>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <signed int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <short unsigned int>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <short unsigned int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <short signed int>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <short signed int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <char>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <char>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <signed char>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <signed char>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <unsigned char>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <unsigned char>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <long unsigned int>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <long unsigned int>{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <long signed int>
{
public:
typedef __true_type value;
};
template <> class _UCXXEXPORT __is_integer <long signed int>{
public:
typedef __true_type value;
};
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
+88 -69
View File
@@ -1,88 +1,107 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <basic_definitions>
#ifndef __STD_HEADER_UTILITY
#define __STD_HEADER_UTILITY 1
#pragma GCC visibility push(default)
namespace std{
extern "C++"
{
namespace rel_ops {
template<class T> inline bool operator!=(const T& x, const T& y){
return !(x == y);
}
namespace std
{
namespace rel_ops
{
template<class T> inline bool operator!=(const T& x, const T& y)
{
return !(x == y);
}
template<class T> inline bool operator> (const T& x, const T& y){
return ( y < x);
}
template<class T> inline bool operator> (const T& x, const T& y)
{
return ( y < x);
}
template<class T> inline bool operator<=(const T& x, const T& y){
return !( y < x );
}
template<class T> inline bool operator<=(const T& x, const T& y)
{
return !( y < x );
}
template<class T> inline bool operator>=(const T& x, const T& y){
return !(x < y);
}
}
template<class T> inline bool operator>=(const T& x, const T& y)
{
return !(x < y);
}
} // namespace
template <class T1, class T2> struct _UCXXEXPORT pair {
typedef T1 first_type;
typedef T2 second_type;
template <class T1, class T2> struct _UCXXEXPORT pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair() : first(), second() { }
pair(const T1& x, const T2& y) : first(x), second(y) { }
template<class U, class V> pair(const pair<U, V> &p) : first(p.first), second(p.second) { }
};
template <class T1, class T2> bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y){
using namespace rel_ops;
return (x.first == y.first && x.second==y.second);
}
template <class T1, class T2> bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y){
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
}
template <class T1, class T2> bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y){
return !(x == y);
}
template <class T1, class T2> bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y){
return y < x;
}
template <class T1, class T2> bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y){
return !(x < y);
}
template <class T1, class T2> bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y){
return !(y < x);
}
template <class T1, class T2> pair<T1,T2> make_pair(const T1& x, const T2& y){
return pair<T1,T2>(x, y);
}
T1 first;
T2 second;
pair() : first(), second() { }
pair(const T1& x, const T2& y) : first(x), second(y) { }
template<class U, class V> pair(const pair<U, V> &p) : first(p.first), second(p.second) { }
};
template <class T1, class T2> bool operator==(const pair<T1,T2>& x, const pair<T1,T2>& y)
{
using namespace rel_ops;
return (x.first == y.first && x.second==y.second);
}
template <class T1, class T2> bool operator< (const pair<T1,T2>& x, const pair<T1,T2>& y)
{
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
}
}
template <class T1, class T2> bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y)
{
return !(x == y);
}
template <class T1, class T2> bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y)
{
return y < x;
}
template <class T1, class T2> bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y)
{
return !(x < y);
}
template <class T1, class T2> bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y)
{
return !(y < x);
}
template <class T1, class T2> pair<T1,T2> make_pair(const T1& x, const T2& y)
{
return pair<T1,T2>(x, y);
}
} // namespace
} // extern "C++"
#pragma GCC visibility pop
#endif //__STD_HEADER_UTILITY
#endif //__STD_HEADER_UTILITY
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,26 +1,24 @@
/* Copyright (C) 2007 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2007 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <associative_base>
namespace std{
}
namespace std
{
} // namespace
+21 -23
View File
@@ -1,26 +1,24 @@
/* Copyright (C) 2004 Garrett A. Kajmowicz
This file is part of the uClibc++ Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Copyright (C) 2004 Garrett A. Kajmowicz
* This file is part of the uClibc++ Library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <bitset>
namespace std{
}
namespace std
{
} // namespace