This class is available for the OPUS Blackboard API. The initial OPUS 2.0 release is described here
Constructors:
Str_to_num( ) | Constructor |
~Str_to_num( ) | Destructor |
Methods:
assign( ) | reassign the string value of the object |
convert( ) | convert string values to numerical datatypes. |
Description
This class converts a string value to int, double, long, bool, short datatypes.
Example
#include "str_to_num.h" using namespace std; int main(int argc, char* argv[]) { int num_blocks; string minblocks("50000"); Str_to_num ns(minblocks); ns.convert(num_blocks); }
See Also:
Str_to_num::Str_to_num - The Str_to_num constructor.
Synopsis
Str_to_num::Str_to_num( const string& s) // I - string to initialize from Str_to_num::Str_to_num( const char* s) // I - string to initialize from
Description
Constructor for the Str_to_num object. Initializes the object's private members.
Exceptions Thrown
Example
Str_to_num ns("3.7");
Str_to_num::~Str_to_num - The Str_to_num destructor.
Synopsis
Str_to_num::~Str_to_num()
Description
Destroys the object.
Exceptions Thrown
Str_to_num::convert - Append argument to string.
Synopsis
void Str_to_num::convert(int &i) void Str_to_num::convert(unsigned int &i) void Str_to_num::convert(long &i) void Str_to_num::convert(unsigned long &i) void Str_to_num::convert(bool &b) void Str_to_num::convert(string &s) void Str_to_num::convert(char *c) void Str_to_num::convert (double &f) void Str_to_num::convert(float &f) void Str_to_num::convert(short int &i) void Str_to_num::convert(unsigned short &i)
Description
Converts the string to the required return type.
Returns
The string converted to the desired return type.
Exceptions Thrown
Bad_val | - String cannot be converted to desired type |
Example
Num_in_str ns("3.7"); float num1; ns.covert(num1);
Str_to_num::assign - Assign a string to the object.
Synopsis
void Str_to_num::assign( const string& s) // I - string to initialize from
Description
The string value of this object is set to the argument value.
Exceptions Thrown
Copyright © 1997-2000 The Association of Universities for
Research in Astronomy, Inc. All Rights Reserved.
For more information, contact opushelp@stsci.edu
Last modified: 25 April 2000