The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
context_free_grammar_generator Class Reference

#include <context_free_grammar_generator.hpp>

Inheritance diagram for context_free_grammar_generator:
Inheritance graph

Classes

struct  nonterminal
 

Public Member Functions

 context_free_grammar_generator (const std::string &source)
 Initialisation. More...
 
 context_free_grammar_generator (const std::map< std::string, std::vector< std::string >> &source)
 Initialisation. More...
 
std::string generate () const override
 Generates a possible word in the grammar set before. More...
 
 ~context_free_grammar_generator ()
 
bool is_valid () const override
 Checks if the object is initialized. More...
 
- Public Member Functions inherited from name_generator
virtual ~name_generator ()
 

Private Member Functions

std::string print_nonterminal (const std::string &name, uint32_t *seed, short int seed_pos) const
 

Private Attributes

std::map< std::string,
nonterminal
nonterminals_
 
bool initialized_
 

Static Private Attributes

static const short unsigned int seed_size = 20
 

Detailed Description

Definition at line 26 of file context_free_grammar_generator.hpp.

Constructor & Destructor Documentation

context_free_grammar_generator::context_free_grammar_generator ( const std::string source)

Initialisation.

Parameters
sourcethe definition of the context-free grammar to use

Definition at line 33 of file context_free_grammar_generator.cpp.

References initialized_, nonterminals_, context_free_grammar_generator::nonterminal::possibilities_, utils::strip(), and lg::wml_error().

context_free_grammar_generator::context_free_grammar_generator ( const std::map< std::string, std::vector< std::string >> &  source)

Initialisation.

Parameters
sourceA map of nonterminals to lists of possibilities

Definition at line 94 of file context_free_grammar_generator.cpp.

References initialized_, nonterminals_, utils::strip(), and lg::wml_error().

context_free_grammar_generator::~context_free_grammar_generator ( )

Definition at line 29 of file context_free_grammar_generator.cpp.

Member Function Documentation

std::string context_free_grammar_generator::generate ( ) const
overridevirtual

Generates a possible word in the grammar set before.

Returns
the word

Implements name_generator.

Definition at line 154 of file context_free_grammar_generator.cpp.

References random_new::generator, i, random_new::rng::next_random(), print_nonterminal(), and seed_size.

bool context_free_grammar_generator::is_valid ( ) const
inlineoverridevirtual

Checks if the object is initialized.

Returns
if it is initialized

Reimplemented from name_generator.

Definition at line 62 of file context_free_grammar_generator.hpp.

References initialized_.

std::string context_free_grammar_generator::print_nonterminal ( const std::string name,
uint32_t seed,
short int  seed_pos 
) const
private

Member Data Documentation

bool context_free_grammar_generator::initialized_
private

Definition at line 37 of file context_free_grammar_generator.hpp.

Referenced by context_free_grammar_generator(), and is_valid().

std::map<std::string, nonterminal> context_free_grammar_generator::nonterminals_
private
const short unsigned int context_free_grammar_generator::seed_size = 20
staticprivate

Definition at line 39 of file context_free_grammar_generator.hpp.

Referenced by generate(), and print_nonterminal().


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