Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
AbstractRandomString Class Referenceabstract

Shared base for a simple "list of strings, pick a random one" source. More...

#include <abstractrandomstring.h>

Inheritance diagram for AbstractRandomString:
Collaboration diagram for AbstractRandomString:

Public Member Functions

const QVector< QString > getStore () const
 All strings.
int getStoreSize () const
 String count.
const QString getStoreAt (const int ind) const
 String at ind (for QML).
QString randomExample ()
 A random string from the list.
void load ()
 Load the strings from fileName.
void qmlProtect (const QQmlEngine *const engine) const
 Pin to C++ ownership.

Protected Member Functions

virtual void qmlRegister () const =0
 Subclass registers its concrete type with QML.
 AbstractRandomString (const QString fileName)

Protected Attributes

 : void listChanged()
 < Number of strings.
QVector< QString > store
 The loaded strings.
const QString fileName
 Asset path (set by the subclass).

Detailed Description

Shared base for a simple "list of strings, pick a random one" source.

The base for NamesPlayer and NamesPokemon: a store of strings loaded from a fileName, with a randomExample() helper. Subclasses just supply the file (via the protected ctor), an inst(), and qmlRegister().

Note
Unusually for this layer, the store isn't strictly read-only – hence the listChanged signal (see the inline note).
See also
NamesPlayer, NamesPokemon, Names (the aggregate).

Definition at line 35 of file abstractrandomstring.h.

Constructor & Destructor Documentation

◆ AbstractRandomString()

AbstractRandomString::AbstractRandomString ( const QString fileName)
protected
Parameters
fileNamethe JSON/text asset the subclass loads from.

Definition at line 54 of file abstractrandomstring.cpp.

References fileName, and load().

Referenced by ExamplesPlayer::ExamplesPlayer(), ExamplesPokemon::ExamplesPokemon(), ExamplesRival::ExamplesRival(), NamesPlayer::NamesPlayer(), NamesPokemon::NamesPokemon(), and qmlRegister().

Member Function Documentation

◆ getStore()

const QVector< QString > AbstractRandomString::getStore ( ) const

All strings.

Definition at line 60 of file abstractrandomstring.cpp.

References store.

◆ getStoreAt()

const QString AbstractRandomString::getStoreAt ( const int ind) const

String at ind (for QML).

Definition at line 70 of file abstractrandomstring.cpp.

References store.

◆ getStoreSize()

int AbstractRandomString::getStoreSize ( ) const

String count.

Definition at line 65 of file abstractrandomstring.cpp.

References store.

◆ load()

void AbstractRandomString::load ( )

Load the strings from fileName.

Definition at line 32 of file abstractrandomstring.cpp.

References fileName, GameData::inst(), GameData::json(), and store.

Referenced by AbstractRandomString(), and randomExample().

◆ qmlProtect()

void AbstractRandomString::qmlProtect ( const QQmlEngine *const engine) const

Pin to C++ ownership.

Definition at line 49 of file abstractrandomstring.cpp.

References Utility::qmlProtectUtil().

Referenced by Examples::qmlProtect(), and Names::qmlProtect().

◆ qmlRegister()

virtual void AbstractRandomString::qmlRegister ( ) const
protectedpure virtual

Subclass registers its concrete type with QML.

Implemented in ExamplesPlayer, ExamplesPokemon, ExamplesRival, NamesPlayer, and NamesPokemon.

References AbstractRandomString(), and fileName.

◆ randomExample()

QString AbstractRandomString::randomExample ( )

Member Data Documentation

◆ __pad0__

AbstractRandomString::__pad0__
protected

< Number of strings.

Emitted when the string list changes (rare; see note).

Definition at line 35 of file abstractrandomstring.h.

◆ fileName

const QString AbstractRandomString::fileName
protected

Asset path (set by the subclass).

Definition at line 64 of file abstractrandomstring.h.

Referenced by AbstractRandomString(), load(), and qmlRegister().

◆ store

QVector<QString> AbstractRandomString::store
protected

The loaded strings.

Definition at line 63 of file abstractrandomstring.h.

Referenced by getStore(), getStoreAt(), getStoreSize(), load(), and randomExample().


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