PIP 5.5.3
Platform-Independent Primitives
Public Member Functions | List of all members
PIConstChars Class Reference

C-String class. More...

#include <piconstchars.h>

Public Member Functions

 PIConstChars ()
 Contructs an null string.
 
 PIConstChars (const char *string)
 Contructs string from C-string "string".
 
 PIConstChars (const char *data, size_t size)
 Contructs string from "size" characters of buffer "data".
 
 PIConstChars (const PIConstChars &o)
 Contructs a copy of string.
 
char operator[] (size_t index) const
 Read-only access to character by index.
 
char at (size_t index) const
 Read-only access to character by index.
 
const char * data () const
 Returns char * string pointer.
 
bool isNull () const
 Returns true if string doesn`t have any data.
 
bool isEmpty () const
 Returns true if string is empty, i.e. length = 0, or null.
 
bool isNotEmpty () const
 Returns true if string is not empty, i.e. length > 0.
 
bool contains (char c) const
 Returns true if string contains character "c".
 
size_t length () const
 Returns characters length of string.
 
size_t size () const
 Returns characters length of string.
 
ssize_t size_s () const
 Returns characters length of string.
 
bool startsWith (const PIConstChars &str) const
 Returns if string starts with "str".
 
bool startsWith (const char c) const
 Returns if string starts with "c".
 
bool endsWith (const PIConstChars &str) const
 Returns if string ends with "str".
 
bool endsWith (const char c) const
 Returns if string ends with "c".
 
PIConstChars mid (const int start, const int len=-1) const
 Returns part of string from character at index "start" and maximum length "len". More...
 
PIConstChars left (const int len) const
 Returns part of string from start and maximum length "len". More...
 
PIConstChars right (const int len) const
 Returns part of string at end and maximum length "len". More...
 
PIConstCharscutLeft (const int len)
 Remove part of string from start and maximum length "len" and return this string. More...
 
PIConstCharscutRight (const int len)
 Remove part of string at end and maximum length "len" and return this string. More...
 
PIConstChars takeLeft (const int len)
 Take a part from the begin of string with maximum length "len" and return it. More...
 
PIConstChars takeRight (const int len)
 Take a part from the end of string with maximum length "len" and return it. More...
 
PIConstCharstrim ()
 Remove spaces at the start and at the end of string and return this string. More...
 
PIConstChars trimmed () const
 Returns copy of this string without spaces at the start and at the end. More...
 
PIString toString () const
 Returns as PIString.
 
PIConstCharsoperator= (const PIConstChars &s)
 Assign operator.
 
PIConstCharsoperator= (PIConstChars &&s)
 Assign move operator.
 
PIConstCharsoperator= (const char *s)
 Assign operator.
 
bool operator== (const PIConstChars &s) const
 Compare operator.
 
bool operator!= (const PIConstChars &s) const
 Compare operator.
 
bool operator< (const PIConstChars &s) const
 Compare operator.
 
bool operator> (const PIConstChars &s) const
 Compare operator.
 
uint hash () const
 Returns hash of string content.
 

Detailed Description

C-String class.

Synopsis

This is wrapper around const char * string. PIConstChars doesn`t copy string, just save pointer and size.

Provides API similar to string, with information and compare methods.

Used to more handly works with ordinary C-strings.

Member Function Documentation

◆ mid()

PIConstChars PIConstChars::mid ( const int  start,
const int  len = -1 
) const

Returns part of string from character at index "start" and maximum length "len".

See also
left(), right()

◆ left()

PIConstChars PIConstChars::left ( const int  len) const

Returns part of string from start and maximum length "len".

See also
mid(), right()

◆ right()

PIConstChars PIConstChars::right ( const int  len) const

Returns part of string at end and maximum length "len".

See also
mid(), left()

◆ cutLeft()

PIConstChars & PIConstChars::cutLeft ( const int  len)

Remove part of string from start and maximum length "len" and return this string.

See also
cutRight()

◆ cutRight()

PIConstChars & PIConstChars::cutRight ( const int  len)

Remove part of string at end and maximum length "len" and return this string.

See also
cutLeft()

◆ takeLeft()

PIConstChars PIConstChars::takeLeft ( const int  len)

Take a part from the begin of string with maximum length "len" and return it.

See also
takeRight()

◆ takeRight()

PIConstChars PIConstChars::takeRight ( const int  len)

Take a part from the end of string with maximum length "len" and return it.

See also
takeLeft()

◆ trim()

PIConstChars & PIConstChars::trim ( )

Remove spaces at the start and at the end of string and return this string.

See also
trimmed()

◆ trimmed()

PIConstChars PIConstChars::trimmed ( ) const
inline

Returns copy of this string without spaces at the start and at the end.

See also
trim()