Vcsn  2.8
Be Rational
vcsn::string_letters Class Reference

Represent alphabets whose "letters" are strings. More...

#include <string.hh>

Collaboration diagram for vcsn::string_letters:

Public Types

using self_t = string_letters
 
using letter_t = symbol
 Internalize the letters to save trees. More...
 
using word_t = std::vector< letter_t >
 

Public Member Functions

word_t to_word (const letter_t l) const
 
const word_tto_word (const word_t &l) const
 
word_t mul (const letter_t l, const letter_t r) const
 
word_t mul (const word_t &l, const letter_t r) const
 
word_t mul (const letter_t l, const word_t &r) const
 
word_t mul (const word_t &l, const word_t &r) const
 
word_t delimit (const word_t &w) const
 Add the special character first and last. More...
 
word_t undelimit (const word_t &w) const
 Remove first and last characters, that must be "special". More...
 
word_t transpose (const word_t &w) const
 
letter_t transpose (letter_t l) const
 
bool is_letter (const letter_t) const
 
bool is_letter (const word_t &w) const
 
std::ostream & print (const letter_t l, std::ostream &o, const format &fmt={}) const
 
std::ostream & print (const word_t &w, std::ostream &o, const format &fmt={}) const
 

Static Public Member Functions

static symbol sname ()
 
static word_t empty_word ()
 
static bool is_empty_word (const word_t &w)
 
static int compare (const letter_t l, const letter_t r)
 Three-way comparison between two letters. More...
 
static int compare (const word_t &l, const word_t &r)
 Three-way comparison between two words. More...
 
static bool equal (const letter_t l, const letter_t r)
 Whether l == r. More...
 
static bool equal (const word_t &l, const word_t &r)
 Whether l == r. More...
 
static bool less (const letter_t l, const letter_t r)
 Whether l < r. More...
 
static bool less (const word_t &l, const word_t &r)
 Whether l < r. More...
 
static letter_t one_letter ()
 The reserved letter used to forge the "one" label (the unit, the identity). More...
 
static letter_t get_letter (std::istream &i, bool quoted=true)
 Read one letter from i. More...
 
template<typename T = letter_t>
static T special ()
 Special character, used to label transitions from pre() and to post(). More...
 

Static Private Member Functions

static letter_t special_letter ()
 The reserved letter used to forge the labels for initial and final transitions. More...
 

Detailed Description

Represent alphabets whose "letters" are strings.

This is useful for linguistics where sometimes letters are words ("it is beautiful" has three letters: "it" "is" and "beautiful") but also to deal with UTF-8, since graphemes then have various widths.

Definition at line 21 of file string.hh.

Member Typedef Documentation

◆ letter_t

Internalize the letters to save trees.

Definition at line 26 of file string.hh.

◆ self_t

Definition at line 24 of file string.hh.

◆ word_t

using vcsn::string_letters::word_t = std::vector<letter_t>

Definition at line 27 of file string.hh.

Member Function Documentation

◆ compare() [1/2]

static int vcsn::string_letters::compare ( const letter_t  l,
const letter_t  r 
)
inlinestatic

Three-way comparison between two letters.

Definition at line 152 of file string.hh.

◆ compare() [2/2]

static int vcsn::string_letters::compare ( const word_t l,
const word_t r 
)
inlinestatic

Three-way comparison between two words.

Definition at line 158 of file string.hh.

References vcsn::detail::lexicographical_cmp().

Here is the call graph for this function:

◆ delimit()

word_t vcsn::string_letters::delimit ( const word_t w) const
inline

Add the special character first and last.

Definition at line 111 of file string.hh.

References mul(), and special_letter().

Here is the call graph for this function:

◆ empty_word()

static word_t vcsn::string_letters::empty_word ( )
inlinestatic

Definition at line 127 of file string.hh.

◆ equal() [1/2]

static bool vcsn::string_letters::equal ( const letter_t  l,
const letter_t  r 
)
inlinestatic

Whether l == r.

Definition at line 165 of file string.hh.

◆ equal() [2/2]

static bool vcsn::string_letters::equal ( const word_t l,
const word_t r 
)
inlinestatic

Whether l == r.

Definition at line 171 of file string.hh.

◆ get_letter()

static letter_t vcsn::string_letters::get_letter ( std::istream &  i,
bool  quoted = true 
)
inlinestatic

Read one letter from i.

Either a single char, or a "letter" enclosed in single-quotes.

