Functions

str2double.cc File Reference

#include <string>
#include <cctype>
#include <sstream>
#include <algorithm>
#include "lo-ieee.h"
#include "Cell.h"
#include "ov.h"
#include "defun-dld.h"
#include "gripes.h"
#include "utils.h"
Include dependency graph for str2double.cc:

Go to the source code of this file.

Functions

 DEFUN_DLD (str2double, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} str2double (@var{s})\n\ Convert a string to a real or complex number.\n\ \n\ The string must be in one of the following formats where\n\ a and b are real numbers and the complex unit is 'i' or 'j':\n\ \n\ @itemize\n\ @item a + bi\n\ \n\ @item a + b*i\n\ \n\ @item a + i*b\n\ \n\ @item bi + a\n\ \n\ @item b*i + a\n\ \n\ @item i*b + a\n\ @end itemize\n\ \n\ If present, a and/or b are of the form @nospell{[+-]d[,.]d[[eE][+-]d]} where\n\ the brackets indicate optional arguments and 'd' indicates zero or more\n\ digits. The special input values @code{Inf}, @code{NaN}, and @code{NA} are\n\ also accepted.\n\ \n\ @var{s} may also be a character matrix, in which case the conversion is\n\ repeated for each row. Or @var{s} may be a cell array of strings, in which\n\ case each element is converted and an array of the same dimensions is\n\ returned.\n\ \n\ @code{str2double} returns NaN for elements of @var{s} which cannot be\n\ converted.\n\ \n\ @code{str2double} can replace @code{str2num}, and it avoids the security\n\ risk of using @code{eval} on unknown data.\n\ @seealso{str2num}\n\ @end deftypefn")
static std::istringstream & extract_num (std::istringstream &is, double &num, bool &imag, bool &have_sign)
static bool is_imag_unit (int c)
static void set_component (Complex &c, double num, bool imag)
static std::istringstream & single_num (std::istringstream &is, double &num)
static Complex str2double1 (const std::string &str_arg)

Function Documentation

DEFUN_DLD ( str2double  ,
args   
)
static std::istringstream& extract_num ( std::istringstream &  is,
double num,
bool imag,
bool have_sign 
) [static]

Definition at line 99 of file str2double.cc.

References is_imag_unit(), and single_num().

Referenced by str2double1().

static bool is_imag_unit ( int  c  )  [inline, static]

Definition at line 42 of file str2double.cc.

Referenced by extract_num().

static void set_component ( Complex c,
double  num,
bool  imag 
) [inline, static]

Definition at line 217 of file str2double.cc.

Referenced by str2double1().

static std::istringstream& single_num ( std::istringstream &  is,
double num 
) [static]

Definition at line 46 of file str2double.cc.

References c1, octave_Inf, octave_NA, and octave_NaN.

Referenced by extract_num().

static Complex str2double1 ( const std::string &  str_arg  )  [static]

Definition at line 238 of file str2double.cc.

References extract_num(), octave_NaN, and set_component().

Referenced by DEFUN_DLD().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines