Classes | Functions

strfns.cc File Reference

#include <cctype>
#include <queue>
#include <sstream>
#include "dMatrix.h"
#include "Cell.h"
#include "defun.h"
#include "error.h"
#include "gripes.h"
#include "ov.h"
#include "oct-obj.h"
#include "unwind-prot.h"
#include "utils.h"
Include dependency graph for strfns.cc:

Go to the source code of this file.

Classes

struct  icmp_char_eq

Functions

 DEFUN (char, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} char (@var{x})\n\ @deftypefnx {Built-in Function} {} char (@var{x}, @dots{})\n\ @deftypefnx {Built-in Function} {} char (@var{s1}, @var{s2}, @dots{})\n\ @deftypefnx {Built-in Function} {} char (@var{cell_array})\n\ Create a string array from one or more numeric matrices, character\n\ matrices, or cell arrays. Arguments are concatenated vertically.\n\ The returned values are padded with blanks as needed to make each row\n\ of the string array have the same length. Empty input strings are\n\ significant and will concatenated in the output.\n\ \n\ For numerical input, each element is converted\n\ to the corresponding ASCII character. A range error results if an input\n\ is outside the ASCII range (0-255).\n\ \n\ For cell arrays, each element is concatenated separately. Cell arrays\n\ converted through\n\ @code{char} can mostly be converted back with @code{cellstr}.\n\ For example:\n\ \n\ @example\n\ @group\n\ char ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, \"str1\", [\"ha\", \"lf\"])\n\ @result{} [\"abc \"\n\ \" \"\n\ \"98 \"\n\ \"99 \"\n\ \"d \"\n\ \"str1 \"\n\ \"half \"]\n\ @end group\n\ @end example\n\ @seealso{strvcat, cellstr}\n\ @end deftypefn")
 DEFUN (strvcat, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} strvcat (@var{x})\n\ @deftypefnx {Built-in Function} {} strvcat (@var{x}, @dots{})\n\ @deftypefnx {Built-in Function} {} strvcat (@var{s1}, @var{s2}, @dots{})\n\ @deftypefnx {Built-in Function} {} strvcat (@var{cell_array})\n\ Create a character array from one or more numeric matrices, character\n\ matrices, or cell arrays. Arguments are concatenated vertically.\n\ The returned values are padded with blanks as needed to make each row\n\ of the string array have the same length. Unlike @code{char}, empty\n\ strings are removed and will not appear in the output.\n\ \n\ For numerical input, each element is converted\n\ to the corresponding ASCII character. A range error results if an input\n\ is outside the ASCII range (0-255).\n\ \n\ For cell arrays, each element is concatenated separately. Cell arrays\n\ converted through\n\ @code{strvcat} can mostly be converted back with @code{cellstr}.\n\ For example:\n\ \n\ @example\n\ @group\n\ strvcat ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, \"str1\", [\"ha\", \"lf\"])\n\ @result{} [\"abc \"\n\ \"98 \"\n\ \"99 \"\n\ \"d \"\n\ \"str1 \"\n\ \"half \"]\n\ @end group\n\ @end example\n\ @seealso{char, strcat, cstrcat}\n\ @end deftypefn")
 DEFUN (list_in_columns, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} list_in_columns (@var{arg}, @var{width})\n\ Return a string containing the elements of @var{arg} listed in\n\ columns with an overall maximum width of @var{width}. The argument\n\ @var{arg} must be a cell array of character strings or a character array.\n\ If @var{width} is not specified, the width of the terminal screen is used.\n\ Newline characters are used to break the lines in the output string.\n\ For example:\n\ @c Set example in small font to prevent overfull line\n\ \n\ @smallexample\n\ @group\n\ list_in_columns (@{\"abc\", \"def\", \"ghijkl\", \"mnop\", \"qrs\", \"tuv\"@}, 20)\n\ @result{} ans = abc mnop\n\ def qrs\n\ ghijkl tuv\n\ \n\ whos ans\n\ @result{}\n\ Variables in the current scope:\n\ \n\ Attr Name Size Bytes Class\n\ ==== ==== ==== ===== =====\n\ ans 1x37 37 char\n\ \n\ Total is 37 elements using 37 bytes\n\ @end group\n\ @end smallexample\n\ \n\ @seealso{terminal_size}\n\ @end deftypefn")
 DEFUN (strncmp, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} strncmp (@var{s1}, @var{s2}, @var{n})\n\ Return 1 if the first @var{n} characters of strings @var{s1} and @var{s2} are\n\ the same, and 0 otherwise.\n\ \n\ @example\n\ @group\n\ strncmp (\"abce\", \"abcd\", 3)\n\ @result{} 1\n\ @end group\n\ @end example\n\ \n\ If either @var{s1} or @var{s2} is a cell array of strings, then an array\n\ of the same size is returned, containing the values described above for\n\ every member of the cell array. The other argument may also be a cell\n\ array of strings (of the same size or with only one element), char matrix\n\ or character string.\n\ \n\ @example\n\ @group\n\ strncmp (\"abce\", @{\"abcd\", \"bca\", \"abc\"@}, 3)\n\ @result{} [1, 0, 1]\n\ @end group\n\ @end example\n\ \n\ @strong{Caution:} For compatibility with @sc{matlab}, Octave's strncmp\n\ function returns 1 if the character strings are equal, and 0 otherwise.\n\ This is just the opposite of the corresponding C library function.\n\ @seealso{strncmpi, strcmp, strcmpi}\n\ @end deftypefn")
 DEFUN (ischar, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} ischar (@var{x})\n\ Return true if @var{x} is a character array.\n\ @seealso{isfloat, isinteger, islogical, isnumeric, iscellstr, isa}\n\ @end deftypefn")
 DEFUN (strcmp, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} strcmp (@var{s1}, @var{s2})\n\ Return 1 if the character strings @var{s1} and @var{s2} are the same,\n\ and 0 otherwise.\n\ \n\ If either @var{s1} or @var{s2} is a cell array of strings, then an array\n\ of the same size is returned, containing the values described above for\n\ every member of the cell array. The other argument may also be a cell\n\ array of strings (of the same size or with only one element), char matrix\n\ or character string.\n\ \n\ @strong{Caution:} For compatibility with @sc{matlab}, Octave's strcmp\n\ function returns 1 if the character strings are equal, and 0 otherwise.\n\ This is just the opposite of the corresponding C library function.\n\ @seealso{strcmpi, strncmp, strncmpi}\n\ @end deftypefn")
 DEFUNX ("strncmpi", Fstrncmpi, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} strncmpi (@var{s1}, @var{s2}, @var{n})\n\ Return 1 if the first @var{n} character of @var{s1} and @var{s2} are the\n\ same, disregarding case of alphabetic characters, and 0 otherwise.\n\ \n\ If either @var{s1} or @var{s2} is a cell array of strings, then an array\n\ of the same size is returned, containing the values described above for\n\ every member of the cell array. The other argument may also be a cell\n\ array of strings (of the same size or with only one element), char matrix\n\ or character string.\n\ \n\ @strong{Caution:} For compatibility with @sc{matlab}, Octave's strncmpi\n\ function returns 1 if the character strings are equal, and 0 otherwise.\n\ This is just the opposite of the corresponding C library function.\n\ \n\ @strong{Caution:} National alphabets are not supported.\n\ @seealso{strncmp, strcmp, strcmpi}\n\ @end deftypefn")
 DEFUNX ("strcmpi", Fstrcmpi, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} strcmpi (@var{s1}, @var{s2})\n\ Return 1 if the character strings @var{s1} and @var{s2} are the same,\n\ disregarding case of alphabetic characters, and 0 otherwise.\n\ \n\ If either @var{s1} or @var{s2} is a cell array of strings, then an array\n\ of the same size is returned, containing the values described above for\n\ every member of the cell array. The other argument may also be a cell\n\ array of strings (of the same size or with only one element), char matrix\n\ or character string.\n\ \n\ @strong{Caution:} For compatibility with @sc{matlab}, Octave's strcmp\n\ function returns 1 if the character strings are equal, and 0 otherwise.\n\ This is just the opposite of the corresponding C library function.\n\ \n\ @strong{Caution:} National alphabets are not supported.\n\ @seealso{strcmp, strncmp, strncmpi}\n\ @end deftypefn")
static octave_value do_strcmp_fun (const octave_value &arg0, const octave_value &arg1, octave_idx_type n, const char *fcn_name, bool(*array_op)(const charNDArray &, const charNDArray &, octave_idx_type), bool(*str_op)(const std::string &, const std::string &, octave_idx_type))
static bool strcmp_array_op (const charNDArray &s1, const charNDArray &s2, octave_idx_type)
static bool strcmp_str_op (const std::string &s1, const std::string &s2, octave_idx_type)
static bool strcmpi_array_op (const charNDArray &s1, const charNDArray &s2, octave_idx_type)
static bool strcmpi_str_op (const std::string &s1, const std::string &s2, octave_idx_type)
static bool strncmp_array_op (const charNDArray &s1, const charNDArray &s2, octave_idx_type n)
static bool strncmp_str_op (const std::string &s1, const std::string &s2, octave_idx_type n)
static bool strncmpi_array_op (const charNDArray &s1, const charNDArray &s2, octave_idx_type n)
static bool strncmpi_str_op (const std::string &s1, const std::string &s2, octave_idx_type n)

Function Documentation

DEFUN ( char  ,
args   
)
DEFUN ( strvcat  ,
args   
)
DEFUN ( list_in_columns  ,
args   
)

Definition at line 856 of file strfns.cc.

References error(), error_state, string_vector::list_in_columns(), and print_usage().

DEFUN ( strncmp  ,
args   
)
DEFUN ( ischar  ,
args   
)

Definition at line 304 of file strfns.cc.

References octave_value::is_defined(), octave_value::is_string(), and print_usage().

DEFUN ( strcmp  ,
args   
)

Definition at line 560 of file strfns.cc.

References do_strcmp_fun(), print_usage(), strcmp_array_op(), and strcmp_str_op().

DEFUNX ( "strncmpi"  ,
Fstrncmpi  ,
args   
)
DEFUNX ( "strcmpi"  ,
Fstrcmpi  ,
args   
)

Definition at line 752 of file strfns.cc.

References do_strcmp_fun(), print_usage(), strcmpi_array_op(), and strcmpi_str_op().

static octave_value do_strcmp_fun ( const octave_value arg0,
const octave_value arg1,
octave_idx_type  n,
const char fcn_name,
bool(*)(const charNDArray &, const charNDArray &, octave_idx_type array_op,
bool(*)(const std::string &, const std::string &, octave_idx_type str_op 
) [static]
static bool strcmp_array_op ( const charNDArray s1,
const charNDArray s2,
octave_idx_type   
) [static]

Definition at line 546 of file strfns.cc.

References Array< T >::data(), Array< T >::dims(), and Array< T >::numel().

Referenced by DEFUN().

static bool strcmp_str_op ( const std::string &  s1,
const std::string &  s2,
octave_idx_type   
) [static]

Definition at line 554 of file strfns.cc.

Referenced by DEFUN().

static bool strcmpi_array_op ( const charNDArray s1,
const charNDArray s2,
octave_idx_type   
) [static]

Definition at line 735 of file strfns.cc.

References Array< T >::data(), Array< T >::dims(), and Array< T >::numel().

Referenced by DEFUNX().

static bool strcmpi_str_op ( const std::string &  s1,
const std::string &  s2,
octave_idx_type   
) [static]

Definition at line 744 of file strfns.cc.

Referenced by DEFUNX().

static bool strncmp_array_op ( const charNDArray s1,
const charNDArray s2,
octave_idx_type  n 
) [static]

Definition at line 641 of file strfns.cc.

References Array< T >::data(), and Array< T >::numel().

Referenced by DEFUN().

static bool strncmp_str_op ( const std::string &  s1,
const std::string &  s2,
octave_idx_type  n 
) [static]

Definition at line 652 of file strfns.cc.

Referenced by DEFUN().

static bool strncmpi_array_op ( const charNDArray s1,
const charNDArray s2,
octave_idx_type  n 
) [static]

Definition at line 791 of file strfns.cc.

References Array< T >::data(), and Array< T >::numel().

Referenced by DEFUNX().

static bool strncmpi_str_op ( const std::string &  s1,
const std::string &  s2,
octave_idx_type  n 
) [static]

Definition at line 801 of file strfns.cc.

Referenced by DEFUNX().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines