Sierra Toolkit  Version of the Day
sierra::object_phrase Class Reference

Class object_phrase makes a pretty string for those annoying plural or singular noun/verb phrases. More...

#include <StringUtil.hpp>

Public Member Functions

 object_phrase (int n, const char *noun, const char *singlar="is", const char *plural="are")
 
std::ostream & print (std::ostream &os) const
 Member function print writes the object phrase to the output stream. More...
 
 operator std::string () const
 Member function operator std::string returns a string of the object phrase. More...
 

Detailed Description

Class object_phrase makes a pretty string for those annoying plural or singular noun/verb phrases.

The output is plural no nouns, when n is zero,
singular 1 noun, when n is 1, or
plural n nouns, when n is greater than 1.

Definition at line 400 of file StringUtil.hpp.

Constructor & Destructor Documentation

◆ object_phrase()

sierra::object_phrase::object_phrase ( int  n,
const char *  noun,
const char *  singlar = "is",
const char *  plural = "are" 
)
inline

Creates a new object_phrase instance.

Parameters
nan int value of the quantity of objects
nouna char const pointer to the name of the object.
singlara char singular form of the verb acting on the object.
plurala char plural form of the verb acting on the object.

Definition at line 415 of file StringUtil.hpp.

Member Function Documentation

◆ print()

std::ostream & sierra::object_phrase::print ( std::ostream &  os) const

Member function print writes the object phrase to the output stream.

Parameters
osa std::ostream reference to the output stream to write to.
Returns
a std::ostream reference to the output stream.

Definition at line 187 of file StringUtil.cpp.

◆ operator std::string()

sierra::object_phrase::operator std::string ( ) const

Member function operator std::string returns a string of the object phrase.

Returns
a std::string value of the object string.

Definition at line 201 of file StringUtil.cpp.


The documentation for this class was generated from the following files: