54 const char pat[] =
"%c";
56 typedef std::time_put<char, iter_type>
TimePut;
57 const TimePut& tp = std::use_facet<TimePut>(
os.getloc ());
61 tp.put (begin,
os,
' ', &tmb, &pat [0], pat +
sizeof pat - 1);
74 std::locale
loc =
os.getloc ();
77 typedef std::moneypunct<char, false> MoneyPunct;
78 const MoneyPunct &mpunct = std::use_facet<MoneyPunct>(
loc);
80 typedef std::num_put<char, iter_type>
NumPut;
81 const NumPut &np = std::use_facet<NumPut>(
loc);
83 os <<
"\nCompany" <<
"\t\t\t" <<
"Initial Price" <<
"\t"
84 <<
"Current Price" <<
"\t" <<
"Volume\n"
85 <<
"-------" <<
"\t\t\t" <<
"------------" <<
"\t"
86 <<
"----------" <<
"\t" <<
"______\n\n";
98 os << info->companyName <<
"\t\t";
99 os << mpunct.curr_symbol ();
100 np.put (itbegin,
os,
' ', info->offerPrice);
102 os << mpunct.curr_symbol ();
103 np.put (itbegin,
os,
' ', info->stockPrice);
105 long volume = stock_change[info->changeIndex ()]*1000L;
108 np.put (itbegin,
os,
' ', volume);
118 const std::locale
loc =
os.getloc ();
127 typedef std::pair<StockXchange*, std::locale> sl_pair;
128 typedef std::deque<sl_pair, std::allocator<sl_pair> > Xchange;
131 std::ostream
os (std::cout.rdbuf ());
132 const std::locale
loc (
os.getloc ());
136 std::cerr <<
"\nNot a valid locale: " <<
US_LOCALE <<
'\n';
139 nse->
add (
"Hyper Software", 20.50);
140 nse->
add (
"Florida Fish", 15.10);
141 nse->
add (
"Inka Inc", 9.50);
142 nse->
add (
"Emory Chemicals", 11.00);
144 os.imbue (std::locale (std::locale (
US_LOCALE), nse));
145 sXchange.push_front (sl_pair (nse,
os.getloc ()));
151 std::cerr<<
"\nNot a valid locale: " <<
GERMAN_LOCALE <<
'\n';
154 fse->
add (
"B\166rsen-Software", 9.75);
155 fse->
add (
"M\174nchner R\174ck", 19.75);
158 sXchange.push_front (sl_pair (fse,
os.getloc ()));
164 std::cerr <<
"\nNot a valid locale: " <<
FRENCH_LOCALE <<
'\n';
167 pse->
add (
"Wines Inc.", 11.50);
168 pse->
add (
"Eiffel Co.", 11.50);
171 sXchange.push_front (sl_pair (pse,
os.getloc ()));
180 tse->
add (
"Akiro Electronics", 12.30);
183 sXchange.push_front (sl_pair (tse,
os.getloc ()));
187 for (
char q =
'\0'; ; ) {
188 std::cout <<
"\nWant to see another quote [enter 'q' to quit] ?";
191 Xchange::const_iterator it_begin = sXchange.begin ();
192 Xchange::const_iterator it_end = sXchange.end ();
193 while (it_begin < it_end) {
194 os.imbue ((*it_begin).second);
195 os << (*(*it_begin).first);
std::time_put< char > TimePut
std::ostream & operator<<(std::ostream &os, const StockXchange &)
static std::locale::id id
virtual bool put(std::ostream &os) const
virtual void localTime(std::ostream &) const
std::ostreambuf_iterator< char, std::char_traits< char > > iter_type
virtual void add(const std::string &name, double initPrice)