first commit
This commit is contained in:
56
extern/stdcxx/4.2.1/examples/include/alg3.h
vendored
Normal file
56
extern/stdcxx/4.2.1/examples/include/alg3.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* alg3.h - Header for sample programs for STL generic algorihtms
|
||||
* that modify their arguments in place.
|
||||
*
|
||||
* $Id: alg3.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ALG3_H_INCLUDED
|
||||
#define ALG3_H_INCLUDED
|
||||
|
||||
#include <rw/_random.h>
|
||||
|
||||
class iotaGenerator
|
||||
{
|
||||
public:
|
||||
iotaGenerator (int iv) : current (iv)
|
||||
{ }
|
||||
int operator () () {
|
||||
return current++;
|
||||
}
|
||||
private:
|
||||
int current;
|
||||
};
|
||||
|
||||
|
||||
struct RandomInteger
|
||||
{
|
||||
int operator () (int m) {
|
||||
// using a proprietary algorithm
|
||||
return _RW::__rw_random (m);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ALG3_H_INCLUDED
|
||||
159
extern/stdcxx/4.2.1/examples/include/codecvte.h
vendored
Normal file
159
extern/stdcxx/4.2.1/examples/include/codecvte.h
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* codecvte.h - Example of user defined codecvt facet.
|
||||
*
|
||||
* $Id: codecvte.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CODECVTE_H_INCLUDED
|
||||
|
||||
#include <locale> // for codecvt
|
||||
#include <cwchar> // for mbstate_t, size_t
|
||||
|
||||
#include <examples.h>
|
||||
|
||||
|
||||
#define RWSTD_TABLE_SIZE 59
|
||||
|
||||
// This facet performs a conversion from Latin Alphabet No. 1
|
||||
// (ISO 8859-1) to U.S. ASCII code page 437. Some conversions are
|
||||
// one way (from ISO to ASCII, but not back again) because this ASCII
|
||||
// code page has no equivilent to the ISO character.
|
||||
|
||||
class ex_codecvt: public std::codecvt<char, char, std::mbstate_t>
|
||||
{
|
||||
static const char table_[RWSTD_TABLE_SIZE][3];
|
||||
|
||||
protected:
|
||||
|
||||
virtual result
|
||||
do_in (std::mbstate_t&,
|
||||
const char* from,
|
||||
const char* from_end,
|
||||
const char* &from_next,
|
||||
char* to,
|
||||
char* to_limit,
|
||||
char* &to_next) const {
|
||||
|
||||
const std::size_t from_size = std::size_t (from_end - from);
|
||||
const std::size_t to_size = std::size_t (to_limit - to);
|
||||
|
||||
std::size_t i = from_size < to_size ? from_size : to_size;
|
||||
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (std::size_t j = 0; j < i; ++j, ++from_next, ++to_next) {
|
||||
|
||||
*to_next = *from_next;
|
||||
|
||||
for (int k = 0; k < RWSTD_TABLE_SIZE; ++k) {
|
||||
if ( *from_next >= table_[k][0]
|
||||
&& *from_next <= table_[k][1]) {
|
||||
*to_next = table_[k][2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
virtual result
|
||||
do_out (std::mbstate_t&,
|
||||
const char* from,
|
||||
const char* from_end,
|
||||
const char* &from_next,
|
||||
char* to,
|
||||
char* to_limit,
|
||||
char* &to_next) const {
|
||||
|
||||
const std::size_t from_size = std::size_t (from_end - from);
|
||||
const std::size_t to_size = std::size_t (to_limit - to);
|
||||
|
||||
std::size_t i = from_size < to_size ? from_size : to_size;
|
||||
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
|
||||
for (std::size_t j = 0; j < i; ++j, ++from_next, ++to_next) {
|
||||
|
||||
*to_next = *from_next;
|
||||
|
||||
for (std::size_t k = 0; k < RWSTD_TABLE_SIZE; ++k) {
|
||||
if ( *from_next == table_[k][2]
|
||||
&& table_[k][0] == table_[k][1]) {
|
||||
*to_next = table_[k][1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
virtual bool do_always_noconv () const _THROWS (()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int do_encoding () const _THROWS (()) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const char ex_codecvt::table_[RWSTD_TABLE_SIZE][3] = {
|
||||
{ '\xa2', '\xa2', '\x9b' }, { '\xa3', '\xa3', '\x9c' },
|
||||
{ '\xa5', '\xa5', '\x9d' }, { '\xa7', '\xa7', '\x15' },
|
||||
{ '\xa8', '\xa8', '\x22' }, { '\xaa', '\xaa', '\xa6' },
|
||||
{ '\xab', '\xab', '\xae' }, { '\xb5', '\xb5', '\xe6' },
|
||||
{ '\xb6', '\xb6', '\x14' }, { '\xb7', '\xb7', '\xfa' },
|
||||
{ '\xba', '\xba', '\xa7' }, { '\xbb', '\xbb', '\xaf' },
|
||||
{ '\xbc', '\xbc', '\xac' }, { '\xbd', '\xbd', '\xab' },
|
||||
{ '\xbf', '\xbf', '\xa8' }, { '\xc0', '\xc3', '\x41' },
|
||||
{ '\xc4', '\xc4', '\x8e' }, { '\xc5', '\xc5', '\x41' },
|
||||
{ '\xc6', '\xc6', '\x92' }, { '\xc7', '\xc7', '\x80' },
|
||||
{ '\xc8', '\xc8', '\x45' }, { '\xc9', '\xc9', '\x90' },
|
||||
{ '\xca', '\xcb', '\x45' }, { '\xcc', '\xcf', '\x49' },
|
||||
{ '\xd1', '\xd1', '\xa5' }, { '\xd2', '\xd5', '\x4f' },
|
||||
{ '\xd6', '\xd6', '\x99' }, { '\xd8', '\xd8', '\xed' },
|
||||
{ '\xd9', '\xdb', '\x55' }, { '\xdc', '\xdc', '\x9a' },
|
||||
{ '\xdd', '\xdd', '\x59' }, { '\xdf', '\xdf', '\xe1' },
|
||||
{ '\xe0', '\xe0', '\x85' }, { '\xe1', '\xe1', '\xa0' },
|
||||
{ '\xe2', '\xe2', '\x83' }, { '\xe3', '\xe3', '\x61' },
|
||||
{ '\xe4', '\xe4', '\x84' }, { '\xe5', '\xe5', '\x86' },
|
||||
{ '\xe6', '\xe6', '\x91' }, { '\xe7', '\xe7', '\x87' },
|
||||
{ '\xe8', '\xe8', '\x8a' }, { '\xe9', '\xe9', '\x82' },
|
||||
{ '\xea', '\xea', '\x88' }, { '\xeb', '\xeb', '\x89' },
|
||||
{ '\xec', '\xec', '\x8d' }, { '\xed', '\xed', '\xa1' },
|
||||
{ '\xee', '\xee', '\x8c' }, { '\xef', '\xef', '\x8b' },
|
||||
{ '\xf1', '\xf1', '\xa4' }, { '\xf2', '\xf2', '\x95' },
|
||||
{ '\xf3', '\xf3', '\xa2' }, { '\xf4', '\xf4', '\x93' },
|
||||
{ '\xf5', '\xf5', '\x6f' }, { '\xf6', '\xf6', '\x94' },
|
||||
{ '\xf9', '\xf9', '\x97' }, { '\xfa', '\xfa', '\xa3' },
|
||||
{ '\xfb', '\xfb', '\x96' }, { '\xfc', '\xfc', '\x81' },
|
||||
{ '\xff', '\xff', '\x98' }
|
||||
};
|
||||
|
||||
#endif // CODECVTE_H_INCLUDED
|
||||
193
extern/stdcxx/4.2.1/examples/include/examples.h
vendored
Normal file
193
extern/stdcxx/4.2.1/examples/include/examples.h
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* examples.h - common definitions to condition example code for broken
|
||||
* compilers; must be #included last, _after_ all lib headers.
|
||||
*
|
||||
* The goal of this file is to allow completely conforming syntax
|
||||
* in examples' code even with non-conforming compilers.
|
||||
*
|
||||
* $Id: examples.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef EXAMPLES_H_INCLUDED
|
||||
#define EXAMPLES_H_INCLUDED
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_NAMESPACE
|
||||
# define std
|
||||
#endif // _RWSTD_NO_NAMESPACE
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_TYPENAME
|
||||
# define typename
|
||||
#endif // _RWSTD_NO_TYPENAME
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_FOR_LOCAL_SCOPE
|
||||
# define for if (0) ; else for
|
||||
#endif // _RWSTD_NO_FOR_LOCAL_SCOPE
|
||||
|
||||
#include <cstddef> // for ptrdiff_t
|
||||
|
||||
#ifdef _RWSTD_NO_LIBC_IN_STD
|
||||
|
||||
_RWSTD_NAMESPACE (std) {
|
||||
|
||||
// accomdate compilers that don't have size_t in namespace std
|
||||
_USING (::size_t);
|
||||
_USING (::ptrdiff_t);
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // _RWSTD_NO_LIBC_IN_STD
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
|
||||
|
||||
// supply conforming versions of count, count_if and distance for platforms
|
||||
// that do not correctly support partial specialization of class templates
|
||||
|
||||
_RWSTD_NAMESPACE (std) {
|
||||
|
||||
template<class InputIter, class T>
|
||||
size_t count (InputIter a, InputIter b, const T& x)
|
||||
{
|
||||
size_t n = 0;
|
||||
count (a, b, x, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
template<class InputIter, class T>
|
||||
size_t count_if (InputIter a, InputIter b, const T& x)
|
||||
{
|
||||
size_t n = 0;
|
||||
count_if (a, b, x, n);
|
||||
return n;
|
||||
|
||||
}
|
||||
|
||||
template<class InputIter>
|
||||
size_t distance (InputIter a, InputIter b)
|
||||
{
|
||||
size_t n = 0;
|
||||
distance (a, b, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // _RWSTD_NO_CLASS_PARTIAL_SPEC
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
|
||||
|
||||
#if !defined (_MSC_VER) || _MSC_VER > 1300
|
||||
|
||||
_RWSTD_NAMESPACE (std) {
|
||||
|
||||
#define has_facet fake_has_facet
|
||||
#define use_facet fake_use_facet
|
||||
|
||||
// fake std::use_facet
|
||||
template <class Facet>
|
||||
struct has_facet
|
||||
{
|
||||
has_facet (const std::locale &loc)
|
||||
|
||||
#ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
|
||||
|
||||
: result (std::has_facet<Facet>(loc)) { }
|
||||
|
||||
#else
|
||||
|
||||
: result (std::has_facet (loc, (Facet*)0)) { }
|
||||
|
||||
#endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
|
||||
|
||||
operator bool () const {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool result;
|
||||
};
|
||||
|
||||
|
||||
// fake std::use_facet
|
||||
template <class Facet>
|
||||
struct use_facet
|
||||
{
|
||||
use_facet (const std::locale &loc)
|
||||
: facet (std::_USE_FACET (Facet, loc)) { }
|
||||
|
||||
operator const Facet& () const {
|
||||
return facet;
|
||||
}
|
||||
|
||||
const Facet &facet;
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#else // if defined (_MSC_VER) && _MSC_VER <= 1300
|
||||
# define _HAS_FACET(facet, locale) has_facet (locale, (facet*)0)
|
||||
#endif // !defined (_MSC_VER) || _MSC_VER > 1300
|
||||
|
||||
#endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_EXCEPTIONS
|
||||
# define try if (1)
|
||||
# define catch(ex) else if (0) for (ex ; 0 ; )
|
||||
# define throw(ignore) abort ()
|
||||
#endif // _RWSTD_NO_EXCEPTIONS
|
||||
|
||||
|
||||
#ifdef _RWSTD_NO_WCHAR_T
|
||||
|
||||
// remove `L' from wide string literals
|
||||
#define L
|
||||
|
||||
// fake wide stream objects
|
||||
#define wcin cin
|
||||
#define wcout cout
|
||||
#define wcerr cerr
|
||||
#define wclog clog
|
||||
|
||||
// fake wide string and stringstream
|
||||
#define wstring string
|
||||
#define wstringstream stringstream
|
||||
|
||||
#define wchar_t char
|
||||
|
||||
#endif // _RWSTD_NO_WCHAR_T
|
||||
|
||||
|
||||
// undefine macros #defined by some evil C libraries (e.g., MSVC)
|
||||
#undef max
|
||||
#undef min
|
||||
|
||||
|
||||
#endif // EXAMPLES_H_INCLUDED
|
||||
78
extern/stdcxx/4.2.1/examples/include/memfunref.h
vendored
Normal file
78
extern/stdcxx/4.2.1/examples/include/memfunref.h
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* memfunref.h - Header for example program for mem_fun and other
|
||||
* member function reference wrappers. See Class Reference Section
|
||||
*
|
||||
* $Id: memfunref.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef MEMFUNREF_H_INCLUDED
|
||||
#define MEMFUNREF_H_INCLUDED
|
||||
|
||||
|
||||
#include <algorithm> // for copy()
|
||||
#include <list> // for list
|
||||
#include <iterator> // for ostream_iterator
|
||||
#include <iostream> // for cout, ostream
|
||||
|
||||
|
||||
template <class T>
|
||||
class sublist
|
||||
{
|
||||
typedef std::list<T, std::allocator<T> > list_type;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename list_type::value_type value_type;
|
||||
typedef typename list_type::reference reference;
|
||||
typedef typename list_type::const_reference const_reference;
|
||||
typedef typename list_type::pointer pointer;
|
||||
typedef typename list_type::const_pointer const_pointer;
|
||||
typedef typename list_type::difference_type difference_type;
|
||||
|
||||
sublist () { }
|
||||
|
||||
sublist (const_pointer begin, const_pointer end): l (begin, end) { }
|
||||
|
||||
int sort () {
|
||||
l.sort ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int disp () const {
|
||||
typedef std::char_traits<char> traits_type;
|
||||
typedef std::ostream_iterator<value_type, char, traits_type> os_iter;
|
||||
|
||||
std::copy (l.begin (), l.end (), os_iter (std::cout, " "));
|
||||
std::cout << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
list_type l;
|
||||
};
|
||||
|
||||
|
||||
#endif // MEMFUNREF_H_INCLUDED
|
||||
61
extern/stdcxx/4.2.1/examples/include/replace.h
vendored
Normal file
61
extern/stdcxx/4.2.1/examples/include/replace.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* replace.h - Header for example program of replace algorithm
|
||||
*
|
||||
* $Id: replace.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef REPLACE_H_INCLUDED
|
||||
#define REPLACE_H_INCLUDED
|
||||
|
||||
#include <functional>
|
||||
|
||||
struct is_prime: public std::unary_function<short, bool>
|
||||
{
|
||||
bool operator() (const short&) const;
|
||||
};
|
||||
|
||||
|
||||
bool is_prime::operator() (const short &a) const
|
||||
{
|
||||
// all primes smaller than 256
|
||||
static const unsigned short primes[] = {
|
||||
2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 23, 25, 29, 31, 35,
|
||||
37, 41, 43, 47, 49, 53, 59, 61, 67, 71, 73, 79, 83, 89,
|
||||
97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139,
|
||||
143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 191,
|
||||
193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251
|
||||
};
|
||||
|
||||
const unsigned short *end = primes + sizeof primes / sizeof *primes;
|
||||
|
||||
// search primes for a divisor
|
||||
for (const unsigned short *p = primes; p != end; ++p)
|
||||
if (0 == a % *p)
|
||||
return false;
|
||||
|
||||
return 0 != a;
|
||||
}
|
||||
|
||||
#endif // REPLACE_H_INCLUDED
|
||||
39
extern/stdcxx/4.2.1/examples/include/rwstdmessages.h
vendored
Normal file
39
extern/stdcxx/4.2.1/examples/include/rwstdmessages.h
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* rwstdmessages.h - indices for error messages
|
||||
*
|
||||
* $Id: rwstdmessages.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define _RW_MSG_START 0
|
||||
#define _RW_MSG_HELLO _RW_MSG_START + 1
|
||||
#define _RW_MSG_GOODBYE _RW_MSG_START + 2
|
||||
#define _RW_MSG_TREES _RW_MSG_START + 3
|
||||
|
||||
// Not in catalog
|
||||
#define _RW_MSG_NOGOOD 6
|
||||
264
extern/stdcxx/4.2.1/examples/include/stocks.h
vendored
Normal file
264
extern/stdcxx/4.2.1/examples/include/stocks.h
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* stocks.h - Stocks program.
|
||||
*
|
||||
* $Id: stocks.h 636370 2008-03-12 15:32:56Z faridz $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef STOCKS_H_INCLUDED
|
||||
#define STOCKS_H_INCLUDED
|
||||
|
||||
#include <ctime>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
#include <stdexcept>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
#include <examples.h>
|
||||
|
||||
|
||||
// The stock exchange example displays stock quotes at various exchanges
|
||||
// distributed globally.
|
||||
|
||||
// The objective of the example is to show monetary, numeric, and date
|
||||
// and time values formated using standard and/or user-defined facets.
|
||||
|
||||
|
||||
#if defined (_AIX)
|
||||
# define US_LOCALE "en_US"
|
||||
# define GERMAN_LOCALE "de_DE"
|
||||
# define FRENCH_LOCALE "fr_FR"
|
||||
# define JAPANESE_LOCALE "ja_JP"
|
||||
#elif defined (__hpux)
|
||||
# define US_LOCALE "en_US.iso88591"
|
||||
# define GERMAN_LOCALE "de_DE.iso88591"
|
||||
# define FRENCH_LOCALE "fr_FR.iso88591"
|
||||
# define JAPANESE_LOCALE "ja_JP.eucJP"
|
||||
#elif defined (__linux__)
|
||||
# define US_LOCALE "en_US"
|
||||
# define GERMAN_LOCALE "de_DE"
|
||||
# define FRENCH_LOCALE "fr_FR"
|
||||
# define JAPANESE_LOCALE "ja_JP"
|
||||
#elif defined (__osf__)
|
||||
# define US_LOCALE "en_US.ISO8859-1"
|
||||
# define GERMAN_LOCALE "de_DE.ISO8859-1"
|
||||
# define FRENCH_LOCALE "fr_FR.ISO8859-1"
|
||||
# define JAPANESE_LOCALE "ja_JP"
|
||||
#elif defined (SNI)
|
||||
# define US_LOCALE "En"
|
||||
# define GERMAN_LOCALE "De"
|
||||
# define FRENCH_LOCALE "Fr_FR.850"
|
||||
# define JAPANESE_LOCALE "Ja_JP.932"
|
||||
#elif defined (_WIN32) || defined (_WIN64)
|
||||
# define US_LOCALE "us"
|
||||
# define GERMAN_LOCALE "german_germany.1252"
|
||||
# define FRENCH_LOCALE "french_france.1252"
|
||||
# define JAPANESE_LOCALE "japanese_japan.1252"
|
||||
#else // POSIX simple names
|
||||
# define US_LOCALE "en_US"
|
||||
# define GERMAN_LOCALE "de_DE"
|
||||
# define FRENCH_LOCALE "fr_FR"
|
||||
# define JAPANESE_LOCALE "ja_JP"
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
const int stock_change[10] = { 0, 1, -1, 2, -1, 3, -3, 4, -1, -1 };
|
||||
const int indexSize = 10;
|
||||
struct std::tm tmb;
|
||||
}
|
||||
|
||||
|
||||
struct Company
|
||||
{
|
||||
Company (const std::string &s, double p)
|
||||
: companyName (s), offerPrice (p), stockPrice (0) {}
|
||||
|
||||
//In actuality a company should not manipulate stocks.
|
||||
//For simplicity let the company play with its own stock.
|
||||
|
||||
void updateStock () {
|
||||
stockPrice = offerPrice + stockChange();
|
||||
if (stockPrice < 0)
|
||||
stockPrice = -(stockPrice);
|
||||
}
|
||||
|
||||
int stockChange () {
|
||||
return stock_change[changeIndex(true)];
|
||||
}
|
||||
|
||||
int changeIndex (bool increment = false) {
|
||||
static int i = 0;
|
||||
if(increment)
|
||||
++i;
|
||||
if (i > indexSize-1)
|
||||
i = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
std::string companyName;
|
||||
double offerPrice; //initial offer price
|
||||
double stockPrice; //current market price
|
||||
|
||||
private:
|
||||
std::string companyNews; //Make use of messaging (if at all it works !)
|
||||
|
||||
std::size_t marketOutlook() {
|
||||
return changeIndex();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct StockXchange: public std::locale::facet
|
||||
{
|
||||
typedef std::basic_ostream<char,std::char_traits<char> > outStream;
|
||||
typedef std::ostreambuf_iterator<char, std::char_traits<char> > iter_type;
|
||||
typedef std::deque<Company*,std::allocator<Company*> > database;
|
||||
|
||||
typedef std::locale::facet facet;
|
||||
|
||||
StockXchange(std::size_t refs=0): facet(refs){}
|
||||
virtual ~StockXchange();
|
||||
|
||||
static std::locale::id id;
|
||||
virtual bool put (std::ostream& os) const;
|
||||
virtual void add (const std::string& name, double initPrice);
|
||||
virtual void localTime (std::ostream&) const;
|
||||
|
||||
protected:
|
||||
database companyDatabase;
|
||||
|
||||
friend StockXchange::outStream&
|
||||
operator<< (StockXchange::outStream&, const StockXchange&);
|
||||
|
||||
private:
|
||||
|
||||
#ifdef _RWSTD_NO_MEMBER_TEMPLATES
|
||||
std::locale::id &_C_get_id () const { return id; }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct TokyoStockXchange: public StockXchange
|
||||
{
|
||||
TokyoStockXchange (std::size_t refs = 0)
|
||||
: StockXchange (refs) { }
|
||||
|
||||
virtual void localTime (std::ostream& os) const {
|
||||
// our contrived GMT time is 07:43:00, to use an actual time,
|
||||
// replace the following tmb assignments with:
|
||||
// tmb = std::gmtime (&tm);
|
||||
tmb.tm_sec = 0;
|
||||
tmb.tm_min = 43;
|
||||
tmb.tm_hour = 7;
|
||||
tmb.tm_mday = 4;
|
||||
tmb.tm_mon = 6;
|
||||
tmb.tm_year = 88;
|
||||
tmb.tm_wday = 1;
|
||||
tmb.tm_yday = 185;
|
||||
tmb.tm_isdst = 1;
|
||||
|
||||
StockXchange::localTime(os);
|
||||
}
|
||||
|
||||
virtual bool put (std::ostream& os) const {
|
||||
os << '\n';
|
||||
os << "######## TOKYO STOCK EXCHANGE #########\n";
|
||||
return StockXchange::put (os);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct FrankfurtStockXchange: public StockXchange
|
||||
{
|
||||
FrankfurtStockXchange (std::size_t refs = 0)
|
||||
: StockXchange (refs) { }
|
||||
|
||||
virtual void localTime(std::ostream& os) const {
|
||||
// our contrived GMT time is 07:43:00, to use an actual time, replace
|
||||
// the following three tmb assignments with:
|
||||
// tmb = gmtime(&tm);
|
||||
tmb.tm_hour=7;
|
||||
tmb.tm_min=43;
|
||||
tmb.tm_sec=00;
|
||||
StockXchange::localTime(os);
|
||||
}
|
||||
|
||||
virtual bool put (std::ostream& os) const {
|
||||
os << '\n';
|
||||
os << "######## FRANKFURTER WERTPAPIERB\366RSE #########\n";
|
||||
return StockXchange::put (os);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct NewYorkStockXchange: public StockXchange
|
||||
{
|
||||
NewYorkStockXchange (std::size_t refs = 0)
|
||||
: StockXchange (refs) { }
|
||||
|
||||
virtual void localTime(std::ostream& os) const {
|
||||
// our contrived GMT time is 07:43:00, for a GMT-5 of 02:43:00
|
||||
// to use an actual time, replace the following three tmb
|
||||
// assignments with:
|
||||
// tmb = localtime(&tm);
|
||||
tmb.tm_hour=2;
|
||||
tmb.tm_min=43;
|
||||
tmb.tm_sec=00;
|
||||
StockXchange::localTime(os);
|
||||
}
|
||||
|
||||
virtual bool put (std::ostream& os) const {
|
||||
os << '\n';
|
||||
os << "######## NEW YORK STOCK EXCHANGE ########\n";
|
||||
return StockXchange::put (os);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct ParisStockXchange: public StockXchange
|
||||
{
|
||||
ParisStockXchange (std::size_t refs = 0)
|
||||
: StockXchange (refs){}
|
||||
|
||||
virtual void localTime(std::ostream& os) const {
|
||||
// our contrived GMT time is 07:43:00, to use an actual time, replace
|
||||
// the following three tmb assignments with:
|
||||
// tmb = gmtime(&tm);
|
||||
tmb.tm_hour=7;
|
||||
tmb.tm_min=43;
|
||||
tmb.tm_sec=00;
|
||||
StockXchange::localTime(os);
|
||||
}
|
||||
|
||||
virtual bool put (std::ostream& os) const {
|
||||
os << '\n';
|
||||
os << "######## BOURSE DE PARIS #########\n";
|
||||
return StockXchange::put (os);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // STOCKS_H_INCLUDED
|
||||
80
extern/stdcxx/4.2.1/examples/include/teller.h
vendored
Normal file
80
extern/stdcxx/4.2.1/examples/include/teller.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* teller.h - Header for bank teller sample program.
|
||||
*
|
||||
* $Id: teller.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef TELLER_H_INCLUDED
|
||||
#define TELLER_H_INCLUDED
|
||||
|
||||
inline unsigned long int lcg_rand (int n);
|
||||
|
||||
class Customer
|
||||
{
|
||||
public:
|
||||
|
||||
int arrivalTime;
|
||||
int processTime;
|
||||
|
||||
Customer (int at = 0)
|
||||
: arrivalTime (at),
|
||||
processTime (2 + lcg_rand (6)) {}
|
||||
|
||||
bool done () { // are we done with our transaction?
|
||||
return --processTime < 0;
|
||||
}
|
||||
|
||||
bool operator< (const Customer& c) const { // order by arrival time
|
||||
return arrivalTime < c.arrivalTime;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Teller
|
||||
{
|
||||
public:
|
||||
Teller (): free (true) { }
|
||||
|
||||
bool isFree () { // are we free to service new customer?
|
||||
if (free)
|
||||
return true;
|
||||
if (customer.done())
|
||||
free = true;
|
||||
return free;
|
||||
}
|
||||
|
||||
void addCustomer (const Customer &c) { // start serving new customer
|
||||
customer = c;
|
||||
free = false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool free;
|
||||
Customer customer;
|
||||
};
|
||||
|
||||
#endif // TELLER_H_INCLUDED
|
||||
65
extern/stdcxx/4.2.1/examples/include/valarray.h
vendored
Normal file
65
extern/stdcxx/4.2.1/examples/include/valarray.h
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* valarray.h -- Header for valarray examples.
|
||||
* Provides a valarray stream inserter.
|
||||
*
|
||||
* $Id: valarray.h 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef VALARRAY_H_INCLUDED
|
||||
#define VALARRAY_H_INCLUDED
|
||||
|
||||
|
||||
#include <valarray>
|
||||
#include <ostream>
|
||||
|
||||
#include <examples.h>
|
||||
|
||||
template<class T>
|
||||
inline std::ostream&
|
||||
insert_valarray (std::ostream &out, const std::valarray<T> &v)
|
||||
{
|
||||
out << "[";
|
||||
for (std::size_t i = 0; i < v.size (); i++) {
|
||||
out << v [i];
|
||||
if (i < v.size () - 1)
|
||||
out << ",";
|
||||
}
|
||||
return out << "]";
|
||||
}
|
||||
|
||||
// Non-templatized insertion operators necessary for implicit
|
||||
// conversion from slice_array<T> (etc.) to valarray<T>. (the
|
||||
// conversion won't work in template argument deduction).
|
||||
inline std::ostream& operator<< (std::ostream &out, const std::valarray<int> &v)
|
||||
{
|
||||
return insert_valarray (out, v);
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream &out, const std::valarray<bool> &v)
|
||||
{
|
||||
return insert_valarray (out, v);
|
||||
}
|
||||
|
||||
#endif // VALARRAY_H_INCLUDED
|
||||
68
extern/stdcxx/4.2.1/examples/include/widwork.h
vendored
Normal file
68
extern/stdcxx/4.2.1/examples/include/widwork.h
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* widwork.h - header for widget works, from Chapter 6.3
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef WIDWORK_H_INCLUDED
|
||||
#define WIDWORK_H_INCLUDED
|
||||
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
class Widget {
|
||||
public:
|
||||
Widget (int a = 0) : id (a)
|
||||
{ }
|
||||
|
||||
void operator= (const Widget& rhs) {
|
||||
id = rhs.id;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<< ( std::ostream&, const Widget& );
|
||||
int id;
|
||||
};
|
||||
|
||||
typedef std::list<Widget, std::allocator<Widget> > widgetList;
|
||||
typedef std::list<int, std::allocator<int> > idList;
|
||||
|
||||
struct WidgetTester : std::binary_function<Widget, int, bool>
|
||||
{
|
||||
public:
|
||||
bool operator () (const Widget & wid, int testid) const;
|
||||
};
|
||||
|
||||
class inventory
|
||||
{
|
||||
public:
|
||||
void order (int wid); // Process order for widget type wid.
|
||||
void receive (int wid); // Receive widget of type wid in shipment.
|
||||
|
||||
private:
|
||||
widgetList on_hand;
|
||||
idList on_order;
|
||||
};
|
||||
|
||||
|
||||
#endif // WIDWORK_H_INCLUDED
|
||||
Reference in New Issue
Block a user