ajstr.c

Datatypes: char* AjPStr const AjPStr AjIStr AjPStrTok


Datatype: char*

C character string

Sections: constructors destructors formatting comparison comparison (sorting) parsing functions


Section: constructors

Functions for constructing C-type (char*) strings, possibly with a starting string.

Functions: ajCharNewC ajCharNewS ajCharNewRes ajCharNewResC ajCharNewResS ajCharNewResLenC ajCharNull


Function ajCharNewC

A text string constructor which allocates memory for a string and initialises it with the text string provided.

Synopsis

Prototype
char* ajCharNewC (
      const char* txt
);

TypeNameRead/WriteDescription
const char*txtInputInitial text, possibly shorter than the space allocated.
char* RETURNA new text string.

Input
txt:(Input)Initial text, possibly shorter than the space allocated.
Returns
char*:A new text string.

Description

A text string constructor which allocates memory for a string and initialises it with the text string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharNewS

A text string constructor which allocates memory for a string and initialises it with the string provided.

Synopsis

Prototype
char* ajCharNewS (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString object as initial value and size for the text.
char* RETURNA new text string.

Input
str:(Input)String object as initial value and size for the text.
Returns
char*:A new text string.

Description

A text string constructor which allocates memory for a string and initialises it with the string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharNewRes

A text string constructor which allocates memory for a string of the specified length and initialises the contents as an empty string.

Synopsis

Prototype
char* ajCharNewRes (
      size_t size
);

TypeNameRead/WriteDescription
size_tsizeInputLength of the Cstring, excluding the trailing NULL.
char* RETURNA new text string with no contents.

Input
size:(Input)Length of the Cstring, excluding the trailing NULL.
Returns
char*:A new text string with no contents.

Description

A text string constructor which allocates memory for a string of the specified length and initialises the contents as an empty string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharNewResC

A text string constructor which allocates memory for a string of the specified length and initialises it with the text string provided.

Synopsis

Prototype
char* ajCharNewResC (
      const char* txt,
      size_t size
);

TypeNameRead/WriteDescription
const char*txtInputString object as initial value and size for the text.
size_tsizeInputMaximum string length, as returned by strlen
char* RETURNA new text string.

Input
txt:(Input)String object as initial value and size for the text.
size:(Input)Maximum string length, as returned by strlen
Returns
char*:A new text string.

Description

A text string constructor which allocates memory for a string of the specified length and initialises it with the text string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharNewResS

A text string constructor which allocates memory for a string of the specified length and initialises it with the string provided.

Synopsis

Prototype
char* ajCharNewResS (
      const AjPStr str,
      size_t size
);

TypeNameRead/WriteDescription
const AjPStrstrInputString object as initial value and size for the text.
size_tsizeInputMaximum string length, as returned by strlen
char* RETURNA new text string.

Input
str:(Input)String object as initial value and size for the text.
size:(Input)Maximum string length, as returned by strlen
Returns
char*:A new text string.

Description

A text string constructor which allocates memory for a string of the specified length and initialises it with the string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharNewResLenC

A text string constructor which allocates memory for a string of the specified length and initialises it with the text string provided.

Synopsis

Prototype
char* ajCharNewResLenC (
      const char* txt,
      size_t size,
      size_t len
);

TypeNameRead/WriteDescription
const char*txtInputString object as initial value and size for the text.
size_tsizeInputMaximum string length, as returned by strlen
size_tlenInputLength of txt to save calculation time.
char* RETURNA new text string.

Input
txt:(Input)String object as initial value and size for the text.
size:(Input)Maximum string length, as returned by strlen
len:(Input)Length of txt to save calculation time.
Returns
char*:A new text string.

Description

A text string constructor which allocates memory for a string of the specified length and initialises it with the text string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharNull

Returns a pointer to an empty string

Synopsis

Prototype
char* ajCharNull (
      void
);

TypeNameRead/WriteDescription
char* RETURNEmpty string

Returns
char*:Empty string

Description

Returns a pointer to an empty string

See Also

See other functions in this section

Availability

In release 6.4.0

Section: destructors

Functions for destruction of C-type (char*) strings.

Functions: ajCharDel


Function ajCharDel

A text string destructor to free memory for a text string.

Synopsis

Prototype
void ajCharDel (
      char** Ptxt
);

TypeNameRead/WriteDescription
char**PtxtDeleteText string to be deallocated.
void RETURN

Output
Ptxt:(Delete)Text string to be deallocated.
Returns
void:No return value

Description

A text string destructor to free memory for a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: formatting

Functions for formatting C-type (char*) strings).

Functions: ajCharFmtLower ajCharFmtUpper


Function ajCharFmtLower

Converts a text string to lower case.

Synopsis

Prototype
AjBool ajCharFmtLower (
      char* txt
);

TypeNameRead/WriteDescription
char*txtModifyText string
AjBool RETURNajTrue on success

Input & Output
txt:(Modify)Text string
Returns
AjBool:ajTrue on success

Description

Converts a text string to lower case.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharFmtUpper

Converts a text string to upper case.

Synopsis

Prototype
AjBool ajCharFmtUpper (
      char* txt
);

TypeNameRead/WriteDescription
char*txtModifyText string
AjBool RETURNajTrue on success

Input & Output
txt:(Modify)Text string
Returns
AjBool:ajTrue on success

Description

Converts a text string to upper case.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: comparison

Functions for comparing C-type (char*) strings.

Functions: ajCharMatchC ajCharMatchCaseC ajCharMatchWildC ajCharMatchWildS ajCharMatchWildCaseC ajCharMatchWildCaseS ajCharMatchWildNextC ajCharMatchWildNextCaseC ajCharMatchWildWordC ajCharMatchWildWordCaseC ajCharPrefixC ajCharPrefixS ajCharPrefixCaseC ajCharPrefixCaseS ajCharSuffixC ajCharSuffixS ajCharSuffixCaseC ajCharSuffixCaseS


Function ajCharMatchC

Simple test for matching two text strings.

Synopsis

Prototype
AjBool ajCharMatchC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
AjBool RETURNajTrue if text completely matches the start of String

Input
txt:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if text completely matches the start of String

Description

Simple test for matching two text strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchCaseC

Simple case-insensitive test for matching two text strings.

Synopsis

Prototype
AjBool ajCharMatchCaseC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
AjBool RETURNajTrue if two strings are exactly the same excluding case

Input
txt:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if two strings are exactly the same excluding case

Description

Simple case-insensitive test for matching two text strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildC

Simple case-sensitive test for matching two text strings using wildcard characters.

Synopsis

Prototype
AjBool ajCharMatchWildC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
AjBool RETURNajTrue if the strings match

Input
txt:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if the strings match

Description

Simple case-sensitive test for matching two text strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildS

Simple case-sensitive test for matching a text string and a string using wildcard characters.

Synopsis

Prototype
AjBool ajCharMatchWildS (
      const char* txt,
      const AjPStr str
);

TypeNameRead/WriteDescription
const char*txtInputString
const AjPStrstrInputWildcard text
AjBool RETURNajTrue if the strings match

Input
txt:(Input)String
str:(Input)Wildcard text
Returns
AjBool:ajTrue if the strings match

Description

Simple case-sensitive test for matching a text string and a string using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildCaseC

Simple case-insensitive test for matching two text strings using wildcard characters.

Synopsis

Prototype
AjBool ajCharMatchWildCaseC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
AjBool RETURNajTrue if the strings match

Input
txt:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if the strings match

Description

Simple case-insensitive test for matching two text strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildCaseS

Simple case-insensitive test for matching a text string and a string using wildcard characters.

Synopsis

Prototype
AjBool ajCharMatchWildCaseS (
      const char* txt,
      const AjPStr str
);

TypeNameRead/WriteDescription
const char*txtInputString
const AjPStrstrInputWildcard text
AjBool RETURNajTrue if the strings match

Input
txt:(Input)String
str:(Input)Wildcard text
Returns
AjBool:ajTrue if the strings match

Description

Simple case-insensitive test for matching a text string and a string using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildNextC

Test for matching the next 'word' in two text strings using wildcard characters.

Synopsis

Prototype
AjBool ajCharMatchWildNextC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
AjBool RETURNajTrue if found

Input
txt:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Test for matching the next 'word' in two text strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildNextCaseC

Test for matching the next 'word' in two text strings using wildcard characters, case-insensitive.

Synopsis

Prototype
AjBool ajCharMatchWildNextCaseC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
AjBool RETURNajTrue if found

Input
txt:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Test for matching the next 'word' in two text strings using wildcard characters, case-insensitive.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildWordC

Case-sensitive test for matching a text string 'word' against any word in a test text string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

Synopsis

Prototype
AjBool ajCharMatchWildWordC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputWildcard word
AjBool RETURNajTrue if found

Input
txt:(Input)String
txt2:(Input)Wildcard word
Returns
AjBool:ajTrue if found

Description

Case-sensitive test for matching a text string 'word' against any word in a test text string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharMatchWildWordCaseC

Case-insensitive test for matching a text string 'word' against any word in a text string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

Synopsis

Prototype
AjBool ajCharMatchWildWordCaseC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputWildcard word
AjBool RETURNajTrue if found

Input
txt:(Input)String
txt2:(Input)Wildcard word
Returns
AjBool:ajTrue if found

Description

Case-insensitive test for matching a text string 'word' against any word in a text string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharPrefixC

Test for matching the start of a text string against a given prefix text string.

Synopsis

Prototype
AjBool ajCharPrefixC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputTest string as text
const char*txt2InputPrefix as text
AjBool RETURNajTrue if the string begins with the prefix

Input
txt:(Input)Test string as text
txt2:(Input)Prefix as text
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Test for matching the start of a text string against a given prefix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharPrefixS

Test for matching the start of a text string against a given prefix string.

Synopsis

Prototype
AjBool ajCharPrefixS (
      const char* txt,
      const AjPStr str
);

TypeNameRead/WriteDescription
const char*txtInputTest string as text
const AjPStrstrInputPrefix as string
AjBool RETURNajTrue if the string begins with the prefix

Input
txt:(Input)Test string as text
str:(Input)Prefix as string
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Test for matching the start of a text string against a given prefix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharPrefixCaseC

Case-insensitive test for matching the start of a text string against a given prefix text string.

Synopsis

Prototype
AjBool ajCharPrefixCaseC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputText
const char*txt2InputPrefix
AjBool RETURNajTrue if the string begins with the prefix

Input
txt:(Input)Text
txt2:(Input)Prefix
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Case-insensitive test for matching the start of a text string against a given prefix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharPrefixCaseS

Case-insensitive test for matching start of a text string against a given prefix string,

Synopsis

Prototype
AjBool ajCharPrefixCaseS (
      const char* txt,
      const AjPStr str
);

TypeNameRead/WriteDescription
const char*txtInputText
const AjPStrstrInputPrefix
AjBool RETURNajTrue if the string begins with the prefix

Input
txt:(Input)Text
str:(Input)Prefix
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Case-insensitive test for matching start of a text string against a given prefix string,

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharSuffixC

Test for matching the end of a text string against a given suffix text string.

Synopsis

Prototype
AjBool ajCharSuffixC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputSuffix as text
AjBool RETURNajTrue if the string ends with the suffix

Input
txt:(Input)String
txt2:(Input)Suffix as text
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Test for matching the end of a text string against a given suffix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharSuffixS

Test for matching the end of a text string against a given suffix string.

Synopsis

Prototype
AjBool ajCharSuffixS (
      const char* txt,
      const AjPStr str
);

TypeNameRead/WriteDescription
const char*txtInputTest string as text
const AjPStrstrInputSuffix as string
AjBool RETURNajTrue if the string ends with the suffix

Input
txt:(Input)Test string as text
str:(Input)Suffix as string
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Test for matching the end of a text string against a given suffix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharSuffixCaseC

Case-insensitive test for matching the end of a text string against a given suffix text string.

Synopsis