Definition at line 215 of file string.hh.

References vcsn::get_char(), vcsn::res, and sname().

Here is the call graph for this function:

◆ is_empty_word()

static bool vcsn::string_letters::is_empty_word ( const word_t w)
inlinestatic

Definition at line 133 of file string.hh.

Referenced by mul().

◆ is_letter() [1/2]

bool vcsn::string_letters::is_letter ( const letter_t  ) const
inline

Definition at line 189 of file string.hh.

◆ is_letter() [2/2]

bool vcsn::string_letters::is_letter ( const word_t w) const
inline

Definition at line 195 of file string.hh.

◆ less() [1/2]

static bool vcsn::string_letters::less ( const letter_t  l,
const letter_t  r 
)
inlinestatic

Whether l < r.

Definition at line 177 of file string.hh.

◆ less() [2/2]

static bool vcsn::string_letters::less ( const word_t l,
const word_t r 
)
inlinestatic

Whether l < r.

Definition at line 183 of file string.hh.

◆ mul() [1/4]

word_t vcsn::string_letters::mul ( const letter_t  l,
const letter_t  r 
) const
inline

Definition at line 48 of file string.hh.

References one_letter().

Referenced by delimit().

Here is the call graph for this function:

◆ mul() [2/4]

word_t vcsn::string_letters::mul ( const word_t l,
const letter_t  r 
) const
inline

Definition at line 64 of file string.hh.

References one_letter(), and vcsn::res.

Here is the call graph for this function:

◆ mul() [3/4]

word_t vcsn::string_letters::mul ( const letter_t  l,
const word_t r 
) const
inline

Definition at line 79 of file string.hh.

References one_letter(), and vcsn::res.

Here is the call graph for this function:

◆ mul() [4/4]

word_t vcsn::string_letters::mul ( const word_t l,
const word_t r 
) const
inline

Definition at line 94 of file string.hh.

References is_empty_word(), and vcsn::res.

Here is the call graph for this function:

◆ one_letter()

static letter_t vcsn::string_letters::one_letter ( )
inlinestatic

The reserved letter used to forge the "one" label (the unit, the identity).

Definition at line 202 of file string.hh.

Referenced by mul(), and print().

◆ print() [1/2]

std::ostream& vcsn::string_letters::print ( const letter_t  l,
std::ostream &  o,
const format fmt = {} 
) const
inline

Definition at line 247 of file string.hh.

References vcsn::format::latex, one_letter(), vcsn::format::raw, vcsn::format::sname, special_letter(), vcsn::str_escape(), vcsn::format::text, and vcsn::format::utf8.

Referenced by print().

Here is the call graph for this function:

◆ print() [2/2]

std::ostream& vcsn::string_letters::print ( const word_t w,
std::ostream &  o,
const format fmt = {} 
) const
inline

Definition at line 276 of file string.hh.

References print(), and special().

Here is the call graph for this function:

◆ sname()

static symbol vcsn::string_letters::sname ( )
inlinestatic

Definition at line 29 of file string.hh.

References vcsn::res.

Referenced by get_letter().

◆ special()

template<typename T = letter_t>
static T vcsn::string_letters::special ( )
static

Special character, used to label transitions from pre() and to post().

Referenced by print().

◆ special_letter()

static letter_t vcsn::string_letters::special_letter ( )
inlinestaticprivate

The reserved letter used to forge the labels for initial and final transitions.

Use the public special() interface.

Definition at line 209 of file string.hh.

Referenced by delimit(), print(), vcsn::string_letters::special< string_letters::letter_t >(), vcsn::string_letters::special< string_letters::word_t >(), and undelimit().

◆ to_word() [1/2]

word_t vcsn::string_letters::to_word ( const letter_t  l) const
inline

Definition at line 36 of file string.hh.

◆ to_word() [2/2]

const word_t& vcsn::string_letters::to_word ( const word_t l) const
inline

Definition at line 42 of file string.hh.

◆ transpose() [1/2]

word_t vcsn::string_letters::transpose ( const word_t w) const
inline

Definition at line 139 of file string.hh.

◆ transpose() [2/2]

letter_t vcsn::string_letters::transpose ( letter_t  l) const
inline

Definition at line 146 of file string.hh.

◆ undelimit()

word_t vcsn::string_letters::undelimit ( const word_t w) const
inline

Remove first and last characters, that must be "special".

Definition at line 117 of file string.hh.

References special_letter().

Here is the call graph for this function:

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