tgen
Loading...
Searching...
No Matches

String value. More...

Inheritance diagram for tgen::str::value:

Public Member Functions

 value (const std::string &str)
 Creates a string value from a std::string.
int size () const
 Returns the size of the string value.
char & operator[] (int idx)
 Accesses the character at some position of the value.
valuesort ()
 Sorts the characters in non-decreasing order.
valuereverse ()
 Reverses the value.
valuelowercase ()
 Sets all characters to lowercase.
valueuppercase ()
 Sets all characters to uppercase.
value operator+ (const value &rhs)
 Concatenates two values.
std::string to_std () const
 Converts the value to a std::string.
Public Member Functions inherited from tgen::gen_value_base< value >
bool operator< (const value &rhs) const

Friends

std::ostream & operator<< (std::ostream &out, const value &inst)
 Prints the value to a std::ostream.

Detailed Description

String value.

It can be deterministically operated upon and printed through std::cout.

Definition at line 3179 of file tgen.h.

Constructor & Destructor Documentation

◆ value()

tgen::str::value::value ( const std::string & str)
inline

Creates a string value from a std::string.

Parameters
strThe std::string representing the value.

Examples

// Creates and prints a value from a std::string.
std::string s = "aba";
tgen::str::value inst(aba);
std::cout << inst << std::endl; // Prints "aba".
String value.
Definition tgen.h:3179

Definition at line 3187 of file tgen.h.

Member Function Documentation

◆ lowercase()

value & tgen::str::value::lowercase ( )
inline

Sets all characters to lowercase.

Complexity

O(n).

Examples

// Sets a value to lowercase and prints it.
tgen::str<int>::value inst = "abC";
std::cout << inst.lowercase() << std::endl; // Prints "ABC".
value & lowercase()
Sets all characters to lowercase.
Definition tgen.h:3222

Definition at line 3222 of file tgen.h.

◆ operator+()

value tgen::str::value::operator+ ( const value & rhs)
inline

Concatenates two values.

Parameters
rhsThe right-hand side.
Returns
The concatenation.

Complexity

Linear.

Examples

// Concatenates and prints two values.
tgen::str s = tgen::str(5, 'a', 'z').all_different();
std::cout << s.gen() + s.gen() << std::endl;
String generator.
Definition tgen.h:3076
value gen() const
Generates a random value from the set of valid strings.
Definition tgen.h:3252
str & all_different()
Restricts generator s.t. all characters are different.
Definition tgen.h:3172

Definition at line 3238 of file tgen.h.

◆ operator[]()

char & tgen::str::value::operator[] ( int idx)
inline

Accesses the character at some position of the value.

Parameters
idxIndex to be accessed.
Returns
The character at index idx.

Examples

// Changes and prints a position of a value.
tgen::str::value inst = "aba";
++inst[1];
std::cout << inst[1] << std::endl; // Prints "c".

Definition at line 3195 of file tgen.h.

◆ reverse()

value & tgen::str::value::reverse ( )
inline

Reverses the value.

Complexity

O(n).

Examples

// Reverses and prints a value.
tgen::str::value inst = "bac";
std::cout << inst.reverse() << std::endl; // Prints "cab".
value & reverse()
Reverses the value.
Definition tgen.h:3215

Definition at line 3215 of file tgen.h.

◆ size()

int tgen::str::value::size ( ) const
inline

Returns the size of the string value.

Returns
The number of characters in the value.

Examples

// Prints the size of a value.
tgen::str::value inst = "aba";
std::cout << inst.size() << std::endl; // Prints "3".
int size() const
Returns the size of the string value.
Definition tgen.h:3192

Definition at line 3192 of file tgen.h.

◆ sort()

value & tgen::str::value::sort ( )
inline

Sorts the characters in non-decreasing order.

Complexity

O(n log n).

Examples

// Sorts and prints a value.
tgen::str::value inst = "aba";
std::cout << inst.sort() << std::endl; // Prints "aab".
value & sort()
Sorts the characters in non-decreasing order.
Definition tgen.h:3208

Definition at line 3208 of file tgen.h.

◆ to_std()

std::string tgen::str::value::to_std ( ) const
inline

Converts the value to a std::string.

Returns
A std::string representing the value.

Examples

// Convoluted way to reverse a string.
std::string s = "bac";
// s = "cab".
std::string to_std() const
Converts the value to a std::string.
Definition tgen.h:3246

Definition at line 3246 of file tgen.h.

◆ uppercase()

value & tgen::str::value::uppercase ( )
inline

Sets all characters to uppercase.

Complexity

O(n).

Examples

// Sets a value to uppercase and prints it.
tgen::str<int>::value inst = "abC";
std::cout << inst.uppercase() << std::endl; // Prints "abc".
value & uppercase()
Sets all characters to uppercase.
Definition tgen.h:3230

Definition at line 3230 of file tgen.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const value & inst )
friend

Prints the value to a std::ostream.

The string is printed with no end of line.

Examples

// Prints a value.
std::cout << tgen::str::value("aba") << std::endl; // Prints "aba".

Definition at line 3241 of file tgen.h.


The documentation for this struct was generated from the following files:
  • /home/runner/work/tgen/tgen/single_include/tgen.h
  • str.dox