Prototype
AjBool ajCharSuffixCaseC (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputSuffix as text
AjBool RETURNajTrue if the string ends with the suffix

Input
txt:(Input)String
txt2:(Input)Suffix as text
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Case-insensitive test for matching the end of a text string against a given suffix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharSuffixCaseS

Case-insensitive test for matching the end of a text string against a given suffix string.

Synopsis

Prototype
AjBool ajCharSuffixCaseS (
      const char* txt,
      const AjPStr str
);

TypeNameRead/WriteDescription
const char*txtInputTest string as text
const AjPStrstrInputSuffix as string
AjBool RETURNajTrue if the string ends with the suffix

Input
txt:(Input)Test string as text
str:(Input)Suffix as string
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Case-insensitive test for matching the end of a text string against a given suffix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: comparison (sorting)

Functions for sorting strings (including C-type char* strings).

Functions: ajCharCmpCase ajCharCmpCaseLen ajCharCmpWild ajCharCmpWildCase


Function ajCharCmpCase

Finds the sort order of two text strings.

Synopsis

Prototype
int ajCharCmpCase (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputText string
const char*txt2InputText string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
txt:(Input)Text string
txt2:(Input)Text string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of two text strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharCmpCaseLen

Finds the sort order of substrings from the start of two text strings.

Synopsis

Prototype
int ajCharCmpCaseLen (
      const char* txt,
      const char* txt2,
      size_t len
);

TypeNameRead/WriteDescription
const char*txtInputText string
const char*txt2InputText string
size_tlenInputlength
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
txt:(Input)Text string
txt2:(Input)Text string
len:(Input)length
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of substrings from the start of two text strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharCmpWild

Finds the sort-order (case insensitive) of two text strings using wildcard characters.

Synopsis

Prototype
int ajCharCmpWild (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
txt:(Input)String
txt2:(Input)Text
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort-order (case insensitive) of two text strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajCharCmpWildCase

Finds the sort-order (case sensitive) of two text strings using wildcard characters.

Synopsis

Prototype
int ajCharCmpWildCase (
      const char* txt,
      const char* txt2
);

TypeNameRead/WriteDescription
const char*txtInputString
const char*txt2InputText
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
txt:(Input)String
txt2:(Input)Text
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort-order (case sensitive) of two text strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: parsing functions

Simple token parsing of strings

Functions: ajCharParseC


Function ajCharParseC

Simple token parsing from text string using a specified set of delimiters.

Synopsis

Prototype
AjPStr ajCharParseC (
      const char* txt,
      const char* txtdelim
);

TypeNameRead/WriteDescription
const char*txtInputString to be parsed (first call) or NULL for follow-up calls using the same string, as for the C RTL function strtok which is eventually called.
const char*txtdelimInputDelimiter(s) to be used between tokens.
AjPStr RETURNToken

Input
txt:(Input)String to be parsed (first call) or NULL for follow-up calls using the same string, as for the C RTL function strtok which is eventually called.
txtdelim:(Input)Delimiter(s) to be used between tokens.
Returns
AjPStr:Token

Description

Simple token parsing from text string using a specified set of delimiters.

See Also

See other functions in this section

Availability

In release 6.4.0

Datatype: AjPStr

String

Sections: constructors destructors assignment combination functions cutting substitution query element retrieval modifiable string retrieval element assignment string to datatype conversion functions datatype to string conversion functions formatting comparison comparison (sorting) comparison (search) functions parsing functions debugging exit


Section: constructors

Functions for constructing string objects, possibly with a starting string.

Functions: ajStrNew ajStrNewC ajStrNewK ajStrNewS ajStrNewRef ajStrNewRes ajStrNewResC ajStrNewResS ajStrNewResLenC


Function ajStrNew

Default string constructor which allocates memory for a string.

The null string usage pointer is incremented.

Synopsis

Prototype
AjPStr ajStrNew (
      void
);

TypeNameRead/WriteDescription
AjPStr RETURNPointer to an empty string

Returns
AjPStr:Pointer to an empty string

Description

Default string constructor which allocates memory for a string.

The null string usage pointer is incremented.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewC

String constructor which allocates memory for a string and initialises it with the text string provided.

The string size is set just large enough to hold the supplied text.

Synopsis

Prototype
AjPStr ajStrNewC (
      const char* txt
);

TypeNameRead/WriteDescription
const char*txtInputNull-terminated character string to initialise the new string.
AjPStr RETURNPointer to a string containing the supplied text

Input
txt:(Input)Null-terminated character string to initialise the new string.
Returns
AjPStr:Pointer to a string containing the supplied text

Description

String constructor which allocates memory for a string and initialises it with the text string provided.

The string size is set just large enough to hold the supplied text.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewK

String constructor which allocates memory for a string and initialises it with the single character provided.

The string size is set just large enough to hold the supplied text.

Synopsis

Prototype
AjPStr ajStrNewK (
      char ch
);

TypeNameRead/WriteDescription
charchInputNull-terminated character string to initialise the new string.
AjPStr RETURNPointer to a string containing the supplied text

Input
ch:(Input)Null-terminated character string to initialise the new string.
Returns
AjPStr:Pointer to a string containing the supplied text

Description

String constructor which allocates memory for a string and initialises it with the single character provided.

The string size is set just large enough to hold the supplied text.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewS

String constructor which allocates memory for a string and initialises it with the string provided.

Synopsis

Prototype
AjPStr ajStrNewS (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to be cloned
AjPStr RETURNPointer to a string of the specified size containing the supplied text.

Input
str:(Input)String to be cloned
Returns
AjPStr:Pointer to a string of the specified size containing the supplied text.

Description

String constructor which allocates memory for a string and initialises it with the string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewRef

String referencing function which returns a pointer to the string passed in and increases its reference count.

Not a true string copy, but if modified the new string will behave as a copy.

Synopsis

Prototype
AjPStr ajStrNewRef (
      AjPStr refstr
);

TypeNameRead/WriteDescription
AjPStrrefstrModifyAJAX string object
AjPStr RETURNPointer to the string passed as an argument, with its use count increased by 1.

Input & Output
refstr:(Modify)AJAX string object
Returns
AjPStr:Pointer to the string passed as an argument, with its use count increased by 1.

Description

String referencing function which returns a pointer to the string passed in and increases its reference count.

Not a true string copy, but if modified the new string will behave as a copy.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewRes

String constructor which allocates memory for a string of an initial reserved size (including a possible null).

Synopsis

Prototype
AjPStr ajStrNewRes (
      size_t size
);

TypeNameRead/WriteDescription
size_tsizeInputReserved size (including a possible null).
AjPStr RETURNPointer to an empty string of specified size.

Input
size:(Input)Reserved size (including a possible null).
Returns
AjPStr:Pointer to an empty string of specified size.

Description

String constructor which allocates memory for a string of an initial reserved size (including a possible null).

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewResC

String constructor which allocates memory for a string of an initial reserved size (including a possible null) and initialises it with the text string provided.

Synopsis

Prototype
AjPStr ajStrNewResC (
      const char* txt,
      size_t size
);

TypeNameRead/WriteDescription
const char*txtInputNull-terminated character string to initialise the new string.
size_tsizeInputReserved size (including a possible null).
AjPStr RETURNPointer to a string of the specified size containing the supplied text.

Input
txt:(Input)Null-terminated character string to initialise the new string.
size:(Input)Reserved size (including a possible null).
Returns
AjPStr:Pointer to a string of the specified size containing the supplied text.

Description

String constructor which allocates memory for a string of an initial reserved size (including a possible null) and initialises it with the text string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewResS

String constructor which allocates memory for a string of an initial reserved size (including a possible null) and initialises it with the string provided.

Synopsis

Prototype
AjPStr ajStrNewResS (
      const AjPStr str,
      size_t size
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to initialise the new string.
size_tsizeInputReserved size (including a possible null).
AjPStr RETURNPointer to a string of the specified size containing the supplied text.

Input
str:(Input)String to initialise the new string.
size:(Input)Reserved size (including a possible null).
Returns
AjPStr:Pointer to a string of the specified size containing the supplied text.

Description

String constructor which allocates memory for a string of an initial reserved size (including a possible null) and initialises it with the string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrNewResLenC

String constructor which allocates memory for a string of a given length and of an initial reserved size (including a possible null) and initialises it with the text string provided.

Synopsis

Prototype
AjPStr ajStrNewResLenC (
      const char* txt,
      size_t size,
      size_t len
);

TypeNameRead/WriteDescription
const char*txtInputNull-terminated character string to initialise the new string.
size_tsizeInputReserved size, including a trailing null and possible space for expansion
size_tlenInputLength of txt to save calculation time.
AjPStr RETURNPointer to a string of the specified size containing the supplied text.

Input
txt:(Input)Null-terminated character string to initialise the new string.
size:(Input)Reserved size, including a trailing null and possible space for expansion
len:(Input)Length of txt to save calculation time.
Returns
AjPStr:Pointer to a string of the specified size containing the supplied text.

Description

String constructor which allocates memory for a string of a given length and of an initial reserved size (including a possible null) and initialises it with the text string provided.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: destructors

Functions for destruction of string objects.

Functions: MAJSTRDEL ajStrDel ajStrDelStatic ajStrDelarray


Macro MAJSTRDEL

Default string destructor which frees memory for a string.

Decrements the use count. When it reaches zero, the string is removed from memory. If the given string is NULL, or a NULL pointer, simply returns.

A macro version of {ajStrDel} available in case it is needed for speed.

Output
Pstr:(Delete)Pointer to the string to be deleted. The pointer is always deleted.
Returns
void:No return value

Description

Default string destructor which frees memory for a string.

Decrements the use count. When it reaches zero, the string is removed from memory. If the given string is NULL, or a NULL pointer, simply returns.

A macro version of {ajStrDel} available in case it is needed for speed.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrDel

Default string destructor which frees memory for a string.

Decrements the use count. When it reaches zero, the string is removed from memory. If the given string is NULL, or a NULL pointer, simply returns.

Synopsis

Prototype
void ajStrDel (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrDeletePointer to the string to be deleted. The pointer is always deleted.
void RETURN

Output
Pstr:(Delete)Pointer to the string to be deleted. The pointer is always deleted.
Returns
void:No return value

Description

Default string destructor which frees memory for a string.

Decrements the use count. When it reaches zero, the string is removed from memory. If the given string is NULL, or a NULL pointer, simply returns.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrDelStatic

String dereferencing function which sets a string pointer to NULL and decrements the use count of the string to which it referred. Strings with a use count of 1 are *not* freed to avoid freeing and reallocating memory when they are reused.

Memory reserved for the string is never deleted and can always be reused by any remaining AjPStr that points to it even if this pointer is cleared.

Use for more efficient memory management for static strings, to avoid reallocation when used in a subsequent call.

If the given string is NULL, or a NULL pointer, simply returns.

Synopsis

Prototype
AjBool ajStrDelStatic (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputPointer to the string to be deleted.
AjBool RETURNTrue if the string exists and can be reused False if the string was deleted.

Output
Pstr:(Output)Pointer to the string to be deleted.
Returns
AjBool:True if the string exists and can be reused False if the string was deleted.

Description

String dereferencing function which sets a string pointer to NULL and decrements the use count of the string to which it referred. Strings with a use count of 1 are *not* freed to avoid freeing and reallocating memory when they are reused.

Memory reserved for the string is never deleted and can always be reused by any remaining AjPStr that points to it even if this pointer is cleared.

Use for more efficient memory management for static strings, to avoid reallocation when used in a subsequent call.

If the given string is NULL, or a NULL pointer, simply returns.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrDelarray

Default string destructor which frees memory for an array of strings.

Decrements the use count. When it reaches zero, the string is removed from memory. If the given string is NULL, or a NULL pointer, simply returns.

Synopsis

Prototype
void ajStrDelarray (
      AjPStr** PPstr
);

TypeNameRead/WriteDescription
AjPStr**PPstrDeletePointer to the string array to be deleted. The last string is a NULL pointer The pointer is always deleted.
void RETURN

Output
PPstr:(Delete)Pointer to the string array to be deleted. The last string is a NULL pointer The pointer is always deleted.
Returns
void:No return value

Description

Default string destructor which frees memory for an array of strings.

Decrements the use count. When it reaches zero, the string is removed from memory. If the given string is NULL, or a NULL pointer, simply returns.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: assignment

Functions for assigning a string.

Functions: ajStrAssignC ajStrAssignK ajStrAssignS ajStrAssignClear ajStrAssignEmptyC ajStrAssignEmptyS ajStrAssignLenC ajStrAssignRef ajStrAssignResC ajStrAssignResS ajStrAssignSubC ajStrAssignSubS


Function ajStrAssignC

Copy a text string to a string.

Synopsis

Prototype
AjBool ajStrAssignC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
const char*txtInputSource text.
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source text.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Copy a text string to a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignK

Copy a single character to a string.

Synopsis

Prototype
AjBool ajStrAssignK (
      AjPStr* Pstr,
      char chr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
charchrInputSource text.
AjBool RETURNajTrue if string was reallocated

Input
chr:(Input)Source text.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Copy a single character to a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignS

Copy a string to a string.

This is a genuine copy (reference count isn't used). Useful where both strings will be separately overwritten later so that they can both remain modifiable.

Synopsis

Prototype
AjBool ajStrAssignS (
      AjPStr* Pstr,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
const AjPStrstrInputSource string.
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)Source string.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Copy a string to a string.

This is a genuine copy (reference count isn't used). Useful where both strings will be separately overwritten later so that they can both remain modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignClear

Clear the string value

Synopsis

Prototype
AjBool ajStrAssignClear (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
AjBool RETURNajTrue if string was reallocated

Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Clear the string value

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignEmptyC

Ensures a string is set (has a value). If the string is set it is left alone, otherwise it is initialised with a text string.

Synopsis

Prototype
AjBool ajStrAssignEmptyC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string which is overwritten.
const char*txtInputSource text.
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source text.
Output
Pstr:(Output)Target string which is overwritten.
Returns
AjBool:ajTrue if string was reallocated

Description

Ensures a string is set (has a value). If the string is set it is left alone, otherwise it is initialised with a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignEmptyS

Ensures a string is set (has a value). If the string is set it is left alone, otherwise it is initialised with a string.

Synopsis

Prototype
AjBool ajStrAssignEmptyS (
      AjPStr* Pstr,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string which is overwritten.
const AjPStrstrInputSource string object.
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)Source string object.
Output
Pstr:(Output)Target string which is overwritten.
Returns
AjBool:ajTrue if string was reallocated

Description

Ensures a string is set (has a value). If the string is set it is left alone, otherwise it is initialised with a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignLenC

Copy a text string of a given length to a string.

Synopsis

Prototype
AjBool ajStrAssignLenC (
      AjPStr* Pstr,
      const char* txt,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
const char*txtInputSource text.
size_tlenInputLength of source text.
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source text.
len:(Input)Length of source text.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Copy a text string of a given length to a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignRef

String referencing function which makes a string point to another. Increases the reference count of the string pointed to.

Not a true string copy, but if modified the new string will behave as a copy.

Sets the destination string to NULL if the source string is NULL.

Synopsis

Prototype
AjBool ajStrAssignRef (
      AjPStr* Pstr,
      AjPStr refstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string which is overwritten.
AjPStrrefstrModifySource string object Copy by reference count so not const.
AjBool RETURNajTrue if string was reallocated

Output
Pstr:(Output)Target string which is overwritten.
Input & Output
refstr:(Modify)Source string object Copy by reference count so not const.
Returns
AjBool:ajTrue if string was reallocated

Description

String referencing function which makes a string point to another. Increases the reference count of the string pointed to.

Not a true string copy, but if modified the new string will behave as a copy.

Sets the destination string to NULL if the source string is NULL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignResC

Copy a text string to a string with a minimum reserved size.

Synopsis

Prototype
AjBool ajStrAssignResC (
      AjPStr* Pstr,
      size_t size,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
size_tsizeInputSpace to reserve.
const char*txtInputSource text.
AjBool RETURNajTrue if string was reallocated

Input
size:(Input)Space to reserve.
txt:(Input)Source text.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Copy a text string to a string with a minimum reserved size.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignResS

Copy a string to a string with a minimum reserved size.

Synopsis

Prototype
AjBool ajStrAssignResS (
      AjPStr* Pstr,
      size_t size,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
size_tsizeInputSize of new string.
const AjPStrstrInputSource text.
AjBool RETURNajTrue if string was reallocated

Input
size:(Input)Size of new string.
str:(Input)Source text.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Copy a string to a string with a minimum reserved size.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignSubC

Copies a substring of a text string to a string.

Synopsis

Prototype
AjBool ajStrAssignSubC (
      AjPStr* Pstr,
      const char* txt,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const char*txtInputSource text
ajlongpos1Inputstart position for substring
ajlongpos2Inputend position for substring
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source text
pos1:(Input)start position for substring
pos2:(Input)end position for substring
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Copies a substring of a text string to a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAssignSubS

Copies a substring of a string to a string.

Synopsis

Prototype
AjBool ajStrAssignSubS (
      AjPStr* Pstr,
      const AjPStr str,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const AjPStrstrInputSource string
ajlongpos1InputStart position in src of substring
ajlongpos2InputEnd position in src of substring
AjBool RETURNajTrue if Pstr was (re)allocated, ajFalse otherwise

Input
str:(Input)Source string
pos1:(Input)Start position in src of substring
pos2:(Input)End position in src of substring
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if Pstr was (re)allocated, ajFalse otherwise

Description

Copies a substring of a string to a string.

The substring is defined from character positions pos1 to pos2.

ajTrue is returned if target was (re)allocated, ajFalse is returned otherwise.

Usage

Pstr: memory will be automatically allocated if required

pos1: negative values count from the end of the string with -1 as the last position

pos2: negative values count from the end of the string with -1 as the last position

See Also

See other functions in this section

Availability

EMBOSS 1.0.0

Section: combination functions

Functions for appending, inserting or overwriting a string or substring to another.

Functions: ajStrAppendC ajStrAppendK ajStrAppendS ajStrAppendCountK ajStrAppendLenC ajStrAppendSubC ajStrAppendSubS ajStrInsertC ajStrInsertK ajStrInsertS ajStrJoinC ajStrJoinS ajStrMaskIdent ajStrMaskRange ajStrPasteS ajStrPasteCountK ajStrPasteMaxC ajStrPasteMaxS


Function ajStrAppendC

Appends a text string to the end of a string.

Uses {ajStrSetRes} to make sure target string is modifiable.

Synopsis

Prototype
AjBool ajStrAppendC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const char*txtInputSource text
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source text
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends a text string to the end of a string.

Uses {ajStrSetRes} to make sure target string is modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAppendK

Appends a character to the end of a string.

Uses {ajStrSetRes} to make sure target string is modifiable.

Synopsis

Prototype
AjBool ajStrAppendK (
      AjPStr* Pstr,
      char chr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
charchrInputSource character
AjBool RETURNajTrue if string was reallocated

Input
chr:(Input)Source character
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends a character to the end of a string.

Uses {ajStrSetRes} to make sure target string is modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAppendS

Appends a string to the end of another string.

Uses {ajStrSetRes} to make sure target string is modifiable.

Synopsis

Prototype
AjBool ajStrAppendS (
      AjPStr* Pstr,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const AjPStrstrInputSource string
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)Source string
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends a string to the end of another string.

Uses {ajStrSetRes} to make sure target string is modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAppendCountK

Appends any number of a given character to the end of a string.

Equivalent to a repeat count for ajStrAppK.

Uses {ajStrSetRes} to make sure target string is modifiable.

Synopsis

Prototype
AjBool ajStrAppendCountK (
      AjPStr* Pstr,
      char chr,
      ajulong num
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
charchrInputSource character
ajulongnumInputRepeat count
AjBool RETURNajTrue if string was reallocated

Input
chr:(Input)Source character
num:(Input)Repeat count
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends any number of a given character to the end of a string.

Equivalent to a repeat count for ajStrAppK.

Uses {ajStrSetRes} to make sure target string is modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAppendLenC

Appends a text string of a given length to the end of a string.

Uses {ajStrSetRes} to make sure target string is modifiable.

Synopsis

Prototype
AjBool ajStrAppendLenC (
      AjPStr* Pstr,
      const char* txt,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const char*txtInputSource text
size_tlenInputString length
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source text
len:(Input)String length
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends a text string of a given length to the end of a string.

Uses {ajStrSetRes} to make sure target string is modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAppendSubC

Appends a substring of a string to the end of another string.

Synopsis

Prototype
AjBool ajStrAppendSubC (
      AjPStr* Pstr,
      const char* txt,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const char*txtInputSource string
ajlongpos1Inputstart position for substring
ajlongpos2Inputend position for substring
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Source string
pos1:(Input)start position for substring
pos2:(Input)end position for substring
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends a substring of a string to the end of another string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrAppendSubS

Appends a substring of a string to the end of another string.

Uses {ajStrSetRes} to make sure target string is modifiable.

Synopsis

Prototype
AjBool ajStrAppendSubS (
      AjPStr* Pstr,
      const AjPStr str,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const AjPStrstrInputSource string
ajlongpos1Inputstart position for substring
ajlongpos2Inputend position for substring
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)Source string
pos1:(Input)start position for substring
pos2:(Input)end position for substring
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Appends a substring of a string to the end of another string.

Uses {ajStrSetRes} to make sure target string is modifiable.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrInsertC

Insert a text string into a string at a specified position.

Synopsis

Prototype
AjBool ajStrInsertC (
      AjPStr* Pstr,
      ajlong pos,
      const char* txt 
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputPosition where text is to be inserted. Negative position counts from the end
const char*txtInputText to be inserted
AjBool RETURNajTrue if string was reallocated

Input
pos:(Input)Position where text is to be inserted. Negative position counts from the end
txt:(Input)Text to be inserted
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Insert a text string into a string at a specified position.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrInsertK

Inserts a character into a string at a specified position.

Synopsis

Prototype
AjBool ajStrInsertK (
      AjPStr* Pstr,
      ajlong pos,
      char chr 
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputPosition where text is to be inserted. Negative position counts from the end
charchrInputText to be inserted
AjBool RETURNajTrue if string was reallocated

Input
pos:(Input)Position where text is to be inserted. Negative position counts from the end
chr:(Input)Text to be inserted
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Inserts a character into a string at a specified position.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrInsertS

Inserts a text string into a string at a specified position.

Synopsis

Prototype
AjBool ajStrInsertS (
      AjPStr* Pstr,
      ajlong pos,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputPosition where text is to be inserted. Negative position counts from the end
const AjPStrstrInputString to be inserted
AjBool RETURNajTrue on successful completion else ajFalse;

Input
pos:(Input)Position where text is to be inserted. Negative position counts from the end
str:(Input)String to be inserted
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on successful completion else ajFalse;

Description

Inserts a text string into a string at a specified position.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrJoinC

Cut down string at pos1 and add string2 from position pos2.

Synopsis

Prototype
AjBool ajStrJoinC (
      AjPStr* Pstr,
      ajlong pos,
      const char* txt,
      ajlong posb
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
ajlongposInputNumber of characters to keep in target string.
const char*txtInputText to append.
ajlongposbInputPosition of first character to copy from text.
AjBool RETURNajTrue on success

Input
pos:(Input)Number of characters to keep in target string.
txt:(Input)Text to append.
posb:(Input)Position of first character to copy from text.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue on success

Description

Cut down string at pos1 and add string2 from position pos2.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrJoinS

Appends one string to another after cutting both strings.

Cuts down string at pos1 and add string2 from position pos2.

Synopsis

Prototype
AjBool ajStrJoinS (
      AjPStr* Pstr,
      ajlong pos,
      const AjPStr str,
      ajlong posb
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
ajlongposInputStart position in target string, negative numbers count from the end.
const AjPStrstrInputString to append.
ajlongposbInputStarts position to copy, negative numbers count from the end.
AjBool RETURNajTrue on success.

Input
pos:(Input)Start position in target string, negative numbers count from the end.
str:(Input)String to append.
posb:(Input)Starts position to copy, negative numbers count from the end.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue on success.

Description

Appends one string to another after cutting both strings.

Cuts down string at pos1 and add string2 from position pos2.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMaskIdent

Masks out characters from a string that are identical to a second string.

Synopsis

Prototype
AjBool ajStrMaskIdent (
      AjPStr* Pstr,
      const AjPStr str,
      char maskchr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const AjPStrstrInputComparison string
charmaskchrInputmasking character
AjBool RETURNajTrue on success

Input
str:(Input)Comparison string
maskchr:(Input)masking character
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue on success

Description

Masks out characters from a string that are identical to a second string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMaskRange

Masks out characters from a string over a specified range.

Synopsis

Prototype
AjBool ajStrMaskRange (
      AjPStr* Pstr,
      ajlong pos1,
      ajlong pos2,
      char maskchr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
ajlongpos1Inputstart position to be masked
ajlongpos2Inputend position to be masked
charmaskchrInputmasking character
AjBool RETURNajTrue on success, ajFalse if begin is out of range

Input
pos1:(Input)start position to be masked
pos2:(Input)end position to be masked
maskchr:(Input)masking character
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue on success, ajFalse if begin is out of range

Description

Masks out characters from a string over a specified range.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPasteS

Overwrite one string with another.

Replace string at pos1 with new string.

Synopsis

Prototype
AjBool ajStrPasteS (
      AjPStr* Pstr,
      ajlong pos,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputPosition in target string
const AjPStrstrInputString to replace.
AjBool RETURNajTrue on success

Input
pos:(Input)Position in target string
str:(Input)String to replace.
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on success

Description

Overwrite one string with another.

Replace string at pos1 with new string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPasteCountK

Overwrites a string with a number of single characters.

Replace string at pos and add num copies of character chr. Or to the end of the existing string

Synopsis

Prototype
AjBool ajStrPasteCountK (
      AjPStr* Pstr,
      ajlong pos,
      char chr,
      ajulong num
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputposition in string
charchrInputCharacter to replace.
ajulongnumInputNumber of characters to copy from text.
AjBool RETURNajTrue on success

Input
pos:(Input)position in string
chr:(Input)Character to replace.
num:(Input)Number of characters to copy from text.
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on success

Description

Overwrites a string with a number of single characters.

Replace string at pos and add num copies of character chr. Or to the end of the existing string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPasteMaxC

Overwrite one string with a specified number of characters from a text string.

Replaces string at pos ands add len characters from text string txt. Or to the end of the existing string

Synopsis

Prototype
AjBool ajStrPasteMaxC (
      AjPStr* Pstr,
      ajlong pos,
      const char* txt,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputStart position in target string.
const char*txtInputString to replace.
size_tlenInputNumber of characters to copy from text.
AjBool RETURNajTrue on success

Input
pos:(Input)Start position in target string.
txt:(Input)String to replace.
len:(Input)Number of characters to copy from text.
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on success

Description

Overwrite one string with a specified number of characters from a text string.

Replaces string at pos ands add len characters from text string txt. Or to the end of the existing string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPasteMaxS

Overwrite one string with a specified number of characters from another string.

Replaces string at pos and add len characters from string str. Or to the end of the existing string

Synopsis

Prototype
AjBool ajStrPasteMaxS (
      AjPStr* Pstr,
      ajlong pos,
      const AjPStr str,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajlongposInputStart position in target string.
const AjPStrstrInputReplacement string
size_tlenInputNumber of characters to copy from text.
AjBool RETURNajTrue on success

Input
pos:(Input)Start position in target string.
str:(Input)Replacement string
len:(Input)Number of characters to copy from text.
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on success

Description

Overwrite one string with a specified number of characters from another string.

Replaces string at pos and add len characters from string str. Or to the end of the existing string

See Also

See other functions in this section

Availability

In release 6.4.0

Section: cutting

Functions for removing characters or regions (substrings) from a string.

Functions: ajStrCutBraces ajStrCutComments ajStrCutCommentsRestpos ajStrCutCommentsStart ajStrCutEnd ajStrCutRange ajStrCutStart ajStrKeepRange ajStrKeepSetC ajStrKeepSetS ajStrKeepSetAlpha ajStrKeepSetAlphaC ajStrKeepSetAlphaS ajStrKeepSetAlphaRest ajStrKeepSetAlphaRestC ajStrKeepSetAlphaRestS ajStrKeepSetAscii ajStrQuoteStrip ajStrQuoteStripAll ajStrRemoveDupchar ajStrRemoveGap ajStrRemoveGapF ajStrRemoveHtml ajStrRemoveLastNewline ajStrRemoveSetC ajStrRemoveWhite ajStrRemoveWhiteExcess ajStrRemoveWhiteSpaces ajStrRemoveWild ajStrTrimC ajStrTrimEndC ajStrTrimStartC ajStrTrimWhite ajStrTrimWhiteEnd ajStrTrimWhiteStart ajStrTruncateLen ajStrTruncatePos


Function ajStrCutBraces

Removes comments enclosed in braces from a string.

A comment is enclosed in curly braces at the end of a string.

Synopsis

Prototype
AjBool ajStrCutBraces (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyLine of text from input file
AjBool RETURNajTrue if there is some text remaining

Input & Output
Pstr:(Modify)Line of text from input file
Returns
AjBool:ajTrue if there is some text remaining

Description

Removes comments enclosed in braces from a string.

A comment is enclosed in curly braces at the end of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCutComments

Removes comments from a string.

A comment begins with a "#" character and may appear anywhere in the string. See ajStrCutCommentsStart for alternative definition of a comment.

Synopsis

Prototype
AjBool ajStrCutComments (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyLine of text from input file
AjBool RETURNajTrue if there is some text remaining

Input & Output
Pstr:(Modify)Line of text from input file
Returns
AjBool:ajTrue if there is some text remaining

Description

Removes comments from a string.

A comment begins with a "#" character and may appear anywhere in the string. See ajStrCutCommentsStart for alternative definition of a comment.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCutCommentsRestpos

Removes comments from a string.

A comment begins with a "#" character and may appear anywhere in the string. See ajStrCutCommentsStart for alternative definition of a comment.

Synopsis

Prototype
AjBool ajStrCutCommentsRestpos (
      AjPStr* Pstr,
      AjPStr* Pcomment,
      size_t* Pstartpos
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyLine of text from input file
AjPStr*PcommentOutputComment characters deleted
size_t*PstartposOutputComment start position
AjBool RETURNajTrue if there is some text remaining

Output
Pcomment:(Output)Comment characters deleted
Pstartpos:(Output)Comment start position
Input & Output
Pstr:(Modify)Line of text from input file
Returns
AjBool:ajTrue if there is some text remaining

Description

Removes comments from a string.

A comment begins with a "#" character and may appear anywhere in the string. See ajStrCutCommentsStart for alternative definition of a comment.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCutCommentsStart

Removes comments from a string.

A comment is a blank line or any text starting with a "#" character.

Synopsis

Prototype
AjBool ajStrCutCommentsStart (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyLine of text from input file
AjBool RETURNajTrue if there is some text remaining

Input & Output
Pstr:(Modify)Line of text from input file
Returns
AjBool:ajTrue if there is some text remaining

Description

Removes comments from a string.

A comment is a blank line or any text starting with a "#" character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCutEnd

Removes a number of characters from the end of a string

Synopsis

Prototype
AjBool ajStrCutEnd (
      AjPStr* Pstr,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
size_tlenInputNumber of characters to delete from the end
AjBool RETURNajTrue if string was reallocated

Input
len:(Input)Number of characters to delete from the end
Input & Output
Pstr:(Modify)string
Returns
AjBool:ajTrue if string was reallocated

Description

Removes a number of characters from the end of a string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCutRange

Removes a substring from a string.

Synopsis

Prototype
AjBool ajStrCutRange (
      AjPStr* Pstr,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
ajlongpos1Inputstart position to be cut
ajlongpos2Inputend position to be cut
AjBool RETURNajTrue on success, ajFalse if begin is out of range

Input
pos1:(Input)start position to be cut
pos2:(Input)end position to be cut
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue on success, ajFalse if begin is out of range

Description

Removes a substring from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCutStart

Removes a number of characters from the start of a string

Synopsis

Prototype
AjBool ajStrCutStart (
      AjPStr* Pstr,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
size_tlenInputNumber of characters to delete from the start
AjBool RETURNajTrue if string was reallocated

Input
len:(Input)Number of characters to delete from the start
Input & Output
Pstr:(Modify)string
Returns
AjBool:ajTrue if string was reallocated

Description

Removes a number of characters from the start of a string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepRange

Reduces target string to a substring of itself by deleting all except a range of character positions.

The end is allowed to be before begin, in which case the output is an empty string.

Synopsis

Prototype
AjBool ajStrKeepRange (
      AjPStr* Pstr,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string.
ajlongpos1InputStart position for substring.
ajlongpos2InputEnd position for substring.
AjBool RETURNajTrue if string was reallocated

Input
pos1:(Input)Start position for substring.
pos2:(Input)End position for substring.
Output
Pstr:(Output)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Reduces target string to a substring of itself by deleting all except a range of character positions.

The end is allowed to be before begin, in which case the output is an empty string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetC

Removes all characters from a string that are not in a given set.

Synopsis

Prototype
AjBool ajStrKeepSetC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
const char*txtInputCharacter set to keep
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Character set to keep
Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string was reallocated

Description

Removes all characters from a string that are not in a given set.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetS

Removes all characters from a string that are not in a given set.

Synopsis

Prototype
AjBool ajStrKeepSetS (
      AjPStr* Pstr,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
const AjPStrstrInputCharacter set to keep
AjBool RETURNajTrue if string is not empty

Input
str:(Input)Character set to keep
Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not in a given set.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAlpha

Removes all characters from a string that are not alphabetic.

Synopsis

Prototype
AjBool ajStrKeepSetAlpha (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
AjBool RETURNajTrue if string is not empty

Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not alphabetic.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAlphaC

Removes all characters from a string that are not alphabetic and are not in a given set.

Synopsis

Prototype
AjBool ajStrKeepSetAlphaC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
const char*txtInputNon-alphabetic character set to keep
AjBool RETURNajTrue if string is not empty

Input
txt:(Input)Non-alphabetic character set to keep
Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not alphabetic and are not in a given set.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAlphaS

Removes all characters from a string that are not alphabetic and are not in a given set.

Synopsis

Prototype
AjBool ajStrKeepSetAlphaS (
      AjPStr* Pstr,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
const AjPStrstrInputNon-alphabetic character set to keep
AjBool RETURNajTrue if string is not empty

Input
str:(Input)Non-alphabetic character set to keep
Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not alphabetic and are not in a given set.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAlphaRest

Removes all characters from a string that are not alphabetic.

Also returns any non-whitespace characters in the strings

Synopsis

Prototype
AjBool ajStrKeepSetAlphaRest (
      AjPStr* Pstr,
      AjPStr* Prest
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
AjPStr*PrestModifyExcluded non-whitespace characters.
AjBool RETURNajTrue if string is not empty

Input & Output
Pstr:(Modify)String to clean.
Prest:(Modify)Excluded non-whitespace characters.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not alphabetic.

Also returns any non-whitespace characters in the strings

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAlphaRestC

Removes all characters from a string that are not alphabetic and are not in a given set.

Also returns any non-whitespace characters in the strings

Synopsis

Prototype
AjBool ajStrKeepSetAlphaRestC (
      AjPStr* Pstr,
      const char* txt,
      AjPStr* Prest
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
const char*txtInputNon-alphabetic character set to keep
AjPStr*PrestModifyExcluded non-whitespace characters.
AjBool RETURNajTrue if string is not empty

Input
txt:(Input)Non-alphabetic character set to keep
Input & Output
Pstr:(Modify)String to clean.
Prest:(Modify)Excluded non-whitespace characters.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not alphabetic and are not in a given set.

Also returns any non-whitespace characters in the strings

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAlphaRestS

Removes all characters from a string that are not alphabetic and are not in a given set.

Also returns any non-whitespace characters in the strings

Synopsis

Prototype
AjBool ajStrKeepSetAlphaRestS (
      AjPStr* Pstr,
      const AjPStr str,
      AjPStr* Prest
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
const AjPStrstrInputNon-alphabetic character set to keep
AjPStr*PrestModifyExcluded non-whitespace characters.
AjBool RETURNajTrue if string is not empty

Input
str:(Input)Non-alphabetic character set to keep
Input & Output
Pstr:(Modify)String to clean.
Prest:(Modify)Excluded non-whitespace characters.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not alphabetic and are not in a given set.

Also returns any non-whitespace characters in the strings

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrKeepSetAscii

Removes all characters from a string that are not within a range of ASCII character codes.

Synopsis

Prototype
AjBool ajStrKeepSetAscii (
      AjPStr* Pstr,
      int minchar,
      int maxchar
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
intmincharInputLowest ASCII code to keep
intmaxcharInputHighest ASCII code to keep
AjBool RETURNajTrue if string is not empty

Input
minchar:(Input)Lowest ASCII code to keep
maxchar:(Input)Highest ASCII code to keep
Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string is not empty

Description

Removes all characters from a string that are not within a range of ASCII character codes.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrQuoteStrip

Removes any double quotes from a string.

Internal escaped or double quotes are converted to single quotes.

Synopsis

Prototype
AjBool ajStrQuoteStrip (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
AjBool RETURNajTrue if string is not empty

Input & Output
Pstr:(Modify)string
Returns
AjBool:ajTrue if string is not empty

Description

Removes any double quotes from a string.

Internal escaped or double quotes are converted to single quotes.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrQuoteStripAll

Removes any single or double quotes from a string.

Internal escaped or doubled-up quotes are converted to single quotes.

Synopsis

Prototype
AjBool ajStrQuoteStripAll (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
AjBool RETURNTrue on success

Input & Output
Pstr:(Modify)string
Returns
AjBool:True on success

Description

Removes any single or double quotes from a string.

Internal escaped or doubled-up quotes are converted to single quotes.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveDupchar

Removes duplicate characters from a string

Synopsis

Prototype
AjBool ajStrRemoveDupchar (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
AjBool RETURNTrue if string is not empty

Output
Pstr:(Output)String
Returns
AjBool:True if string is not empty

Description

Removes duplicate characters from a string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveGap

Removes non-sequence characters (all but alphabetic characters and asterisk) from a string.

Synopsis

Prototype
AjBool ajStrRemoveGap (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
AjBool RETURNTrue if string is not empty

Output
Pstr:(Output)String
Returns
AjBool:True if string is not empty

Description

Removes non-sequence characters (all but alphabetic characters and asterisk) from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveGapF

Removes non-sequence characters (all but alphabetic characters and asterisk) from a string. Also removes floats from an array of the same size

Synopsis

Prototype
AjBool ajStrRemoveGapF (
      AjPStr* Pstr,
      float* Pfloat
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
float*PfloatOutputFloating point array (e.g. quality scores)
AjBool RETURNTrue if string is not empty

Output
Pstr:(Output)String
Pfloat:(Output)Floating point array (e.g. quality scores)
Returns
AjBool:True if string is not empty

Description

Removes non-sequence characters (all but alphabetic characters and asterisk) from a string. Also removes floats from an array of the same size

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveHtml

Removes html from a string.

html is defined as all substrings between and including angle brackets.

Synopsis

Prototype
AjBool ajStrRemoveHtml (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
AjBool RETURNajTrue on success

Output
Pstr:(Output)String
Returns
AjBool:ajTrue on success

Description

Removes html from a string.

html is defined as all substrings between and including angle brackets.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveLastNewline

Removes last character from a string if it is a newline character.

Synopsis

Prototype
AjBool ajStrRemoveLastNewline (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
AjBool RETURNTrue is string is not empty

Output
Pstr:(Output)String
Returns
AjBool:True is string is not empty

Description

Removes last character from a string if it is a newline character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveSetC

Removes all of a given set of characters from a string.

Synopsis

Prototype
AjBool ajStrRemoveSetC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
const char*txtInputcharacters to remove
AjBool RETURNTrue on success

Input
txt:(Input)characters to remove
Output
Pstr:(Output)String
Returns
AjBool:True on success

Description

Removes all of a given set of characters from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveWhite

Removes all whitespace characters from a string.

Synopsis

Prototype
AjBool ajStrRemoveWhite (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string was reallocated

Description

Removes all whitespace characters from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveWhiteExcess

Removes excess whitespace characters from a string.

Leading/trailing whitespace removed. Multiple spaces replaced by single spaces.

Synopsis

Prototype
AjBool ajStrRemoveWhiteExcess (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string was reallocated

Description

Removes excess whitespace characters from a string.

Leading/trailing whitespace removed. Multiple spaces replaced by single spaces.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveWhiteSpaces

Removes excess space characters from a string.

Leading/trailing whitespace removed. Multiple spaces replaced by single spaces. Tabs converted to spaces. Newlines left unchanged

Synopsis

Prototype
AjBool ajStrRemoveWhiteSpaces (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString to clean.
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String to clean.
Returns
AjBool:ajTrue if string was reallocated

Description

Removes excess space characters from a string.

Leading/trailing whitespace removed. Multiple spaces replaced by single spaces. Tabs converted to spaces. Newlines left unchanged

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRemoveWild

Removes all characters after the first wildcard character (if found).

Synopsis

Prototype
AjBool ajStrRemoveWild (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if the string contained a wildcard and was truncated.

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if the string contained a wildcard and was truncated.

Description

Removes all characters after the first wildcard character (if found).

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrimC

Removes regions with a given character composition from start and end of a string.

Synopsis

Prototype
AjBool ajStrTrimC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
const char*txtInputCharacters to delete from each end
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Characters to delete from each end
Input & Output
Pstr:(Modify)string
Returns
AjBool:ajTrue if string was reallocated

Description

Removes regions with a given character composition from start and end of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrimEndC

Removes a region with a given character composition from end of a string.

Synopsis

Prototype
AjBool ajStrTrimEndC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
const char*txtInputCharacters to delete from the end
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Characters to delete from the end
Input & Output
Pstr:(Modify)string
Returns
AjBool:ajTrue if string was reallocated

Description

Removes a region with a given character composition from end of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrimStartC

Removes a region with a given character composition from start of a string.

Synopsis

Prototype
AjBool ajStrTrimStartC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
const char*txtInputCharacters to delete from the end
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Characters to delete from the end
Input & Output
Pstr:(Modify)string
Returns
AjBool:ajTrue if string was reallocated

Description

Removes a region with a given character composition from start of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrimWhite

Removes regions composed of white space characters only from the start and end of a string.

Synopsis

Prototype
AjBool ajStrTrimWhite (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Removes regions composed of white space characters only from the start and end of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrimWhiteEnd

Removes regions composed of white space characters only from the end of a string.

Synopsis

Prototype
AjBool ajStrTrimWhiteEnd (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Removes regions composed of white space characters only from the end of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrimWhiteStart

Removes regions composed of white space characters only from the start of a string.

Synopsis

Prototype
AjBool ajStrTrimWhiteStart (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Removes regions composed of white space characters only from the start of a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTruncateLen

Removes the end from a string reducing it to a defined length.

Synopsis

Prototype
AjBool ajStrTruncateLen (
      AjPStr* Pstr,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
size_tlenInputLength of required string.
AjBool RETURNajTrue if string was reallocated

Input
len:(Input)Length of required string.
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Removes the end from a string reducing it to a defined length.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTruncatePos

Removes the end from a string by cutting at a defined position.

Synopsis

Prototype
AjBool ajStrTruncatePos (
      AjPStr* Pstr,
      ajlong pos
);

TypeNameRead/WriteDescription
AjPStr*PstrModifytarget string
ajlongposInputFirst position to be deleted. Negative values count from the end
AjBool RETURNTrue is string was reallocated

Input
pos:(Input)First position to be deleted. Negative values count from the end
Input & Output
Pstr:(Modify)target string
Returns
AjBool:True is string was reallocated

Description

Removes the end from a string by cutting at a defined position.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: substitution

Functions for substitutions of characters or regions (substrings) within a string.

Functions: ajStrExchangeCC ajStrExchangeCS ajStrExchangeKK ajStrExchangeSC ajStrExchangeSS ajStrExchangePosCC ajStrExchangeSetCC ajStrExchangeSetSS ajStrExchangeSetRestCK ajStrExchangeSetRestSK ajStrRandom ajStrReverse


Function ajStrExchangeCC

Replace all occurrences in a string of one substring with another.

Synopsis

Prototype
AjBool ajStrExchangeCC (
      AjPStr* Pstr,
      const char* txt,
      const char* txtnew
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
const char*txtInputstring to replace.
const char*txtnewInputstring to insert.
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)string to replace.
txtnew:(Input)string to insert.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one substring with another.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeCS

Replace all occurrences in a string of one substring with another.

Synopsis

Prototype
AjBool ajStrExchangeCS (
      AjPStr* Pstr,
      const char* txt,
      const AjPStr strnew
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
const char*txtInputstring to replace.
const AjPStrstrnewInputstring to insert.
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)string to replace.
strnew:(Input)string to insert.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one substring with another.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeKK

Replace all occurrences in a string of one character with another.

Synopsis

Prototype
AjBool ajStrExchangeKK (
      AjPStr* Pstr,
      char chr,
      char chrnew
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
charchrInputCharacter to replace.
charchrnewInputCharacter to insert.
AjBool RETURNajTrue if string was reallocated

Input
chr:(Input)Character to replace.
chrnew:(Input)Character to insert.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one character with another.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeSC

Replace all occurrences in a string of one substring with another.

Synopsis

Prototype
AjBool ajStrExchangeSC (
      AjPStr* Pstr,
      const AjPStr str,
      const char* txtnew
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
const AjPStrstrInputstring to replace.
const char*txtnewInputstring to insert.
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)string to replace.
txtnew:(Input)string to insert.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one substring with another.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeSS

Replace all occurrences in a string of one substring with another.

Synopsis

Prototype
AjBool ajStrExchangeSS (
      AjPStr* Pstr,
      const AjPStr str,
      const AjPStr strnew
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
const AjPStrstrInputstring to replace.
const AjPStrstrnewInputstring to insert.
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)string to replace.
strnew:(Input)string to insert.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one substring with another.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangePosCC

Replace one substring with another at a given position in the text.

Synopsis

Prototype
AjBool ajStrExchangePosCC (
      AjPStr* Pstr,
      ajlong ipos,
      const char* txt,
      const char* txtnew
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string.
ajlongiposInputPosition in the string, negative values are from the end of the string.
const char*txtInputstring to replace.
const char*txtnewInputstring to insert.
AjBool RETURNajTrue if string was reallocated

Input
ipos:(Input)Position in the string, negative values are from the end of the string.
txt:(Input)string to replace.
txtnew:(Input)string to insert.
Input & Output
Pstr:(Modify)Target string.
Returns
AjBool:ajTrue if string was reallocated

Description

Replace one substring with another at a given position in the text.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeSetCC

Replace all occurrences in a string of one set of characters with another set.

Synopsis

Prototype
AjBool ajStrExchangeSetCC (
      AjPStr* Pstr,
      const char* txt,
      const char* txtnew
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
const char*txtInputUnwanted characters
const char*txtnewInputReplacement characters
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Unwanted characters
txtnew:(Input)Replacement characters
Output
Pstr:(Output)String
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one set of characters with another set.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeSetSS

Replace all occurrences in a string of one set of characters with another set.

Synopsis

Prototype
AjBool ajStrExchangeSetSS (
      AjPStr* Pstr,
      const AjPStr str,
      const AjPStr strnew
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
const AjPStrstrInputUnwanted characters
const AjPStrstrnewInputReplacement characters
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)Unwanted characters
strnew:(Input)Replacement characters
Output
Pstr:(Output)String
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one set of characters with another set.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeSetRestCK

Replace all occurrences in a string of one set of characters with a substitute character

Synopsis

Prototype
AjBool ajStrExchangeSetRestCK (
      AjPStr* Pstr,
      const char* txt,
      char chrnew
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
const char*txtInputWanted characters
charchrnewInputReplacement character
AjBool RETURNajTrue if string was reallocated

Input
txt:(Input)Wanted characters
chrnew:(Input)Replacement character
Output
Pstr:(Output)String
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string of one set of characters with a substitute character

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExchangeSetRestSK

Replace all occurrences in a string not in one set of characters with a substitute character.

Synopsis

Prototype
AjBool ajStrExchangeSetRestSK (
      AjPStr* Pstr,
      const AjPStr str,
      char chrnew
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
const AjPStrstrInputWanted characters
charchrnewInputReplacement character
AjBool RETURNajTrue if string was reallocated

Input
str:(Input)Wanted characters
chrnew:(Input)Replacement character
Output
Pstr:(Output)String
Returns
AjBool:ajTrue if string was reallocated

Description

Replace all occurrences in a string not in one set of characters with a substitute character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrRandom

Randomly rearranges the characters in a string.

The application code must first call ajRandomSeed().

Synopsis

Prototype
AjBool ajStrRandom (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
AjBool RETURNTrue unless string is empty

Input & Output
Pstr:(Modify)string
Returns
AjBool:True unless string is empty

Description

Randomly rearranges the characters in a string.

The application code must first call ajRandomSeed().

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrReverse

Reverses the order of characters in a string

Synopsis

Prototype
AjBool ajStrReverse (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
AjBool RETURNajTrue if string was reallocated

Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Reverses the order of characters in a string

See Also

See other functions in this section

Availability

In release 6.4.0

Section: query

Functions for querying the properties of strings.

Functions: ajStrCalcCountC ajStrCalcCountK ajStrHasParentheses ajStrIsAlnum ajStrIsAlpha ajStrIsBool ajStrIsCharsetC ajStrIsCharsetS ajStrIsCharsetCaseC ajStrIsCharsetCaseS ajStrIsDouble ajStrIsFloat ajStrIsHex ajStrIsInt ajStrIsLong ajStrIsLower ajStrIsNum ajStrIsUpper ajStrIsWhite ajStrIsWild ajStrIsWord ajStrWhole


Function ajStrCalcCountC

Counts occurrences of set of characters in a string.

Synopsis

Prototype
ajulong ajStrCalcCountC (
      const AjPStr str,
      const char* txt
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txtInputCharacters to count
ajulong RETURNNumber of times characters were found in string

Input
str:(Input)String
txt:(Input)Characters to count
Returns
ajulong:Number of times characters were found in string

Description

Counts occurrences of set of characters in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCalcCountK

Counts occurrences of a character in a string.

Synopsis

Prototype
ajulong ajStrCalcCountK (
      const AjPStr str,
      char chr
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
charchrInputCharacter to count
ajulong RETURNNumber of times character was found in string

Input
str:(Input)String
chr:(Input)Character to count
Returns
ajulong:Number of times character was found in string

Description

Counts occurrences of a character in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrHasParentheses

Tests whether a string contains (possibly nested) pairs of parentheses.

Pairs of parentheses are difficult to test for with regular expressions.

Synopsis

Prototype
AjBool ajStrHasParentheses (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to test
AjBool RETURNajTrue if string has zero or more () pairs with possibly other text

Input
str:(Input)String to test
Returns
AjBool:ajTrue if string has zero or more () pairs with possibly other text

Description

Tests whether a string contains (possibly nested) pairs of parentheses.

Pairs of parentheses are difficult to test for with regular expressions.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsAlnum

Test whether a string contains alphanumeric characters only (no white space).

The test is defined by isalnum in the C RTL plus underscores.

Synopsis

Prototype
AjBool ajStrIsAlnum (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is entirely alphanumeric

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is entirely alphanumeric

Description

Test whether a string contains alphanumeric characters only (no white space).

The test is defined by isalnum in the C RTL plus underscores.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsAlpha

Test whether a string contains alphabetic characters only (no white space).

Test is defined by isalpha in the C RTL.

Synopsis

Prototype
AjBool ajStrIsAlpha (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is entirely alphabetic

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is entirely alphabetic

Description

Test whether a string contains alphabetic characters only (no white space).

Test is defined by isalpha in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsBool

Tests whether a string represents a valid Boolean value.

The string must be a single character boolean value, or one of "yes, "no", "true" or "false".

Synopsis

Prototype
AjBool ajStrIsBool (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is acceptable as a boolean.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is acceptable as a boolean.

Description

Tests whether a string represents a valid Boolean value.

The string must be a single character boolean value, or one of "yes, "no", "true" or "false".

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsCharsetC

Test whether a string contains specified characters only.

Synopsis

Prototype
AjBool ajStrIsCharsetC (
      const AjPStr str,
      const char* txt
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txtInputCharacter set to test
AjBool RETURNajTrue if the string is entirely composed of characters in the specified set

Input
str:(Input)String
txt:(Input)Character set to test
Returns
AjBool:ajTrue if the string is entirely composed of characters in the specified set

Description

Test whether a string contains specified characters only.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsCharsetS

Test whether a string contains specified characters only.

Synopsis

Prototype
AjBool ajStrIsCharsetS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputCharacter set to test
AjBool RETURNajTrue if the string is entirely composed of characters in the specified set

Input
str:(Input)String
str2:(Input)Character set to test
Returns
AjBool:ajTrue if the string is entirely composed of characters in the specified set

Description

Test whether a string contains specified characters only.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsCharsetCaseC

Test whether a string contains specified characters only. The test is case-insensitive

Synopsis

Prototype
AjBool ajStrIsCharsetCaseC (
      const AjPStr str,
      const char* txt
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txtInputCharacter set to test
AjBool RETURNajTrue if the string is entirely composed of characters in the specified set

Input
str:(Input)String
txt:(Input)Character set to test
Returns
AjBool:ajTrue if the string is entirely composed of characters in the specified set

Description

Test whether a string contains specified characters only. The test is case-insensitive

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsCharsetCaseS

Test whether a string contains specified characters only. The test is case-insensitive

Synopsis

Prototype
AjBool ajStrIsCharsetCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputCharacter set to test
AjBool RETURNajTrue if the string is entirely composed of characters in the specified set

Input
str:(Input)String
str2:(Input)Character set to test
Returns
AjBool:ajTrue if the string is entirely composed of characters in the specified set

Description

Test whether a string contains specified characters only. The test is case-insensitive

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsDouble

Tests whether a string represents a valid double precision value,

Test uses the strtod call in the C RTL.

Synopsis

Prototype
AjBool ajStrIsDouble (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is acceptable as a double precision number.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is acceptable as a double precision number.

Description

Tests whether a string represents a valid double precision value,

Test uses the strtod call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsFloat

Tests whether a string represents a valid floating point value.

Test uses the strtod call in the C RTL.

Synopsis

Prototype
AjBool ajStrIsFloat (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is acceptable as a floating point number.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is acceptable as a floating point number.

Description

Tests whether a string represents a valid floating point value.

Test uses the strtod call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsHex

Tests whether a string represents a valid hexadecimal value.

Test uses the strtol call in the C RTL.

Synopsis

Prototype
AjBool ajStrIsHex (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is acceptable as a hexadecimal value.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is acceptable as a hexadecimal value.

Description

Tests whether a string represents a valid hexadecimal value.

Test uses the strtol call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsInt

Tests whether a string represents a valid integer value.

Test uses the strtol call in the C RTL.

Synopsis

Prototype
AjBool ajStrIsInt (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is acceptable as an integer.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is acceptable as an integer.

Description

Tests whether a string represents a valid integer value.

Test uses the strtol call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsLong

Tests whether a string represents a valid ajlong integer value.

Test uses the strtol call in the C RTL.

Synopsis

Prototype
AjBool ajStrIsLong (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is acceptable as an integer.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is acceptable as an integer.

Description

Tests whether a string represents a valid ajlong integer value.

Test uses the strtol call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsLower

Tests whether a string contains no upper case alphabetic characters.

Test is defined by isupper in the C RTL..

Synopsis

Prototype
AjBool ajStrIsLower (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is entirely alphabetic

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is entirely alphabetic

Description

Tests whether a string contains no upper case alphabetic characters.

Test is defined by isupper in the C RTL..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsNum

Test whether a string contains decimal digits only.

Test is defined by isdigit in the C RTL..

Synopsis

Prototype
AjBool ajStrIsNum (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is entirely numeric

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is entirely numeric

Description

Test whether a string contains decimal digits only.

Test is defined by isdigit in the C RTL..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsUpper

Test whether a string contains no lower case alphabetic characters.

Test is defined by islower in the C RTL..

Synopsis

Prototype
AjBool ajStrIsUpper (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string has no lower case characters.

Input
str:(Input)String
Returns
AjBool:ajTrue if the string has no lower case characters.

Description

Test whether a string contains no lower case alphabetic characters.

Test is defined by islower in the C RTL..

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsWhite

Test whether a string contains whitespace characters only.

The test is made using the strtod call in the C RTL.

Synopsis

Prototype
AjBool ajStrIsWhite (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string is only white space (or empty).

Input
str:(Input)String
Returns
AjBool:ajTrue if the string is only white space (or empty).

Description

Test whether a string contains whitespace characters only.

The test is made using the strtod call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsWild

Tests whether a string contains the standard wildcard characters * or ?.

Synopsis

Prototype
AjBool ajStrIsWild (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if string has wildcards.

Input
str:(Input)String
Returns
AjBool:ajTrue if string has wildcards.

Description

Tests whether a string contains the standard wildcard characters * or ?.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIsWord

Test whether a string contains no white space characters.

Test is defined by isspace in the C RTL.

Synopsis

Prototype
AjBool ajStrIsWord (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if the string has no white space

Input
str:(Input)String
Returns
AjBool:ajTrue if the string has no white space

Description

Test whether a string contains no white space characters.

Test is defined by isspace in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrWhole

Tests whether a range refers to the whole string

Synopsis

Prototype
AjBool ajStrWhole (
      const AjPStr str,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajlongpos1InputBegin position (0 start, negative from the end)
ajlongpos2InputBegin position (0 start, negative from the end)
AjBool RETURNajTrue is range covers the whole string

Input
str:(Input)String
pos1:(Input)Begin position (0 start, negative from the end)
pos2:(Input)Begin position (0 start, negative from the end)
Returns
AjBool:ajTrue is range covers the whole string

Description

Tests whether a range refers to the whole string

See Also

See other functions in this section

Availability

In release 6.4.0

Section: element retrieval

Functions for returning elements of a string object.

Functions: ajStrGetAsciiCommon ajStrGetAsciiHigh ajStrGetAsciiLow ajStrGetCharFirst ajStrGetCharLast ajStrGetCharPos ajStrGetLen MAJSTRGETLEN ajStrGetPtr MAJSTRGETPTR ajStrGetRes MAJSTRGETRES ajStrGetRoom ajStrGetUse MAJSTRGETUSE ajStrGetValid


Function ajStrGetAsciiCommon

Returns the most common ASCII character code in a string.

Synopsis

Prototype
char ajStrGetAsciiCommon (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
char RETURNMost common character or null character if empty.

Input
str:(Input)String
Returns
char:Most common character or null character if empty.

Description

Returns the most common ASCII character code in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetAsciiHigh

Returns the highest ASCII character code in a string.

Synopsis

Prototype
char ajStrGetAsciiHigh (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
char RETURNHighest character or null character if empty.

Input
str:(Input)String
Returns
char:Highest character or null character if empty.

Description

Returns the highest ASCII character code in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetAsciiLow

Returns the lowest ASCII character code in a string.

Synopsis

Prototype
char ajStrGetAsciiLow (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
char RETURNLowest character or null character if empty.

Input
str:(Input)String
Returns
char:Lowest character or null character if empty.

Description

Returns the lowest ASCII character code in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetCharFirst

Returns the first character from a string.

Synopsis

Prototype
char ajStrGetCharFirst (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
char RETURNFirst character or null character if empty.

Input
str:(Input)String
Returns
char:First character or null character if empty.

Description

Returns the first character from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetCharLast

Returns the last character from a string.

Synopsis

Prototype
char ajStrGetCharLast (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
char RETURNLast character or null character if empty.

Input
str:(Input)String
Returns
char:Last character or null character if empty.

Description

Returns the last character from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetCharPos

Returns a single character at a given position from a string.

Synopsis

Prototype
char ajStrGetCharPos (
      const AjPStr str,
      ajlong pos
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajlongposInputPosition in the string, negative values are from the end of the string.
char RETURNCharacter at position pos or null character if out of range.

Input
str:(Input)String
pos:(Input)Position in the string, negative values are from the end of the string.
Returns
char:Character at position pos or null character if out of range.

Description

Returns a single character at a given position from a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetLen

Returns the current length of the C (char *) string.

The length will remain valid unless the string is resized or deleted.

Synopsis

Prototype
size_t ajStrGetLen (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputSource string
size_t RETURNCurrent string length

Input
str:(Input)Source string
Returns
size_t:Current string length

Description

Returns the current length of the C (char *) string.

The length will remain valid unless the string is resized or deleted.

See Also

See other functions in this section

Availability

In release 6.4.0

Macro MAJSTRGETLEN

Returns the current length of the C (char *) string.

A macro version of {ajStrGetLen} available in case it is needed for speed.

Input
str:(Input)Source string
Returns
size_t:Current string length

Description

Returns the current length of the C (char *) string.

A macro version of {ajStrGetLen} available in case it is needed for speed.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetPtr

Returns the current pointer to C (char *) string.

The pointer will remain valid unless the string is resized or deleted.

Synopsis

Prototype
const char* ajStrGetPtr (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputSource string
const char* RETURNCurrent string pointer, or a null string if undefined.

Input
str:(Input)Source string
Returns
const char*:Current string pointer, or a null string if undefined.

Description

Returns the current pointer to C (char *) string.

The pointer will remain valid unless the string is resized or deleted.

See Also

See other functions in this section

Availability

In release 6.4.0

Macro MAJSTRGETPTR

Returns the current pointer to C (char *) string.

A macro version of {ajStrGetPtr} available in case it is needed for speed.

Input
str:(Input)Source string
Returns
const char*:Current string pointer, or a null string if undefined.

Description

Returns the current pointer to C (char *) string.

A macro version of {ajStrGetPtr} available in case it is needed for speed.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetRes

Returns the current reserved size of the C (char *) string.

The reserved size will remain valid unless the string is resized or deleted.

Synopsis

Prototype
size_t ajStrGetRes (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputSource string
size_t RETURNCurrent string reserved size

Input
str:(Input)Source string
Returns
size_t:Current string reserved size

Description

Returns the current reserved size of the C (char *) string.

The reserved size will remain valid unless the string is resized or deleted.

See Also

See other functions in this section

Availability

In release 6.4.0

Macro MAJSTRGETRES

Returns the current reserved size of the C (char *) string.

A macro version of {ajStrGetRes} available in case it is needed for speed.

Input
str:(Input)Source string
Returns
size_t:Current string reserved size

Description

Returns the current reserved size of the C (char *) string.

A macro version of {ajStrGetRes} available in case it is needed for speed.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetRoom

Returns the additional space available in a string before it would require reallocating.

Synopsis

Prototype
size_t ajStrGetRoom (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
size_t RETURNSpace available for additional characters.

Input
str:(Input)String
Returns
size_t:Space available for additional characters.

Description

Returns the additional space available in a string before it would require reallocating.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetUse

Returns the current usage count of the C (char *) string.

The usage count will remain valid unless the string is resized or deleted.

Synopsis

Prototype
ajuint ajStrGetUse (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputSource string
ajuint RETURNCurrent string usage count

Input
str:(Input)Source string
Returns
ajuint:Current string usage count

Description

Returns the current usage count of the C (char *) string.

The usage count will remain valid unless the string is resized or deleted.

See Also

See other functions in this section

Availability

In release 6.4.0

Macro MAJSTRGETUSE

Returns the current usage count of the C (char *) string.

A macro version of {ajStrGetUse} available in case it is needed for speed.

Input
str:(Input)Source string
Returns
ajuint:Current string usage count

Description

Returns the current usage count of the C (char *) string.

A macro version of {ajStrGetUse} available in case it is needed for speed.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetValid

Checks a string object for consistency.

Intended for debugging and testing of these routines, but made publicly available.

Synopsis

Prototype
AjBool ajStrGetValid (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool RETURNajTrue if no errors were found.

Input
str:(Input)String
Returns
AjBool:ajTrue if no errors were found.

Description

Checks a string object for consistency.

Intended for debugging and testing of these routines, but made publicly available.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: modifiable string retrieval

Functions for returning elements of a string object.

Functions: ajStrGetuniquePtr MAJSTRGETUNIQUESTR ajStrGetuniqueStr


Function ajStrGetuniquePtr

Makes the string value unique by copying any string with a reference count of more than 1, and returns the current C (char *) pointer.

As the input string is not const, the calling program must be able to modify it in order to call this function.

If the length of the string is changed, it is the responsibility of the caller to reset it with ajStrSetValid

Synopsis

Prototype
char* ajStrGetuniquePtr (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifySource string
char* RETURNCurrent string pointer, or a null string if undefined.

Input & Output
Pstr:(Modify)Source string
Returns
char*:Current string pointer, or a null string if undefined.

Description

Makes the string value unique by copying any string with a reference count of more than 1, and returns the current C (char *) pointer.

As the input string is not const, the calling program must be able to modify it in order to call this function.

If the length of the string is changed, it is the responsibility of the caller to reset it with ajStrSetValid

See Also

See other functions in this section

Availability

In release 6.4.0

Macro MAJSTRGETUNIQUESTR

Make certain a string is modifiable by checking it has no other references, or by making a new real copy of the string.

Uses strCloneL to copy without copying the reference count.

The target string is guaranteed to have a reference count of exactly 1.

A macro version of {ajStrGetuniqueStr} in case it is needed for speed

Input & Output
Pstr:(Modify)String
Returns
AjPStr:The new string pointer, or NULL for failure

Description

Make certain a string is modifiable by checking it has no other references, or by making a new real copy of the string.

Uses strCloneL to copy without copying the reference count.

The target string is guaranteed to have a reference count of exactly 1.

A macro version of {ajStrGetuniqueStr} in case it is needed for speed

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrGetuniqueStr

Make certain a string is modifiable by checking it has no other references, or by making a new real copy of the string.

Uses strCloneL to copy without copying the reference count.

The target string is guaranteed to have a reference count of exactly 1.

Synopsis

Prototype
AjPStr ajStrGetuniqueStr (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjPStr RETURNThe new string pointer, or NULL for failure

Input & Output
Pstr:(Modify)String
Returns
AjPStr:The new string pointer, or NULL for failure

Description

Make certain a string is modifiable by checking it has no other references, or by making a new real copy of the string.

Uses strCloneL to copy without copying the reference count.

The target string is guaranteed to have a reference count of exactly 1.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: element assignment

Functions for assigning elements of a string object.

Functions: ajStrSetClear ajStrSetRes ajStrSetResRound ajStrSetValid ajStrSetValidLen


Function ajStrSetClear

Clears all elements in a string object.

If the string is already empty nothing happens. If the string has data, it makes sure the string is modifiable and sets it to empty.

Synopsis

Prototype
AjBool ajStrSetClear (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputPointer to the string to be deleted. The pointer is always deleted.
AjBool RETURNajTrue if string was reallocated

Output
Pstr:(Output)Pointer to the string to be deleted. The pointer is always deleted.
Returns
AjBool:ajTrue if string was reallocated

Description

Clears all elements in a string object.

If the string is already empty nothing happens. If the string has data, it makes sure the string is modifiable and sets it to empty.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSetRes

Ensures a string is modifiable and big enough for its intended purpose.

The target string is guaranteed to have a reference count of 1 and a minimum reserved size.

Synopsis

Prototype
AjBool ajStrSetRes (
      AjPStr* Pstr,
      size_t size
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
size_tsizeInputMinimum reserved size.
AjBool RETURNajTrue if the string was reallocated

Input
size:(Input)Minimum reserved size.
Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if the string was reallocated

Description

Ensures a string is modifiable and big enough for its intended purpose.

The target string is guaranteed to have a reference count of 1 and a minimum reserved size.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSetResRound

Ensures a string is modifiable and big enough for its intended purpose.

The target string is guaranteed to have a reference count of 1, and a minimum reserved size. The string size is rounded up.

Synopsis

Prototype
AjBool ajStrSetResRound (
      AjPStr* Pstr,
      size_t size
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString
size_tsizeInputMinimum reserved size.
AjBool RETURNajTrue if the string was reallocated

Input
size:(Input)Minimum reserved size.
Output
Pstr:(Output)String
Returns
AjBool:ajTrue if the string was reallocated

Description

Ensures a string is modifiable and big enough for its intended purpose.

The target string is guaranteed to have a reference count of 1, and a minimum reserved size. The string size is rounded up.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSetValid

Reset string length when some nasty caller may have edited it

Synopsis

Prototype
AjBool ajStrSetValid (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString.
AjBool RETURNTrue on success.

Input & Output
Pstr:(Modify)String.
Returns
AjBool:True on success.

Description

Reset string length when some nasty caller may have edited it

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSetValidLen

Reset string length when some nasty caller may have edited it

Synopsis

Prototype
AjBool ajStrSetValidLen (
      AjPStr* Pstr,
      size_t len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
size_tlenInputLength expected.
AjBool RETURNTrue on success

Input
len:(Input)Length expected.
Input & Output
Pstr:(Modify)String
Returns
AjBool:True on success

Description

Reset string length when some nasty caller may have edited it

See Also

See other functions in this section

Availability

In release 6.4.0

Section: string to datatype conversion functions

Functions for converting strings to other datatypes.

Functions: ajStrToBool ajStrToDouble ajStrToFloat ajStrToHex ajStrToInt ajStrToLong ajStrToUint ajStrToUlong


Function ajStrToBool

Converts a string into a Boolean value.

Synopsis

Prototype
AjBool ajStrToBool (
      const AjPStr str,
      AjBool* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjBool*PvalOutputajTrue if the string is "true" as a boolean.
AjBool RETURNajTrue if the string had a valid boolean value.

Input
str:(Input)String
Output
Pval:(Output)ajTrue if the string is "true" as a boolean.
Returns
AjBool:ajTrue if the string had a valid boolean value.

Description

Converts a string into a Boolean value.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToDouble

Converts a string into a double precision value.

Uses the strtod call in the C RTL.

Synopsis

Prototype
AjBool ajStrToDouble (
      const AjPStr str,
      double* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
double*PvalOutputString represented as a double precision number.
AjBool RETURNajTrue if the string had a valid double precision value.

Input
str:(Input)String
Output
Pval:(Output)String represented as a double precision number.
Returns
AjBool:ajTrue if the string had a valid double precision value.

Description

Converts a string into a double precision value.

Uses the strtod call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToFloat

Converts a string into a floating point value.

Uses the strtod call in the C RTL.

Synopsis

Prototype
AjBool ajStrToFloat (
      const AjPStr str,
      float* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
float*PvalOutputString represented as a floating point number.
AjBool RETURNajTrue if the string had a valid floating point value.

Input
str:(Input)String
Output
Pval:(Output)String represented as a floating point number.
Returns
AjBool:ajTrue if the string had a valid floating point value.

Description

Converts a string into a floating point value.

Uses the strtod call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToHex

Converts a string from hexadecimal into an integer value.

Uses the strtol call in the C RTL.

Synopsis

Prototype
AjBool ajStrToHex (
      const AjPStr str,
      ajint* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajint*PvalOutputString represented as an integer.
AjBool RETURNajTrue if the string had a valid hexadecimal value.

Input
str:(Input)String
Output
Pval:(Output)String represented as an integer.
Returns
AjBool:ajTrue if the string had a valid hexadecimal value.

Description

Converts a string from hexadecimal into an integer value.

Uses the strtol call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToInt

Converts a string into an integer value.

Uses the strtol call in the C RTL.

Synopsis

Prototype
AjBool ajStrToInt (
      const AjPStr str,
      ajint* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajint*PvalOutputString represented as an integer.
AjBool RETURNajTrue if the string had a valid integer value.

Input
str:(Input)String
Output
Pval:(Output)String represented as an integer.
Returns
AjBool:ajTrue if the string had a valid integer value.

Description

Converts a string into an integer value.

Uses the strtol call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToLong

Converts a string into an integer value.

Uses the strtol call in the C RTL.

Synopsis

Prototype
AjBool ajStrToLong (
      const AjPStr str,
      ajlong* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajlong*PvalOutputString represented as an integer.
AjBool RETURNajTrue if the string had a valid integer value.

Input
str:(Input)String
Output
Pval:(Output)String represented as an integer.
Returns
AjBool:ajTrue if the string had a valid integer value.

Description

Converts a string into an integer value.

Uses the strtol call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToUint

Converts a string into an unsigned integer value.

Uses the strtoul call in the C RTL from C89 onwards.

Synopsis

Prototype
AjBool ajStrToUint (
      const AjPStr str,
      ajuint* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajuint*PvalOutputString represented as an unsigned integer.
AjBool RETURNajTrue if the string had a valid unsigned integer value.

Input
str:(Input)String
Output
Pval:(Output)String represented as an unsigned integer.
Returns
AjBool:ajTrue if the string had a valid unsigned integer value.

Description

Converts a string into an unsigned integer value.

Uses the strtoul call in the C RTL from C89 onwards.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrToUlong

Converts a string into an unsigned long integer value.

Uses the strtoul call in the C RTL.

Synopsis

Prototype
AjBool ajStrToUlong (
      const AjPStr str,
      ajulong* Pval
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajulong*PvalOutputString represented as an integer.
AjBool RETURNajTrue if the string had a valid integer value.

Input
str:(Input)String
Output
Pval:(Output)String represented as an integer.
Returns
AjBool:ajTrue if the string had a valid integer value.

Description

Converts a string into an unsigned long integer value.

Uses the strtoul call in the C RTL.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: datatype to string conversion functions

Functions for converting datatypes to strings.

Functions: ajStrFromBool ajStrFromDouble ajStrFromDoubleExp ajStrFromFloat ajStrFromInt ajStrFromLong ajStrFromUint ajStrFromVoid


Function ajStrFromBool

Converts a Boolean value into a 1-letter string.

Can be used to print boolean values, but the ajFmt library has better ways.

Synopsis

Prototype
AjBool ajStrFromBool (
      AjPStr* Pstr,
      AjBool val
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputString to hold the result.
AjBoolvalInputBoolean value
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Boolean value
Output
Pstr:(Output)String to hold the result.
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a Boolean value into a 1-letter string.

Can be used to print boolean values, but the ajFmt library has better ways.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromDouble

Converts a double precision value into a string.

The string size is set to be just large enough to hold the value.

Synopsis

Prototype
AjBool ajStrFromDouble (
      AjPStr* Pstr,
      double val,
      ajint precision
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
doublevalInputDouble precision value
ajintprecisionInputPrecision (number of decimal places) to use.
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Double precision value
precision:(Input)Precision (number of decimal places) to use.
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a double precision value into a string.

The string size is set to be just large enough to hold the value.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromDoubleExp

Converts a double precision value into a string.

The string size is set to be just large enough to hold the value. Uses exponential form.

Synopsis

Prototype
AjBool ajStrFromDoubleExp (
      AjPStr* Pstr,
      double val,
      ajint precision
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
doublevalInputDouble precision value
ajintprecisionInputPrecision (number of decimal places) to use.
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Double precision value
precision:(Input)Precision (number of decimal places) to use.
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a double precision value into a string.

The string size is set to be just large enough to hold the value. Uses exponential form.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromFloat

Converts a floating point value into a string.

The string size is set to be just large enough to hold the value.

Synopsis

Prototype
AjBool ajStrFromFloat (
      AjPStr* Pstr,
      float val,
      ajint precision
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
floatvalInputFloating point value
ajintprecisionInputPrecision (number of decimal places) to use.
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Floating point value
precision:(Input)Precision (number of decimal places) to use.
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a floating point value into a string.

The string size is set to be just large enough to hold the value.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromInt

Converts an integer value into a string.

The string size is set to be just large enough to hold the value.

Synopsis

Prototype
AjBool ajStrFromInt (
      AjPStr* Pstr,
      ajint val
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
ajintvalInputInteger value
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Integer value
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Converts an integer value into a string.

The string size is set to be just large enough to hold the value.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromLong

Converts an ajlong integer value into a string.

The string size is set to be just large enough to hold the value.

Synopsis

Prototype
AjBool ajStrFromLong (
      AjPStr* Pstr,
      ajlong val
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
ajlongvalInputLong integer value
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Long integer value
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Converts an ajlong integer value into a string.

The string size is set to be just large enough to hold the value.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromUint

Converts an unsigned integer value into a string.

The string size is set to be just large enough to hold the value.

Synopsis

Prototype
AjBool ajStrFromUint (
      AjPStr* Pstr,
      ajuint val
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
ajuintvalInputInteger value
AjBool RETURNajTrue if string was reallocated

Input
val:(Input)Integer value
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was reallocated

Description

Converts an unsigned integer value into a string.

The string size is set to be just large enough to hold the value.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFromVoid

Tests a void pointer and if it is potentially an ASCII string saves it as the output string.

The string size is set to be just large enough to hold the value.

Intended to allow possible strings to be reported in tables and lists where they must be held as void* pointers

Synopsis

Prototype
AjBool ajStrFromVoid (
      AjPStr* Pstr,
      const void* vval
);

TypeNameRead/WriteDescription
AjPStr*PstrOutputTarget string
const void*vvalInputInteger value
AjBool RETURNajTrue if string was found

Input
vval:(Input)Integer value
Output
Pstr:(Output)Target string
Returns
AjBool:ajTrue if string was found

Description

Tests a void pointer and if it is potentially an ASCII string saves it as the output string.

The string size is set to be just large enough to hold the value.

Intended to allow possible strings to be reported in tables and lists where they must be held as void* pointers

See Also

See other functions in this section

Availability

In release 6.4.0

Section: formatting

Functions for formatting strings.

Functions: ajStrFmtBlock ajStrFmtLower ajStrFmtLowerSub ajStrFmtPercentDecode ajStrFmtPercentEncodeC ajStrFmtPercentEncodeS ajStrFmtQuery ajStrFmtQuote ajStrFmtTitle ajStrFmtUpper ajStrFmtUpperSub ajStrFmtWord ajStrFmtWrap ajStrFmtWrapAt ajStrFmtWrapLeft


Function ajStrFmtBlock

Splits a string into words (blocks) of a given size by inserting spaces.

Mainly intended for sequence output formats

Synopsis

Prototype
AjBool ajStrFmtBlock (
      AjPStr* Pstr,
      ajulong len
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString.
ajulonglenInputBlock size
AjBool RETURNajTrue on success

Input
len:(Input)Block size
Input & Output
Pstr:(Modify)String.
Returns
AjBool:ajTrue on success

Description

Splits a string into words (blocks) of a given size by inserting spaces.

Mainly intended for sequence output formats

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtLower

Converts a string to lower case.

If the string has multiple references, a new string is made first.

Synopsis

Prototype
AjBool ajStrFmtLower (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a string to lower case.

If the string has multiple references, a new string is made first.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtLowerSub

Converts a substring of a string to lower case.

Synopsis

Prototype
AjBool ajStrFmtLowerSub (
      AjPStr* Pstr,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
ajlongpos1Inputstart position for conversion
ajlongpos2Inputend position for conversion
AjBool RETURNajTrue if string was reallocated

Input
pos1:(Input)start position for conversion
pos2:(Input)end position for conversion
Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a substring of a string to lower case.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtPercentDecode

Converts percent-encoded characters

Synopsis

Prototype
AjBool ajStrFmtPercentDecode (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
AjBool RETURNTrue if string is not empty.

Input & Output
Pstr:(Modify)string
Returns
AjBool:True if string is not empty.

Description

Converts percent-encoded characters

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtPercentEncodeC

Percent-encoded specified characters

Synopsis

Prototype
AjBool ajStrFmtPercentEncodeC (
      AjPStr* Pstr,
      const char* txt
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
const char*txtInputCharacters to encode
AjBool RETURNTrue if string is not empty.

Input
txt:(Input)Characters to encode
Input & Output
Pstr:(Modify)string
Returns
AjBool:True if string is not empty.

Description

Percent-encoded specified characters

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtPercentEncodeS

Percent-encoded specified characters

Synopsis

Prototype
AjBool ajStrFmtPercentEncodeS (
      AjPStr* Pstr,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
const AjPStrstrInputCharacters to encode
AjBool RETURNTrue if string is not empty.

Input
str:(Input)Characters to encode
Input & Output
Pstr:(Modify)string
Returns
AjBool:True if string is not empty.

Description

Percent-encoded specified characters

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtQuery

Ensures a string is a standard EMBOSS query term with all alphabetic characters in lower case, and any non alphanumeric characters replaced by an underscore

Synopsis

Prototype
AjBool ajStrFmtQuery (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
AjBool RETURNTrue if string is not empty.

Input & Output
Pstr:(Modify)string
Returns
AjBool:True if string is not empty.

Description

Ensures a string is a standard EMBOSS query term with all alphabetic characters in lower case, and any non alphanumeric characters replaced by an underscore

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtQuote

Ensures a string is quoted with double quotes.

Synopsis

Prototype
AjBool ajStrFmtQuote (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifystring
AjBool RETURNTrue if string is not empty. As it is at least quoted, it will always return true.

Input & Output
Pstr:(Modify)string
Returns
AjBool:True if string is not empty. As it is at least quoted, it will always return true.

Description

Ensures a string is quoted with double quotes.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtTitle

Converts the first character of a string to upper case.

Synopsis

Prototype
AjBool ajStrFmtTitle (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Converts the first character of a string to upper case.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtUpper

Converts a string to upper case.

If the string has multiple references, a new string is made first.

Synopsis

Prototype
AjBool ajStrFmtUpper (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue if string was reallocated

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a string to upper case.

If the string has multiple references, a new string is made first.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtUpperSub

Converts a substring of a string to upper case.

Synopsis

Prototype
AjBool ajStrFmtUpperSub (
      AjPStr* Pstr,
      ajlong pos1,
      ajlong pos2
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
ajlongpos1Inputstart position for conversion
ajlongpos2Inputend position for conversion
AjBool RETURNajTrue if string was reallocated

Input
pos1:(Input)start position for conversion
pos2:(Input)end position for conversion
Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue if string was reallocated

Description

Converts a substring of a string to upper case.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtWord

Converts a string to a single word. Spaces are converted to underscores. Leading substrings ending in a colon are removed.

Synopsis

Prototype
AjBool ajStrFmtWord (
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyString
AjBool RETURNajTrue on success

Input & Output
Pstr:(Modify)String
Returns
AjBool:ajTrue on success

Description

Converts a string to a single word. Spaces are converted to underscores. Leading substrings ending in a colon are removed.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtWrap

Formats a string so that it wraps when printed.

Newline characters are inserted, at white space if possible, with a break at whitespace following the preferred character if found, or at the last whitespace, or just at the line width if there is no whitespace found (it does happen with long hyphenated enzyme names)

Synopsis

Prototype
AjBool ajStrFmtWrap (
      AjPStr* Pstr,
      ajuint width
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajuintwidthInputLine width
AjBool RETURNajTrue on successful completion else ajFalse;

Input
width:(Input)Line width
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on successful completion else ajFalse;

Description

Formats a string so that it wraps when printed.

Newline characters are inserted, at white space if possible, with a break at whitespace following the preferred character if found, or at the last whitespace, or just at the line width if there is no whitespace found (it does happen with long hyphenated enzyme names)

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtWrapAt

Formats a string so that it wraps when printed. Breaks are at a preferred character (for example ',' for author lists)

Newline characters are inserted, at white space if possible, with a break at whitespace following the preferred character if found, or at the last whitespace, or just at the line width if there is no whitespace found (it does happen with long hyphenated enzyme names)

Synopsis

Prototype
AjBool ajStrFmtWrapAt (
      AjPStr* Pstr,
      ajuint width,
      char ch
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajuintwidthInputLine width
charchInputPreferred last character on line
AjBool RETURNajTrue on successful completion else ajFalse;

Input
width:(Input)Line width
ch:(Input)Preferred last character on line
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on successful completion else ajFalse;

Description

Formats a string so that it wraps when printed. Breaks are at a preferred character (for example ',' for author lists)

Newline characters are inserted, at white space if possible, with a break at whitespace following the preferred character if found, or at the last whitespace, or just at the line width if there is no whitespace found (it does happen with long hyphenated enzyme names)

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFmtWrapLeft

Formats a string so that it wraps and has a margin of space characters and an additional indent when printed.

Newline characters are inserted, at white space if possible,

Synopsis

Prototype
AjBool ajStrFmtWrapLeft (
      AjPStr* Pstr,
      ajuint width,
      ajuint margin,
      ajuint indent
);

TypeNameRead/WriteDescription
AjPStr*PstrModifyTarget string
ajuintwidthInputLine width
ajuintmarginInputLeft margin
ajuintindentInputLeft indentation on later lines
AjBool RETURNajTrue on successful completion else ajFalse;

Input
width:(Input)Line width
margin:(Input)Left margin
indent:(Input)Left indentation on later lines
Input & Output
Pstr:(Modify)Target string
Returns
AjBool:ajTrue on successful completion else ajFalse;

Description

Formats a string so that it wraps and has a margin of space characters and an additional indent when printed.

Newline characters are inserted, at white space if possible,

See Also

See other functions in this section

Availability

In release 6.4.0

Section: comparison

Functions for comparing strings

Functions: ajStrMatchC ajStrMatchS ajStrMatchCaseC ajStrMatchCaseS ajStrMatchWildC ajStrMatchWildS ajStrMatchWildCaseC ajStrMatchWildCaseS ajStrMatchWildWordC ajStrMatchWildWordS ajStrMatchWildWordCaseC ajStrMatchWildWordCaseS ajStrMatchWordAllS ajStrMatchWordOneS ajStrPrefixC ajStrPrefixS ajStrPrefixCaseC ajStrPrefixCaseS ajStrSuffixC ajStrSuffixS ajStrSuffixCaseC ajStrSuffixCaseS


Function ajStrMatchC

Simple test for matching a string and a text string.

Synopsis

Prototype
AjBool ajStrMatchC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputText
AjBool RETURNajTrue if two complete strings are the same

Input
str:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if two complete strings are the same

Description

Simple test for matching a string and a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchS

Simple test for matching two strings.

Synopsis

Prototype
AjBool ajStrMatchS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputSecond String
AjBool RETURNajTrue if two complete strings are the same

Input
str:(Input)String
str2:(Input)Second String
Returns
AjBool:ajTrue if two complete strings are the same

Description

Simple test for matching two strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchCaseC

Simple case-insensitive test for matching a string and a text string.

Synopsis

Prototype
AjBool ajStrMatchCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputText
AjBool RETURNajTrue if two strings are exactly the same excluding case

Input
str:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if two strings are exactly the same excluding case

Description

Simple case-insensitive test for matching a string and a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchCaseS

Simple case-insensitive test for matching two strings.

Synopsis

Prototype
AjBool ajStrMatchCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputSecond String
AjBool RETURNajTrue if two strings are exactly the same excluding case

Input
str:(Input)String
str2:(Input)Second String
Returns
AjBool:ajTrue if two strings are exactly the same excluding case

Description

Simple case-insensitive test for matching two strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildC

Simple case-sensitive test for matching a string and a text string using wildcard characters.

Synopsis

Prototype
AjBool ajStrMatchWildC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputWildcard text
AjBool RETURNajTrue if the strings match

Input
str:(Input)String
txt2:(Input)Wildcard text
Returns
AjBool:ajTrue if the strings match

Description

Simple case-sensitive test for matching a string and a text string using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildS

Simple case-sensitive test for matching two strings using wildcard characters.

Synopsis

Prototype
AjBool ajStrMatchWildS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputWildcard string
AjBool RETURNajTrue if two strings match

Input
str:(Input)String
str2:(Input)Wildcard string
Returns
AjBool:ajTrue if two strings match

Description

Simple case-sensitive test for matching two strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildCaseC

Simple case-insensitive test for matching a string and a text string using wildcard characters.

Synopsis

Prototype
AjBool ajStrMatchWildCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputWildcard text
AjBool RETURNajTrue if the strings match

Input
str:(Input)String
txt2:(Input)Wildcard text
Returns
AjBool:ajTrue if the strings match

Description

Simple case-insensitive test for matching a string and a text string using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildCaseS

Simple case-insensitive test for matching two strings using wildcard characters.

Synopsis

Prototype
AjBool ajStrMatchWildCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputWildcard string
AjBool RETURNajTrue if two strings match

Input
str:(Input)String
str2:(Input)Wildcard string
Returns
AjBool:ajTrue if two strings match

Description

Simple case-insensitive test for matching two strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildWordC

Case-sensitive test for matching a text string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

Synopsis

Prototype
AjBool ajStrMatchWildWordC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputText
AjBool RETURNajTrue if found

Input
str:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Case-sensitive test for matching a text string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildWordS

Case-sensitive test for matching a string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

Synopsis

Prototype
AjBool ajStrMatchWildWordS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputText
AjBool RETURNajTrue if found

Input
str:(Input)String
str2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Case-sensitive test for matching a string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildWordCaseC

Case-insensitive test for matching a text string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

Synopsis

Prototype
AjBool ajStrMatchWildWordCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputText
AjBool RETURNajTrue if found

Input
str:(Input)String
txt2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Case-insensitive test for matching a text string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWildWordCaseS

Case-insensitive test for matching a string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

Synopsis

Prototype
AjBool ajStrMatchWildWordCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputText
AjBool RETURNajTrue if found

Input
str:(Input)String
str2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Case-insensitive test for matching a string "word" against a string using wildcard characters.

'Word' is defined as starting and ending with an alphanumeric character (A-Z a-z 0-9) with no white space.

The query text can use '*' or '?' as a wildcard.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWordAllS

Test for matching all words within a string. Matches can be to parts of words in the original string.

'Word' is defined as no white space.

Synopsis

Prototype
AjBool ajStrMatchWordAllS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputText
AjBool RETURNajTrue if found

Input
str:(Input)String
str2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Test for matching all words within a string. Matches can be to parts of words in the original string.

'Word' is defined as no white space.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrMatchWordOneS

Test for matching a word within a string. Matches can be to parts of words in the original string.

'Word' is defined as no white space.

Synopsis

Prototype
AjBool ajStrMatchWordOneS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputText
AjBool RETURNajTrue if found

Input
str:(Input)String
str2:(Input)Text
Returns
AjBool:ajTrue if found

Description

Test for matching a word within a string. Matches can be to parts of words in the original string.

'Word' is defined as no white space.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPrefixC

Test for matching the start of a string against a given prefix text string.

Synopsis

Prototype
AjBool ajStrPrefixC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputPrefix as text
AjBool RETURNajTrue if the string begins with the prefix

Input
str:(Input)String
txt2:(Input)Prefix as text
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Test for matching the start of a string against a given prefix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPrefixS

Test for matching the start of a string against a given prefix string.

Synopsis

Prototype
AjBool ajStrPrefixS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputPrefix
AjBool RETURNajTrue if the string begins with the prefix

Input
str:(Input)String
str2:(Input)Prefix
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Test for matching the start of a string against a given prefix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPrefixCaseC

Case-insensitive test for matching the start of a string against a given prefix text string.

Synopsis

Prototype
AjBool ajStrPrefixCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputPrefix
AjBool RETURNajTrue if the string begins with the prefix

Input
str:(Input)String
txt2:(Input)Prefix
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Case-insensitive test for matching the start of a string against a given prefix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrPrefixCaseS

Case-insensitive test for matching the start of a string against a given prefix string.

Synopsis

Prototype
AjBool ajStrPrefixCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputPrefix
AjBool RETURNajTrue if the string begins with the prefix

Input
str:(Input)String
str2:(Input)Prefix
Returns
AjBool:ajTrue if the string begins with the prefix

Description

Case-insensitive test for matching the start of a string against a given prefix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSuffixC

Test for matching the end of a string against a given suffix text string.

Synopsis

Prototype
AjBool ajStrSuffixC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputSuffix as text
AjBool RETURNajTrue if the string ends with the suffix

Input
str:(Input)String
txt2:(Input)Suffix as text
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Test for matching the end of a string against a given suffix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSuffixS

Test for matching the end of a string against a given suffix string.

Synopsis

Prototype
AjBool ajStrSuffixS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputSuffix
AjBool RETURNajTrue if the string ends with the suffix

Input
str:(Input)String
str2:(Input)Suffix
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Test for matching the end of a string against a given suffix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSuffixCaseC

Case-insensitive test for matching the end of a string against a given suffix text string.

Synopsis

Prototype
AjBool ajStrSuffixCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputPrefix
AjBool RETURNajTrue if the string ends with the suffix

Input
str:(Input)String
txt2:(Input)Prefix
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Case-insensitive test for matching the end of a string against a given suffix text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrSuffixCaseS

Case-insensitive test for matching the end of a string against a given suffix string.

Synopsis

Prototype
AjBool ajStrSuffixCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputPrefix
AjBool RETURNajTrue if the string ends with the suffix

Input
str:(Input)String
str2:(Input)Prefix
Returns
AjBool:ajTrue if the string ends with the suffix

Description

Case-insensitive test for matching the end of a string against a given suffix string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: comparison (sorting)

Functions for sorting strings.

Functions: MAJSTRCMPC ajStrCmpC ajStrCmpLenC MAJSTRCMPS ajStrCmpS ajStrCmpCaseS ajStrCmpLenS ajStrCmpWildC ajStrCmpWildS ajStrCmpWildCaseC ajStrCmpWildCaseS ajStrVcmp


Macro MAJSTRCMPC

Finds the sort order of a string and a text string.

A macro version of {ajStrCmpC} in case it is needed for speed

Input
str:(Input)String object
txt2:(Input)Text string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of a string and a text string.

A macro version of {ajStrCmpC} in case it is needed for speed

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpC

Finds the sort order of a string and a text string.

Synopsis

Prototype
int ajStrCmpC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString object
const char*txt2InputText string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String object
txt2:(Input)Text string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of a string and a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpLenC

Finds the sort order of a string and a text string comparing the first n characters only.

Synopsis

Prototype
int ajStrCmpLenC (
      const AjPStr str,
      const char* txt2,
      size_t len
);

TypeNameRead/WriteDescription
const AjPStrstrInputString object
const char*txt2InputText string
size_tlenInputLength to compare
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String object
txt2:(Input)Text string
len:(Input)Length to compare
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of a string and a text string comparing the first n characters only.

See Also

See other functions in this section

Availability

In release 6.4.0

Macro MAJSTRCMPS

Finds the sort order of two strings.

A macro version of {ajStrCmpS} in case it is needed for speed

Input
str:(Input)First string
str2:(Input)Second string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of two strings.

A macro version of {ajStrCmpS} in case it is needed for speed

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpS

Finds the sort order of two strings.

Synopsis

Prototype
int ajStrCmpS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputFirst string
const AjPStrstr2InputSecond string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)First string
str2:(Input)Second string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of two strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpCaseS

Finds the sort order of two strings using a case-insensitive comparison.

Synopsis

Prototype
int ajStrCmpCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputtext string
const AjPStrstr2InputText string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)text string
str2:(Input)Text string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of two strings using a case-insensitive comparison.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpLenS

Finds the sort order of two strings comparing the first n characters only.

Compares the first n characters of two strings

Synopsis

Prototype
int ajStrCmpLenS (
      const AjPStr str,
      const AjPStr str2,
      size_t len
);

TypeNameRead/WriteDescription
const AjPStrstrInputString object
const AjPStrstr2InputSecond string object
size_tlenInputLength to compare
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String object
str2:(Input)Second string object
len:(Input)Length to compare
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of two strings comparing the first n characters only.

Compares the first n characters of two strings

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpWildC

Finds the sort-order (case insensitive) of string and a text string using wildcard characters.

Synopsis

Prototype
int ajStrCmpWildC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputWildcard text
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String
txt2:(Input)Wildcard text
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort-order (case insensitive) of string and a text string using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpWildS

Finds the sort-order (case insensitive) of two strings using wildcard characters.

Synopsis

Prototype
int ajStrCmpWildS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputWildcard string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String
str2:(Input)Wildcard string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort-order (case insensitive) of two strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpWildCaseC

Finds the sort-order (case sensitive) of string and a text string using wildcard characters.

Synopsis

Prototype
int ajStrCmpWildCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2InputWildcard text
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String
txt2:(Input)Wildcard text
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort-order (case sensitive) of string and a text string using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrCmpWildCaseS

Finds the sort-order (case sensitive) of two strings using wildcard characters.

Synopsis

Prototype
int ajStrCmpWildCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2InputWildcard string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)String
str2:(Input)Wildcard string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort-order (case sensitive) of two strings using wildcard characters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrVcmp

Finds the sort order of two strings cast as void.

For use with {ajListSort}, {ajListUnique} and other functions which require a general function with void arguments.

Synopsis

Prototype
int ajStrVcmp (
      const void* str,
      const void* str2
);

TypeNameRead/WriteDescription
const void*strInputFirst string
const void*str2InputSecond string
int RETURN-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Input
str:(Input)First string
str2:(Input)Second string
Returns
int:-1 if first string should sort before second, +1 if the second string should sort first. 0 if they are identical in length and content.

Description

Finds the sort order of two strings cast as void.

For use with {ajListSort}, {ajListUnique} and other functions which require a general function with void arguments.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: comparison (search) functions

Functions for finding substrings or characters in strings.

Functions: ajStrFindC ajStrFindS ajStrFindAnyC ajStrFindAnyK ajStrFindAnyS ajStrFindCaseC ajStrFindCaseS ajStrFindNextC ajStrFindNextK ajStrFindNextS ajStrFindRestC ajStrFindRestS ajStrFindRestCaseC ajStrFindRestCaseS ajStrFindlastC ajStrFindlastK ajStrFindlastS


Function ajStrFindC

Finds the first occurrence in a string of a second (text) string.

Synopsis

Prototype
ajlong ajStrFindC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
txt2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindS

Finds the first occurrence in a string of a second string.

Synopsis

Prototype
ajlong ajStrFindS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
str2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of a second string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindAnyC

Finds the first occurrence in a string of any character in a second (text) string.

Synopsis

Prototype
ajlong ajStrFindAnyC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
txt2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of any character in a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindAnyK

Finds the first occurrence in a string of a specified character.

Synopsis

Prototype
ajlong ajStrFindAnyK (
      const AjPStr str,
      char chr
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
charchrInputcharacter to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
chr:(Input)character to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of a specified character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindAnyS

Finds the first occurrence in a string of any character in a second string.

Synopsis

Prototype
ajlong ajStrFindAnyS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
str2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of any character in a second string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindCaseC

Finds the first occurrence in a string of a second (text) string using a case-insensitive search.

Synopsis

Prototype
ajlong ajStrFindCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2Inputtext to find
ajlong RETURNPosition of the start of text in string if found.

Input
str:(Input)String
txt2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found.

Description

Finds the first occurrence in a string of a second (text) string using a case-insensitive search.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindCaseS

Finds the first occurrence in a string of a second string using a case-insensitive search.

Synopsis

Prototype
ajlong ajStrFindCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. -1 if not found.

Input
str:(Input)String
str2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. -1 if not found.

Description

Finds the first occurrence in a string of a second string using a case-insensitive search.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindNextC

Finds the next occurrence in a string of a second (text) string.

Synopsis

Prototype
ajlong ajStrFindNextC (
      const AjPStr str,
      ajlong pos1,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajlongpos1InputStart position in string
const char*txt2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
pos1:(Input)Start position in string
txt2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the next occurrence in a string of a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindNextK

Finds the next occurrence in a string of a specified character.

Synopsis

Prototype
ajlong ajStrFindNextK (
      const AjPStr str,
      ajlong pos1,
      char chr
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajlongpos1InputStart position in string
charchrInputcharacter to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
pos1:(Input)Start position in string
chr:(Input)character to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the next occurrence in a string of a specified character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindNextS

Finds the next occurrence in a string of any character in a second string.

Synopsis

Prototype
ajlong ajStrFindNextS (
      const AjPStr str,
      ajlong pos1,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
ajlongpos1InputStart position in string
const AjPStrstr2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
pos1:(Input)Start position in string
str2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the next occurrence in a string of any character in a second string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindRestC

Finds the first occurrence in a string of any character not in a second (text) string.

Synopsis

Prototype
ajlong ajStrFindRestC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
txt2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of any character not in a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindRestS

Finds the first occurrence in a string of any character not in a second (text) string.

Synopsis

Prototype
ajlong ajStrFindRestS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
str2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of any character not in a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindRestCaseC

Finds the first occurrence in a string of any character not in a second (text) string (case-insensitive).

Synopsis

Prototype
ajlong ajStrFindRestCaseC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*txt2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
txt2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of any character not in a second (text) string (case-insensitive).

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindRestCaseS

Finds the first occurrence in a string of any character not in a second (text) string (case-insensitive).

Synopsis

Prototype
ajlong ajStrFindRestCaseS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStrstr2Inputtext to find
ajlong RETURNPosition of the start of text in string if found. Or -1 for text not found.

Input
str:(Input)String
str2:(Input)text to find
Returns
ajlong:Position of the start of text in string if found. Or -1 for text not found.

Description

Finds the first occurrence in a string of any character not in a second (text) string (case-insensitive).

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindlastC

Finds the last occurrence in a string of a second (text) string.

Synopsis

Prototype
ajlong ajStrFindlastC (
      const AjPStr str,
      const char* txt2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to search
const char*txt2Inputtext to look for
ajlong RETURNPosition of the text string if found.

Input
str:(Input)String to search
txt2:(Input)text to look for
Returns
ajlong:Position of the text string if found.

Description

Finds the last occurrence in a string of a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindlastK

Finds the last occurrence in a string of a character.

Synopsis

Prototype
ajlong ajStrFindlastK (
      const AjPStr str,
      char chr
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to search
charchrInputCharacter to look for
ajlong RETURNPosition of the character if found.

Input
str:(Input)String to search
chr:(Input)Character to look for
Returns
ajlong:Position of the character if found.

Description

Finds the last occurrence in a string of a character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrFindlastS

Finds the last occurrence in a string of a second (text) string.

Synopsis

Prototype
ajlong ajStrFindlastS (
      const AjPStr str,
      const AjPStr str2
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to search
const AjPStrstr2Inputtext to look for
ajlong RETURNPosition of the text string if found.

Input
str:(Input)String to search
str2:(Input)text to look for
Returns
ajlong:Position of the text string if found.

Description

Finds the last occurrence in a string of a second (text) string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: parsing functions

Functions for parsing tokens from strings.

Functions: ajStrExtractFirst ajStrExtractToken ajStrExtractWord ajStrParseC ajStrParseCount ajStrParseCountC ajStrParseCountS ajStrParseCountMultiC ajStrParseSplit ajStrParseWhite


Function ajStrExtractFirst

Returns a word from the start of a string, and the remainder of the string

Synopsis

Prototype
AjBool ajStrExtractFirst (
      const AjPStr str,
      AjPStr* Prest,
      AjPStr* Pword
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to be parsed
AjPStr*PrestOutputRemainder of string
AjPStr*PwordOutputFirst word of string
AjBool RETURNTrue if parsing succeeded

Input
str:(Input)String to be parsed
Output
Prest:(Output)Remainder of string
Pword:(Output)First word of string
Returns
AjBool:True if parsing succeeded

Description

Returns a word from the start of a string, and the remainder of the string

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExtractToken

Returns a word from the start of a string, and the remainder of the string. Leading spaces and punctuation (commas, semicolons) are ignored

Synopsis

Prototype
AjBool ajStrExtractToken (
      const AjPStr str,
      AjPStr* Prest,
      AjPStr* Pword
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to be parsed
AjPStr*PrestOutputRemainder of string
AjPStr*PwordOutputFirst token of string
AjBool RETURNTrue if parsing succeeded

Input
str:(Input)String to be parsed
Output
Prest:(Output)Remainder of string
Pword:(Output)First token of string
Returns
AjBool:True if parsing succeeded

Description

Returns a word from the start of a string, and the remainder of the string. Leading spaces and punctuation (commas, semicolons) are ignored

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrExtractWord

Returns a word from the start of a string, and the remainder of the string. Leading spaces are skipped.

Synopsis

Prototype
AjBool ajStrExtractWord (
      const AjPStr str,
      AjPStr* Prest,
      AjPStr* Pword
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to be parsed
AjPStr*PrestOutputRemainder of string
AjPStr*PwordOutputFirst word of string
AjBool RETURNTrue if parsing succeeded

Input
str:(Input)String to be parsed
Output
Prest:(Output)Remainder of string
Pword:(Output)First word of string
Returns
AjBool:True if parsing succeeded

Description

Returns a word from the start of a string, and the remainder of the string. Leading spaces are skipped.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseC

Tokenise a string using a specified set of delimiters and return tokens from the string.

This function uses the C run time library strtok function. This makes it necessary to only call it from one string at a time as strtok and this function have internal memories of the last position.

Synopsis

Prototype
const AjPStr ajStrParseC (
      const AjPStr str,
      const char* txtdelim
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to be parsed (first call) or NULL for follow-up calls using the same string, as for the C RTL function strtok which is eventually called.
const char*txtdelimInputDelimiter(s) to be used between tokens.
const AjPStr RETURNToken returned, when all tokens are parsed a NULL is returned.

Input
str:(Input)String to be parsed (first call) or NULL for follow-up calls using the same string, as for the C RTL function strtok which is eventually called.
txtdelim:(Input)Delimiter(s) to be used between tokens.
Returns
const AjPStr:Token returned, when all tokens are parsed a NULL is returned.

Description

Tokenise a string using a specified set of delimiters and return tokens from the string.

This function uses the C run time library strtok function. This makes it necessary to only call it from one string at a time as strtok and this function have internal memories of the last position.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseCount

Returns the number of tokens in a string, delimited by whitespace

Synopsis

Prototype
ajuint ajStrParseCount (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to examine.
ajuint RETURNThe number of tokens

Input
str:(Input)String to examine.
Returns
ajuint:The number of tokens

Description

Returns the number of tokens in a string, delimited by whitespace

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseCountC

Returns the number of tokens in a string using a specified set of delimiters held in a text string.

Synopsis

Prototype
ajuint ajStrParseCountC (
      const AjPStr str,
      const char* txtdelim
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to examine.
const char*txtdelimInputString of delimiter characters.
ajuint RETURNThe number of tokens

Input
str:(Input)String to examine.
txtdelim:(Input)String of delimiter characters.
Returns
ajuint:The number of tokens

Description

Returns the number of tokens in a string using a specified set of delimiters held in a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseCountS

Returns the number of tokens in a string using a specified set of delimiters held in a string.

Synopsis

Prototype
ajuint ajStrParseCountS (
      const AjPStr str,
      const AjPStr strdelim
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to examine.
const AjPStrstrdelimInputString of delimiter characters.
ajuint RETURNThe number of tokens

Input
str:(Input)String to examine.
strdelim:(Input)String of delimiter characters.
Returns
ajuint:The number of tokens

Description

Returns the number of tokens in a string using a specified set of delimiters held in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseCountMultiC

Returns the number of tokens in a string.

Uses reentrant {ajSysStrtokR} in place of the C RTL strtok function.

Synopsis

Prototype
ajuint ajStrParseCountMultiC (
      const AjPStr str,
      const char* txtdelim
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to examine.
const char*txtdelimInputString of delimiter characters.
ajuint RETURNThe number of tokens

Input
str:(Input)String to examine.
txtdelim:(Input)String of delimiter characters.
Returns
ajuint:The number of tokens

Description

Returns the number of tokens in a string.

Uses reentrant {ajSysStrtokR} in place of the C RTL strtok function.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseSplit

Splits a newline-separated multi-line string into an array of strings.

Synopsis

Prototype
ajuint ajStrParseSplit (
      const AjPStr str,
      AjPStr** PPstr
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
AjPStr**PPstrOutputpointer to array of AjPStrs
ajuint RETURNNumber of array elements created

Input
str:(Input)String
Output
PPstr:(Output)pointer to array of AjPStrs
Returns
ajuint:Number of array elements created

Description

Splits a newline-separated multi-line string into an array of strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrParseWhite

Tokenise a string using whitespace and return tokens from the string.

Synopsis

Prototype
const AjPStr ajStrParseWhite (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString to be parsed (first call) or NULL for follow-up calls using the same string, as for the C RTL function strtok which is eventually called.
const AjPStr RETURNToken

Input
str:(Input)String to be parsed (first call) or NULL for follow-up calls using the same string, as for the C RTL function strtok which is eventually called.
Returns
const AjPStr:Token

Description

Tokenise a string using whitespace and return tokens from the string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: debugging

Functions for reporting of a string object.

Functions: ajStrProbe ajStrStat ajStrTrace ajStrTraceFull ajStrTraceTitle


Function ajStrProbe

Default string memory probe which checks the string object and the string it contains are valid memory

If the given string is NULL, or a NULL pointer, simply returns.

Synopsis

Prototype
void ajStrProbe (
      AjPStr const* Pstr
);

TypeNameRead/WriteDescription
AjPStr const*PstrInputPointer to the string to be probed.
void RETURN

Input
Pstr:(Input)Pointer to the string to be probed.
Returns
void:No return value

Description

Default string memory probe which checks the string object and the string it contains are valid memory

If the given string is NULL, or a NULL pointer, simply returns.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrStat

Prints a summary of string usage with debug calls.

Synopsis

Prototype
void ajStrStat (
      const char* title
);

TypeNameRead/WriteDescription
const char*titleInputTitle for this summary
void RETURN

Input
title:(Input)Title for this summary
Returns
void:No return value

Description

Prints a summary of string usage with debug calls.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTrace

Checks a string object for consistency and reports its contents.

Synopsis

Prototype
void ajStrTrace (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
void RETURN

Input
str:(Input)String
Returns
void:No return value

Description

Checks a string object for consistency and reports its contents.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTraceFull

Checks a string object for consistency and reports its contents character by character.

Synopsis

Prototype
void ajStrTraceFull (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
void RETURN

Input
str:(Input)String
Returns
void:No return value

Description

Checks a string object for consistency and reports its contents character by character.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTraceTitle

Checks a string object for consistency and reports its contents using a defined title for the report.

Synopsis

Prototype
void ajStrTraceTitle (
      const AjPStr str,
      const char* title
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const char*titleInputReport title
void RETURN

Input
str:(Input)String
title:(Input)Report title
Returns
void:No return value

Description

Checks a string object for consistency and reports its contents using a defined title for the report.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: exit

Functions called on exit from the program by ajExit to do any necessary cleanup and to report internal statistics to the debug file

Functions: ajStrExit


Function ajStrExit

Prints a summary of string usage with debug calls.

Synopsis

Prototype
void ajStrExit (
      void
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

Description

Prints a summary of string usage with debug calls.

See Also

See other functions in this section

Availability

In release 6.4.0

Datatype: const AjPStr

String constant

Sections: string constant constructors


Section: string constant constructors

Functions for constructing string constant objects

Functions: ajStrConstS ajStrConstEmpty


Function ajStrConstS

Returns an unmodifiable empty string.

Synopsis

Prototype
const AjPStr ajStrConstS (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputString
const AjPStr RETURNPointer to an empty string

Input
str:(Input)String
Returns
const AjPStr:Pointer to an empty string

Description

Returns an unmodifiable empty string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrConstEmpty

Returns an unmodifiable empty string.

Synopsis

Prototype
const AjPStr ajStrConstEmpty (
      void
);

TypeNameRead/WriteDescription
const AjPStr RETURNPointer to an empty string

Returns
const AjPStr:Pointer to an empty string

Description

Returns an unmodifiable empty string.

See Also

See other functions in this section

Availability

In release 6.4.0

Datatype: AjIStr

String iterator

Sections: constructors destructors tests resets attributes modifiers stepping


Section: constructors

Functions: ajStrIterNew ajStrIterNewBack


Function ajStrIterNew

String iterator constructor which allocates memory for a string iterator, used to iterate over the characters in a string.

Synopsis

Prototype
AjIStr ajStrIterNew (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputOriginal string
AjIStr RETURNString Iterator

Input
str:(Input)Original string
Returns
AjIStr:String Iterator

Description

String iterator constructor which allocates memory for a string iterator, used to iterate over the characters in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIterNewBack

String iterator constructor which allocates memory for a string iterator, used to iterate over the characters in a string, from end to start.

Synopsis

Prototype
AjIStr ajStrIterNewBack (
      const AjPStr str
);

TypeNameRead/WriteDescription
const AjPStrstrInputOriginal string
AjIStr RETURNString Iterator

Input
str:(Input)Original string
Returns
AjIStr:String Iterator

Description

String iterator constructor which allocates memory for a string iterator, used to iterate over the characters in a string, from end to start.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: destructors

Functions: ajStrIterDel


Function ajStrIterDel

String iterator destructor which frees memory for a string iterator.

Synopsis

Prototype
void ajStrIterDel (
      AjIStr* iter
);

TypeNameRead/WriteDescription
AjIStr*iterDeleteString iterator
void RETURN

Output
iter:(Delete)String iterator
Returns
void:No return value

Description

String iterator destructor which frees memory for a string iterator.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: tests

Functions: ajStrIterDone ajStrIterDoneBack


Function ajStrIterDone

Tests whether a string iterator has completed yet.

Synopsis

Prototype
AjBool ajStrIterDone (
      const AjIStr iter
);

TypeNameRead/WriteDescription
const AjIStriterInputString iterator.
AjBool RETURNtrue if complete

Input
iter:(Input)String iterator.
Returns
AjBool:true if complete

Description

Tests whether a string iterator has completed yet.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIterDoneBack

Tests whether a string iterator (from end to start) has completed yet.

Synopsis

Prototype
AjBool ajStrIterDoneBack (
      const AjIStr iter
);

TypeNameRead/WriteDescription
const AjIStriterInputString iterator.
AjBool RETURNtrue if complete

Input
iter:(Input)String iterator.
Returns
AjBool:true if complete

Description

Tests whether a string iterator (from end to start) has completed yet.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: resets

Functions: ajStrIterBegin ajStrIterEnd


Function ajStrIterBegin

Sets a string iterator to its start condition,

Synopsis

Prototype
void ajStrIterBegin (
      AjIStr iter
);

TypeNameRead/WriteDescription
AjIStriterModifyString iterator.
void RETURN

Input & Output
iter:(Modify)String iterator.
Returns
void:No return value

Description

Sets a string iterator to its start condition,

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIterEnd

Sets a string iterator to its stop condition.

Synopsis

Prototype
void ajStrIterEnd (
      AjIStr iter
);

TypeNameRead/WriteDescription
AjIStriterModifyString iterator.
void RETURN

Input & Output
iter:(Modify)String iterator.
Returns
void:No return value

Description

Sets a string iterator to its stop condition.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: attributes

Functions: ajStrIterGetC ajStrIterGetK


Function ajStrIterGetC

Returns the remainder of the string at the current string iterator position.

Synopsis

Prototype
const char* ajStrIterGetC (
      const AjIStr iter
);

TypeNameRead/WriteDescription
const AjIStriterInputString iterator.
const char* RETURNCurrent text string within iterator

Input
iter:(Input)String iterator.
Returns
const char*:Current text string within iterator

Description

Returns the remainder of the string at the current string iterator position.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIterGetK

Returns the value (character) at the current string iterator position.

Synopsis

Prototype
char ajStrIterGetK (
      const AjIStr iter
);

TypeNameRead/WriteDescription
const AjIStriterInputString iterator.
char RETURNCurrent character within iterator

Input
iter:(Input)String iterator.
Returns
char:Current character within iterator

Description

Returns the value (character) at the current string iterator position.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: modifiers

Functions: ajStrIterPutK


Function ajStrIterPutK

Replaces the character at the current string iterator position.

Synopsis

Prototype
void ajStrIterPutK (
      AjIStr iter,
      char chr
);

TypeNameRead/WriteDescription
AjIStriterModifyString iterator.
charchrInputCharacter
void RETURN

Input
chr:(Input)Character
Input & Output
iter:(Modify)String iterator.
Returns
void:No return value

Description

Replaces the character at the current string iterator position.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: stepping

Functions: ajStrIterNext ajStrIterNextBack


Function ajStrIterNext

Step to next character in string iterator.

Synopsis

Prototype
AjIStr ajStrIterNext (
      AjIStr iter
);

TypeNameRead/WriteDescription
AjIStriterModifyString iterator.
AjIStr RETURNUpdated iterator duplicated as return value.

Input & Output
iter:(Modify)String iterator.
Returns
AjIStr:Updated iterator duplicated as return value.

Description

Step to next character in string iterator.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrIterNextBack

Step to previous character in string iterator.

Synopsis

Prototype
AjIStr ajStrIterNextBack (
      AjIStr iter
);

TypeNameRead/WriteDescription
AjIStriterModifyString iterator.
AjIStr RETURNUpdated iterator duplicated as return value.

Input & Output
iter:(Modify)String iterator.
Returns
AjIStr:Updated iterator duplicated as return value.

Description

Step to previous character in string iterator.

See Also

See other functions in this section

Availability

In release 6.4.0

Datatype: AjPStrTok

String token parser

Sections: constructors destructors assignment reset debugging parsing


Section: constructors

Functions: ajStrTokenNewC ajStrTokenNewS ajStrTokenNewcharC ajStrTokenNewcharS


Function ajStrTokenNewC

String token parser constructor which allocates memory for a string token parser object from a string and a set of default delimiters defined in a text string.

Synopsis

Prototype
AjPStrTok ajStrTokenNewC (
      const AjPStr str,
      const char* txtdelim
);

TypeNameRead/WriteDescription
const AjPStrstrInputSource string
const char*txtdelimInputDefault delimiter(s)
AjPStrTok RETURNA new string token parser.

Input
str:(Input)Source string
txtdelim:(Input)Default delimiter(s)
Returns
AjPStrTok:A new string token parser.

Description

String token parser constructor which allocates memory for a string token parser object from a string and a set of default delimiters defined in a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNewS

String token parser constructor which allocates memory for a string token parser object from a string and an optional set of default delimiters defined in a text string.

Synopsis

Prototype
AjPStrTok ajStrTokenNewS (
      const AjPStr str,
      const AjPStr strdelim
);

TypeNameRead/WriteDescription
const AjPStrstrInputSource string
const AjPStrstrdelimInputDefault delimiter(s)
AjPStrTok RETURNA new string token parser.

Input
str:(Input)Source string
strdelim:(Input)Default delimiter(s)
Returns
AjPStrTok:A new string token parser.

Description

String token parser constructor which allocates memory for a string token parser object from a string and an optional set of default delimiters defined in a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNewcharC

String token parser constructor which allocates memory for a string token parser object from a string and a set of default delimiters defined in a text string.

Synopsis

Prototype
AjPStrTok ajStrTokenNewcharC (
      const char* txt,
      const char* txtdelim
);

TypeNameRead/WriteDescription
const char*txtInputSource string
const char*txtdelimInputDefault delimiter(s)
AjPStrTok RETURNA new string token parser.

Input
txt:(Input)Source string
txtdelim:(Input)Default delimiter(s)
Returns
AjPStrTok:A new string token parser.

Description

String token parser constructor which allocates memory for a string token parser object from a string and a set of default delimiters defined in a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNewcharS

String token parser constructor which allocates memory for a string token parser object from a string and an optional set of default delimiters defined in a text string.

Synopsis

Prototype
AjPStrTok ajStrTokenNewcharS (
      const char* txt,
      const AjPStr strdelim
);

TypeNameRead/WriteDescription
const char*txtInputSource string
const AjPStrstrdelimInputDefault delimiter(s)
AjPStrTok RETURNA new string token parser.

Input
txt:(Input)Source string
strdelim:(Input)Default delimiter(s)
Returns
AjPStrTok:A new string token parser.

Description

String token parser constructor which allocates memory for a string token parser object from a string and an optional set of default delimiters defined in a text string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: destructors

Functions: ajStrTokenDel


Function ajStrTokenDel

String token parser destructor which frees memory for a string token parser.

Synopsis

Prototype
void ajStrTokenDel (
      AjPStrTok* Ptoken
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenDeleteToken parser
void RETURN

Output
Ptoken:(Delete)Token parser
Returns
void:No return value

Description

String token parser destructor which frees memory for a string token parser.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: assignment

Functions: ajStrTokenAssign ajStrTokenAssignC ajStrTokenAssignS


Function ajStrTokenAssign

Generates a string token parser object from a string without a specific set of delimiters.

Synopsis

Prototype
AjBool ajStrTokenAssign (
      AjPStrTok* Ptoken,
      const AjPStr str
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenOutputString token object
const AjPStrstrInputSource string
AjBool RETURNajTrue on success.

Input
str:(Input)Source string
Output
Ptoken:(Output)String token object
Returns
AjBool:ajTrue on success.

Description

Generates a string token parser object from a string without a specific set of delimiters.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenAssignC

Generates a string token parser object from a string and an optional set of default delimiters defined in a text string.

The string token can be either an existing token to be overwritten or a NULL.

Synopsis

Prototype
AjBool ajStrTokenAssignC (
      AjPStrTok* Ptoken,
      const AjPStr str,
      const char* txtdelim
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenOutputString token object
const AjPStrstrInputSource string
const char*txtdelimInputDefault delimiter(s)
AjBool RETURNajTrue on success.

Input
str:(Input)Source string
txtdelim:(Input)Default delimiter(s)
Output
Ptoken:(Output)String token object
Returns
AjBool:ajTrue on success.

Description

Generates a string token parser object from a string and an optional set of default delimiters defined in a text string.

The string token can be either an existing token to be overwritten or a NULL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenAssignS

Generates a string token parser object from a string and an optional set of default delimiters defined in a string.

Synopsis

Prototype
AjBool ajStrTokenAssignS (
      AjPStrTok* Ptoken,
      const AjPStr str,
      const AjPStr strdelim
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenOutputString token object
const AjPStrstrInputSource string
const AjPStrstrdelimInputDefault delimiter(s)
AjBool RETURNajTrue on success.

Input
str:(Input)Source string
strdelim:(Input)Default delimiter(s)
Output
Ptoken:(Output)String token object
Returns
AjBool:ajTrue on success.

Description

Generates a string token parser object from a string and an optional set of default delimiters defined in a string.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: reset

Functions: ajStrTokenReset


Function ajStrTokenReset

Clears the strings from a string token parser object.

Synopsis

Prototype
void ajStrTokenReset (
      AjPStrTok* Ptoken
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenOutputString token object
void RETURN

Output
Ptoken:(Output)String token object
Returns
void:No return value

Description

Clears the strings from a string token parser object.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: debugging

Functions: ajStrTokenTrace


Function ajStrTokenTrace

Writes a debug trace of a string token parser object.

Synopsis

Prototype
void ajStrTokenTrace (
      const AjPStrTok token
);

TypeNameRead/WriteDescription
const AjPStrToktokenInputString token object
void RETURN

Input
token:(Input)String token object
Returns
void:No return value

Description

Writes a debug trace of a string token parser object.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: parsing

Functions: ajStrTokenNextFind ajStrTokenNextFindC ajStrTokenNextParse ajStrTokenNextParseC ajStrTokenNextParseS ajStrTokenNextParseDelimiters ajStrTokenNextParseNoskip ajStrTokenRestParse


Function ajStrTokenNextFind

Parses tokens from a string using a string token parser. Treats the whole delimiter as a single string between tokens.

Synopsis

Prototype
AjBool ajStrTokenNextFind (
      AjPStrTok* Ptoken,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyToken parser. Updated with the delimiter string (if any) in delim.
AjPStr*PstrOutputToken found
AjBool RETURNajTrue if another token was found.

Output
Pstr:(Output)Token found
Input & Output
Ptoken:(Modify)Token parser. Updated with the delimiter string (if any) in delim.
Returns
AjBool:ajTrue if another token was found.

Description

Parses tokens from a string using a string token parser. Treats the whole delimiter as a single string between tokens.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNextFindC

Parses tokens from a string using a string token parser. Treats the whole delimiter as a single string between tokens.

Synopsis

Prototype
AjBool ajStrTokenNextFindC (
      AjPStrTok* Ptoken,
      const char* txtdelim,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyToken parser. Updated with the delimiter string in delim.
const char*txtdelimInputDelimiter string.
AjPStr*PstrOutputToken found
AjBool RETURNajTrue if another token was found.

Input
txtdelim:(Input)Delimiter string.
Output
Pstr:(Output)Token found
Input & Output
Ptoken:(Modify)Token parser. Updated with the delimiter string in delim.
Returns
AjBool:ajTrue if another token was found.

Description

Parses tokens from a string using a string token parser. Treats the whole delimiter as a single string between tokens.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNextParse

Parses tokens from a string using a string token parser. Uses any character defined in the string token parsing object delimiter character set as a delimiter.

The test uses the C function 'strcspn'.

Synopsis

Prototype
AjBool ajStrTokenNextParse (
      AjPStrTok* Ptoken,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyString token parsing object.
AjPStr*PstrOutputNext token returned, may be empty if the delimiter has changed.
AjBool RETURNTrue if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Output
Pstr:(Output)Next token returned, may be empty if the delimiter has changed.
Input & Output
Ptoken:(Modify)String token parsing object.
Returns
AjBool:True if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Description

Parses tokens from a string using a string token parser. Uses any character defined in the string token parsing object delimiter character set as a delimiter.

The test uses the C function 'strcspn'.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNextParseC

Parses tokens from a string using a string token parser. Uses any character defined in the delimiter character set as a delimiter.

Returns the next token parsed from a string token parsing object

Note: This can return "true" but an empty string in cases where the delimiter has changed since the previous call.

The test uses the C function 'strcspn'.

Synopsis

Prototype
AjBool ajStrTokenNextParseC (
      AjPStrTok* Ptoken,
      const char* txtdelim,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyString token parsing object.
const char*txtdelimInputDelimiter character set.
AjPStr*PstrOutputNext token returned, may be empty if the delimiter has changed.
AjBool RETURNTrue if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Input
txtdelim:(Input)Delimiter character set.
Output
Pstr:(Output)Next token returned, may be empty if the delimiter has changed.
Input & Output
Ptoken:(Modify)String token parsing object.
Returns
AjBool:True if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Description

Parses tokens from a string using a string token parser. Uses any character defined in the delimiter character set as a delimiter.

Returns the next token parsed from a string token parsing object

Note: This can return "true" but an empty string in cases where the delimiter has changed since the previous call.

The test uses the C function 'strcspn'.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNextParseS

Parses tokens from a string using a string token parser. Uses any character defined in the delimiter character set as a delimiter.

Note: This can return "true" but an empty string in cases where the delimiter has changed since the previous call.

The test uses the C function 'strcspn'.

Synopsis

Prototype
AjBool ajStrTokenNextParseS (
      AjPStrTok* Ptoken,
      const AjPStr strdelim,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyString token parsing object.
const AjPStrstrdelimInputDelimiter character set.
AjPStr*PstrOutputNext token returned, may be empty if the delimiter has changed.
AjBool RETURNTrue if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Input
strdelim:(Input)Delimiter character set.
Output
Pstr:(Output)Next token returned, may be empty if the delimiter has changed.
Input & Output
Ptoken:(Modify)String token parsing object.
Returns
AjBool:True if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Description

Parses tokens from a string using a string token parser. Uses any character defined in the delimiter character set as a delimiter.

Note: This can return "true" but an empty string in cases where the delimiter has changed since the previous call.

The test uses the C function 'strcspn'.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNextParseDelimiters

Parses tokens from a string using a string token parser. Uses any character defined in the string token parsing object delimiter character set as a delimiter.

The test uses the C function 'strcspn'.

Synopsis

Prototype
AjBool ajStrTokenNextParseDelimiters (
      AjPStrTok* Ptoken,
      AjPStr* Pstr,
      AjPStr* Pdelim
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyString token parsing object.
AjPStr*PstrOutputNext token returned, may be empty if the delimiter has changed.
AjPStr*PdelimOutputDelimiter(s) following the token.
AjBool RETURNTrue if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Output
Pstr:(Output)Next token returned, may be empty if the delimiter has changed.
Pdelim:(Output)Delimiter(s) following the token.
Input & Output
Ptoken:(Modify)String token parsing object.
Returns
AjBool:True if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Description

Parses tokens from a string using a string token parser. Uses any character defined in the string token parsing object delimiter character set as a delimiter.

The test uses the C function 'strcspn'.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenNextParseNoskip

Parses tokens from a string using a string token parser. Uses any character defined in the string token parsing object's delimiter character set as a delimiter.

The test uses the C function 'strcspn'.

Synopsis

Prototype
AjBool ajStrTokenNextParseNoskip (
      AjPStrTok* Ptoken,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyString token parsing object.
AjPStr*PstrOutputNext token returned, may be empty if the delimiter has changed or if next character was also a delimiter
AjBool RETURNTrue if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Output
Pstr:(Output)Next token returned, may be empty if the delimiter has changed or if next character was also a delimiter
Input & Output
Ptoken:(Modify)String token parsing object.
Returns
AjBool:True if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Description

Parses tokens from a string using a string token parser. Uses any character defined in the string token parsing object's delimiter character set as a delimiter.

The test uses the C function 'strcspn'.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajStrTokenRestParse

Returns the remainder of a string that has been partially parsed using a string token parser.

Synopsis

Prototype
AjBool ajStrTokenRestParse (
      AjPStrTok* Ptoken,
      AjPStr* Pstr
);

TypeNameRead/WriteDescription
AjPStrTok*PtokenModifyString token parsing object.
AjPStr*PstrOutputNext token returned.
AjBool RETURNTrue if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Output
Pstr:(Output)Next token returned.
Input & Output
Ptoken:(Modify)String token parsing object.
Returns
AjBool:True if successfully parsed. False (and string set to empty) if there is nothing more to parse.

Description

Returns the remainder of a string that has been partially parsed using a string token parser.

See Also

See other functions in this section

Availability

In release 6.4.0