num_get man page on SunOS

Man page or keyword search:  
man Server   20652 pages
apropos Keyword Search (all sections)
Output format
SunOS logo
[printable version]

num_get(3C++)			       -			 num_get(3C++)

Standard C++ Library Copyright 1998, Rogue Wave Software, Inc.

NAME
       num_get

	- A numeric formatting facet for input.

SYNOPSIS
#include <locale>
template <;class charT, class InputIterator > class num_get;

DESCRIPTION
       The   num_get   facet   allows	for   formatted	  input	  of  numbers.
       basic_istream_and all other input-oriented streams use  this  facet  to
       implement formatted numeric input.

INTERFACE
       template <class charT, class InputIterator =
 istreambuf_iterator<charT> >
class num_get : public locale::facet {
public:
 typedef charT		  char_type;
 typedef InputIterator	  iter_type;
 explicit num_get(size_t refs = 0);
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, bool&)	   const;
 iter_type get(iter_type, iter_type, ios_base& ,
	       ios_base::iostate&, long&)	   const;
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, unsigned short&) const;
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, unsigned int&)  const;
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, unsigned long&) const;
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, float&)	   const;
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, double&)	   const;
 iter_type get(iter_type, iter_type, ios_base&,
	       ios_base::iostate&, long double&)   const;
 static locale::id id;

protected:
  ~num_get();  // virtual
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&, bool&) const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&, long&) const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&,
			  unsigned short&) const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&,
			  unsigned int&) const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&,
			  unsigned long&) const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&, float&)
			  const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&, double&)
			  const;
 virtual iter_type do_get(iter_type, iter_type, ios_base&,
			  ios_base::iostate&,
			  long double&) const;
};

TYPES
       char_type

   Type of character the facet is instantiated on.

iter_type

   Type of iterator used to scan the character buffer.

CONSTRUCTORS
       explicit num_get(size_t refs = 0)

   Construct  a	 num_get facet. If the refs argument is 0, then destruction of
   the object is delegated to the locale,  or  locales,	 containing  it.  This
   allows the user to ignore lifetime management issues. On the other hand, if
   refs is 1, then the object must be explicitly deleted; the locale does  not
   do  so.  In	this case, the object can be maintained across the lifetime of
   multiple locales.

DESTRUCTORS
       ~num_get();  // virtual and protected

   Destroys the facet.

FACET ID
       static locale::id id;

   Unique identifier for this type of facet.

PUBLIC MEMBER FUNCTIONS
       The public members of the num_get facet include an  interface  to  pro‐
       tected members. Each public member xxx has a corresponding virtual pro‐
       tected member do_xxx. All work is delegated to these protected members.
       For  instance, the long version of the public get function simply calls
       its protected cousin do_get.

       iter_type
       get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, bool& v)	     const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, long& v)	     const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, unsigned short& v) const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, unsigned int& v)  const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, unsigned long& v) const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, float& v) const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, double& v) const;
iter_type
get(iter_type in, iter_type end, ios_base& io,
   ios_base::iostate& err, long double& v) const;

   Each of the eight overloads of the get function simply call the correspond‐
   ing do_get function.

PROTECTED MEMBER FUNCTIONS
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err, bool& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err, long& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err,
      unsigned short& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err,
      unsigned int& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err,
      unsigned long& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err, float& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& err, double& v) const;
virtual iter_type
do_get(iter_type in, iter_type end, ios_base& io,
      ios_base::iostate& long double& v) const;

   The	eight  overloads  of the do_get member function all take a sequence of
   characters [int,end), and extract a numeric value.  The  numeric  value  is
   returned  in	 v.   The io argument is used to obtain formatting information
   and the err argument is used to set error conditions in a calling stream.

EXAMPLE
//
// numget.cpp
//

#include <sstream>

int main ()
{
 using namespace std;

typedef istreambuf_iterator<;char,char_traits<char> >
 iter_type;

 locale loc;
 ios_base::iostate state;
 bool bval = false;
 long lval = 0L;
 long double ldval = 0.0;
 iter_type end;

  // Get a num_get facet
 const num_get<char,iter_type>& tg =
#ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
 use_facet<num_get<char,iter_type> >(loc);
#else
 use_facet(loc,(num_get<char,iter_type>*)0);
#endif

  {
    // Build an istringstream from the buffer and construct
    // beginning and ending iterators on it.
   istringstream ins("true");
   iter_type begin(ins);

    // Get a bool value
   tg.get(begin,end,ins,state,bval);
  }
 cout << bval << endl;
  {
    // Get a long value
   istringstream ins("2422235");
   iter_type begin(ins);
   tg.get(begin,end,ins,state,lval);
  }
 cout << lval << endl;
  {
    // Get a long double value
   istringstream ins("32324342.98908");
   iter_type begin(ins);
   tg.get(begin,end,ins,state,ldval);
  }
 cout << ldval << endl;
 return 0;
}

SEE ALSO
       locale, facets, num_put, numpunct, ctype

Rogue Wave Software		  02 Apr 1998			 num_get(3C++)
[top]

List of man pages available for SunOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net