ManaPlus
Public Member Functions | Private Member Functions | Private Attributes
Catch::CompositeGenerator< T > Class Template Reference

#include <catch.hpp>

Public Member Functions

 CompositeGenerator ()
 
 CompositeGenerator (CompositeGenerator &other)
 
CompositeGeneratorsetFileInfo (const char *fileInfo)
 
 ~CompositeGenerator ()
 
 operator T () const
 
void add (const IGenerator< T > *generator)
 
CompositeGeneratorthen (CompositeGenerator &other)
 
CompositeGeneratorthen (T value)
 

Private Member Functions

void move (CompositeGenerator &other)
 

Private Attributes

std::vector< const IGenerator< T > * > m_composed
 
std::string m_fileInfo
 
size_t m_totalSize
 

Detailed Description

template<typename T>
class Catch::CompositeGenerator< T >

Definition at line 2393 of file catch.hpp.

Constructor & Destructor Documentation

◆ CompositeGenerator() [1/2]

template<typename T >
Catch::CompositeGenerator< T >::CompositeGenerator ( )
inline

Definition at line 2395 of file catch.hpp.

2395 : m_totalSize( 0 ) {}

◆ CompositeGenerator() [2/2]

template<typename T >
Catch::CompositeGenerator< T >::CompositeGenerator ( CompositeGenerator< T > &  other)
inline

Definition at line 2398 of file catch.hpp.

2399  : m_fileInfo( other.m_fileInfo ),
2400  m_totalSize( 0 )
2401  {
2402  move( other );
2403  }
std::string m_fileInfo
Definition: catch.hpp:2458
void move(CompositeGenerator &other)
Definition: catch.hpp:2451

References Actions::move().

◆ ~CompositeGenerator()

template<typename T >
Catch::CompositeGenerator< T >::~CompositeGenerator ( )
inline

Definition at line 2410 of file catch.hpp.

2410  {
2411  deleteAll( m_composed );
2412  }
std::vector< const IGenerator< T > * > m_composed
Definition: catch.hpp:2457
void deleteAll(ContainerT &container)
Definition: catch.hpp:353

References Catch::deleteAll().

Member Function Documentation

◆ add()

template<typename T >
void Catch::CompositeGenerator< T >::add ( const IGenerator< T > *  generator)
inline

Definition at line 2432 of file catch.hpp.

2432  {
2433  m_totalSize += generator->size();
2434  m_composed.push_back( generator );
2435  }
Resource *(&) generator(const void *const data)

Referenced by Catch::Generators::between(), and Catch::Generators::values().

◆ move()

template<typename T >
void Catch::CompositeGenerator< T >::move ( CompositeGenerator< T > &  other)
inlineprivate

Definition at line 2451 of file catch.hpp.

2451  {
2452  std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
2453  m_totalSize += other.m_totalSize;
2454  other.m_composed.clear();
2455  }

References Catch::CompositeGenerator< T >::m_composed, and Catch::CompositeGenerator< T >::m_totalSize.

◆ operator T()

template<typename T >
Catch::CompositeGenerator< T >::operator T ( ) const
inline

Definition at line 2414 of file catch.hpp.

2414  {
2415  size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize );
2416 
2417  typename std::vector<const IGenerator<T>*>::const_iterator it = m_composed.begin();
2418  typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
2419  for( size_t index = 0; it != itEnd; ++it )
2420  {
2421  const IGenerator<T>* generator = *it;
2422  if( overallIndex >= index && overallIndex < index + generator->size() )
2423  {
2424  return generator->getValue( overallIndex-index );
2425  }
2426  index += generator->size();
2427  }
2428  CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
2429  return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so
2430  }
#define CATCH_INTERNAL_ERROR(msg)
Definition: catch.hpp:430
IContext & getCurrentContext()
int size()
Definition: emotedb.cpp:306
virtual size_t getGeneratorIndex(std::string const &fileInfo, size_t totalSize)=0

References CATCH_INTERNAL_ERROR, Catch::getCurrentContext(), Catch::IContext::getGeneratorIndex(), and EmoteDB::size().

◆ setFileInfo()

template<typename T >
CompositeGenerator& Catch::CompositeGenerator< T >::setFileInfo ( const char *  fileInfo)
inline

Definition at line 2405 of file catch.hpp.

2405  {
2406  m_fileInfo = fileInfo;
2407  return *this;
2408  }

◆ then() [1/2]

template<typename T >
CompositeGenerator& Catch::CompositeGenerator< T >::then ( CompositeGenerator< T > &  other)
inline

Definition at line 2437 of file catch.hpp.

2437  {
2438  move( other );
2439  return *this;
2440  }

References Actions::move().

◆ then() [2/2]

template<typename T >
CompositeGenerator& Catch::CompositeGenerator< T >::then ( value)
inline

Definition at line 2442 of file catch.hpp.

2442  {
2443  ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
2444  valuesGen->add( value );
2445  add( valuesGen );
2446  return *this;
2447  }
void add(const IGenerator< T > *generator)
Definition: catch.hpp:2432

References Catch::ValuesGenerator< T >::add().

Field Documentation

◆ m_composed

template<typename T >
std::vector<const IGenerator<T>*> Catch::CompositeGenerator< T >::m_composed
private

Definition at line 2457 of file catch.hpp.

Referenced by Catch::CompositeGenerator< T >::move().

◆ m_fileInfo

template<typename T >
std::string Catch::CompositeGenerator< T >::m_fileInfo
private

Definition at line 2458 of file catch.hpp.

◆ m_totalSize

template<typename T >
size_t Catch::CompositeGenerator< T >::m_totalSize
private

Definition at line 2459 of file catch.hpp.

Referenced by Catch::CompositeGenerator< T >::move().


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