OpenTREP Logo  0.6.0
C++ Open Travel Request Parsing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OPENTREP::StringPartition Struct Reference

#include <opentrep/bom/StringPartition.hpp>

+ Inheritance diagram for OPENTREP::StringPartition:

Public Types

typedef std::list< StringSetStringPartition_T

Public Member Functions

void push_back (const StringSet &iStringSet)
size_t size () const
bool empty () const
void clear ()
const std::string & getInitialString () const
StringSet calculateUniqueCombinations () const
void toStream (std::ostream &ioOut) const
void fromStream (std::istream &ioIn)
std::string describeKey () const
std::string describe () const
 StringPartition (const std::string &iStringToBePartitioned)
 ~StringPartition ()

Public Attributes

std::string _initialString
StringPartition_T _partition

Detailed Description

Class holding a string partition.

A string partition contains all the ways to combine, serially, all the words of a given string.

For instance, "rio de janeiro" will give:

  • {
    • {"rio", "de", "janeiro"}
    • {"rio", "de janeiro"}
    • {"rio de", "janeiro"}
    • {"rio de janeiro"}
  • }

Definition at line 35 of file StringPartition.hpp.

Member Typedef Documentation

Type gathering all the partitions of a string.

Definition at line 40 of file StringPartition.hpp.

Constructor & Destructor Documentation

OPENTREP::StringPartition::StringPartition ( const std::string &  iStringToBePartitioned)


conststd::string& The string for which the partitions are sought

Definition at line 17 of file StringPartition.cpp.

OPENTREP::StringPartition::~StringPartition ( )

Default destructor.

Definition at line 23 of file StringPartition.cpp.

Member Function Documentation

void OPENTREP::StringPartition::push_back ( const StringSet iStringSet)

Add an item (StringSet) into the list.

When the given string set is empty (zero-length), it is (obviously) not added to the list

Definition at line 27 of file StringPartition.cpp.

References _partition, and OPENTREP::StringSet::empty().

size_t OPENTREP::StringPartition::size ( ) const

Return the size of the list.

Definition at line 34 of file StringPartition.cpp.

References _partition.

Referenced by BOOST_AUTO_TEST_CASE().

bool OPENTREP::StringPartition::empty ( ) const

Return whether or not the list is empty.

Definition at line 39 of file StringPartition.cpp.

References _partition.

Referenced by OPENTREP::QuerySlices::push_back().

void OPENTREP::StringPartition::clear ( )

Empty the list.

Definition at line 44 of file StringPartition.cpp.

References _partition.

const std::string& OPENTREP::StringPartition::getInitialString ( ) const

Get the initial string, that is, the string having been given to be partitioned.

Definition at line 70 of file StringPartition.hpp.

References _initialString.

StringSet OPENTREP::StringPartition::calculateUniqueCombinations ( ) const

Return the list of all the unique word combinations, which can be made from the partitions.

For instance, with "rio de janeiro", the list of unique strings would be:

  • "rio"
  • "de"
  • "janeiro"
  • "rio de"
  • "de janeiro"
  • "rio de janeiro"
StringSet The list of unique strings.

Definition at line 171 of file StringPartition.cpp.

References _partition, OPENTREP::StringSet::_set, and OPENTREP::StringSet::push_back().

void OPENTREP::StringPartition::toStream ( std::ostream &  ioOut) const

Dump the structure into an output stream.

ostream&the output stream.

Definition at line 85 of file StringPartition.cpp.

References describe().

void OPENTREP::StringPartition::fromStream ( std::istream &  ioIn)

Read a structure from an input stream.

istream&the input stream.

Reimplemented from OPENTREP::StructAbstract.

Definition at line 90 of file StringPartition.cpp.

std::string OPENTREP::StringPartition::describeKey ( ) const

Get a string describing the whole key (differentiating two objects at any level).

Definition at line 49 of file StringPartition.cpp.

Referenced by describe().

std::string OPENTREP::StringPartition::describe ( ) const

Get the serialised version of the structure.

Implements OPENTREP::StructAbstract.

Definition at line 56 of file StringPartition.cpp.

References _partition, and describeKey().

Referenced by toStream().

Member Data Documentation

std::string OPENTREP::StringPartition::_initialString

String to be partitioned.

Definition at line 153 of file StringPartition.hpp.

Referenced by getInitialString().

StringPartition_T OPENTREP::StringPartition::_partition

Partition, i.e., a list containing sub-lists of strings

Definition at line 158 of file StringPartition.hpp.

Referenced by calculateUniqueCombinations(), clear(), describe(), empty(), push_back(), OPENTREP::searchString(), and size().

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