sc::KeyVal(3)
β¨ NAME β¨
okay bestie, welcome to sc::KeyVal(3) from MPQC π the whole vibe is this: the KeyVal class is literally designed to make it easier for a user to specify keyword/value associations to a C++ program. no cap, that's the mission. π«Ά
πΈ SYNOPSIS πΈ
#include <keyval.h>
sc::KeyVal inherits sc::RefCount.
It's inherited by sc::AggregateKeyVal, sc::AssignedKeyVal, sc::PrefixKeyVal, and sc::StringKeyVal. β¨
π Public Types π
Here's the type tea, bestie:
enum { MaxKeywordLength = 256 }
enum KeyValError { OK, HasNoValue, WrongType, UnknownKeyword,
OperationFailed }
π Public Member Functions π
int exists (const char *)β this one takes a keyword as its only argument. it's your little existence check, bestie. πint count (const char *=0)β if the value of a keyword is an array, this returns its length. πRef< KeyValValue > value (const char *=0, const KeyValValue &def=KeyValValue())β returns the value associated with the keyword, withdefas the default. πint booleanvalue (const char *key=0, const KeyValValue &def=KeyValValueboolean())β returns the boolean value ofkey, where0 = falseand1 = true. π«Άdouble doublevalue (const char *key=0, const KeyValValue &def=KeyValValuedouble())β returns thedoublevalue ofkey. π₯float floatvalue (const char *key=0, const KeyValValue &def=KeyValValuefloat())β returns thefloatvalue ofkey. πΈchar charvalue (const char *key=0, const KeyValValue &def=KeyValValuechar())β returns thecharvalue ofkey. πint intvalue (const char *key=0, const KeyValValue &def=KeyValValueint())β returns theintvalue ofkey. βsize_t sizevalue (const char *key=0, const KeyValValue &def=KeyValValuesize())β returns thesize_tvalue ofkey. πchar * pcharvalue (const char *key=0, const KeyValValue &def=KeyValValuepchar())β returns a copy of the string representation of the key's value. yes, a copy, bestie. πstd::string stringvalue (const char *key=0, const KeyValValue &def=KeyValValuestring())β returns a string representation of the key's value. π¦Ref< DescribedClass > describedclassvalue (const char *key=0, const KeyValValue &def=KeyValValueRefDescribedClass())β returns a reference to an object of typeDescribedClass. π
π¦ Reading Vectors. π¦
These members correspond to the above members, but take an additional integer argument, i, which is a vector index. π
This is equivalent to getting a value for a keyword named key:i. The routines that do not take key arguments get the value for the keyword named i. β¨
int exists (const char *key, int i)
int count (const char *key, int i)
int booleanvalue (const char *key, int i, const KeyValValue &def=KeyValValueboolean())
double doublevalue (const char *key, int i, const KeyValValue &def=KeyValValuedouble())
float floatvalue (const char *key, int i, const KeyValValue &def=KeyValValuefloat())
char charvalue (const char *key, int i, const KeyValValue &def=KeyValValuechar())
int intvalue (const char *key, int i, const KeyValValue &def=KeyValValueint())
size_t sizevalue (const char *key, int i, const KeyValValue &def=KeyValValuesize())
char * pcharvalue (const char *key, int i, const KeyValValue &def=KeyValValuepchar())
std::string stringvalue (const char *key, int i, const KeyValValue &def=KeyValValuestring())
Ref< DescribedClass > describedclassvalue (const char *key, int, const KeyValValue &def=KeyValValueRefDescribedClass())
int exists (int i)
int count (int i)
int booleanvalue (int i, const KeyValValue &def=KeyValValueboolean())
double doublevalue (int i, const KeyValValue &def=KeyValValuedouble())
float floatvalue (int i, const KeyValValue &def=KeyValValuefloat())
char charvalue (int i, const KeyValValue &def=KeyValValuechar())
int intvalue (int i, const KeyValValue &def=KeyValValueint())
size_t sizevalue (int i, const KeyValValue &def=KeyValValuesize())
char * pcharvalue (int i, const KeyValValue &def=KeyValValuepchar())
std::string stringvalue (int i, const KeyValValue &def=KeyValValuestring())
Ref< DescribedClass > describedclassvalue (int i, const KeyValValue &def=KeyValValueRefDescribedClass())
π Reading 2D Arrays. π
These members correspond to the above members, but take additional integer arguments, i and j, which is an array index. π
This is equivalent to getting a value for a keyword named key:i:j. The routines that do not take key arguments get the value for the keyword named i:j. β
int exists (const char *, int, int)
int count (const char *, int, int)
int booleanvalue (const char *, int, int, const KeyValValue &def=KeyValValueboolean())
double doublevalue (const char *key, int, int, const KeyValValue &def=KeyValValuedouble())
float floatvalue (const char *key, int, int, const KeyValValue &def=KeyValValuefloat())
char charvalue (const char *key, int, int, const KeyValValue &def=KeyValValuechar())
int intvalue (const char *key, int, int, const KeyValValue &def=KeyValValueint())
size_t sizevalue (const char *key, int, int, const KeyValValue &def=KeyValValuesize())
char * pcharvalue (const char *key, int, int, const KeyValValue &def=KeyValValuepchar())
std::string stringvalue (const char *key, int, int, const KeyValValue &def=KeyValValuestring())
Ref< DescribedClass > describedclassvalue (const char *key, int, int, const KeyValValue &def=KeyValValueRefDescribedClass())
int exists (int i, int j)
int count (int i, int j)
int booleanvalue (int i, int j, const KeyValValue &def=KeyValValueboolean())
double doublevalue (int i, int j, const KeyValValue &def=KeyValValuedouble())
float floatvalue (int i, int j, const KeyValValue &def=KeyValValuefloat())
char charvalue (int i, int j, const KeyValValue &def=KeyValValuechar())
int intvalue (int i, int j, const KeyValValue &def=KeyValValueint())
size_t sizevalue (int i, int j, const KeyValValue &def=KeyValValuesize())
char * pcharvalue (int i, int j, const KeyValValue &def=KeyValValuepchar())
std::string stringvalue (int i, int j, const KeyValValue &def=KeyValValuestring())
Ref< DescribedClass > describedclassvalue (int i, int j, const KeyValValue &def=KeyValValueRefDescribedClass())
β Reading 3D Arrays. β
These members correspond to the above members, but can be used to read in arrays with more than two dimensions. π
The nindex argument is the number of indices in the array. It is followed by an int giving the value of each index. π₯
int Va_exists (const char *key, int nindex,...)
int Va_count (const char *key, int nindex,...)
int Va_booleanvalue (const char *key, int nindex,...)
double Va_doublevalue (const char *key, int nindex,...)
float Va_floatvalue (const char *key, int nindex,...)
char Va_charvalue (const char *key, int nindex,...)
int Va_intvalue (const char *key, int nindex,...)
size_t Va_sizevalue (const char *key, int nindex,...)
char * Va_pcharvalue (const char *key, int nindex,...)
std::string Va_stringvalue (const char *key, int nindex,...)
Ref< DescribedClass > Va_describedclassvalue (const char *key, int nindex,...)
and the rest of the public members are these, bestie:
KeyValError error ()β returns the current error condition. πconst char * errormsg (KeyValError err)β returns a textual representation oferr. πconst char * errormsg ()β returns a textual representation of the current error. πΈvirtual void errortrace (std::ostream &fp=ExEnv::err0())β writes a message tofpdescribing the error. β¨virtual void dump (std::ostream &fp=ExEnv::err0())β writes a message tofpdescribing the error. π«Άvirtual void print_unseen (std::ostream &fp=ExEnv::out0())β prints keywords that were never looked at, if possible. π¦virtual int have_unseen ()β returns1if there were unseen keywords,0if there are none, or-1when this keyval doesn't keep track of unseen keywords. πvoid verbose (int v)β controls printing of assignments. πint verbose () constβ returns nonzero if assignments are printed. β
π«Ά Protected Member Functions π«Ά
void seterror (KeyValError err)β sets the current error condition. πvoid seterror (KeyValValue::KeyValValueError err)β sets the current error condition. πvirtual int key_exists (const char *)=0β ultimately called byexists. π₯virtual int key_count (const char *=0)β ultimately called bycount. πvirtual Ref< KeyValValue > key_value (const char *, const KeyValValue &def)=0β ultimately called byvalue. πvirtual int key_booleanvalue (const char *, const KeyValValue &def)β ultimately called bybooleanvalue. π«Άvirtual double key_doublevalue (const char *key, const KeyValValue &def)β ultimately called bydoublevalue. β¨virtual float key_floatvalue (const char *key, const KeyValValue &def)β ultimately called byfloatvalue. πΈvirtual char key_charvalue (const char *key, const KeyValValue &def)β ultimately called bycharvalue. π¦virtual int key_intvalue (const char *key, const KeyValValue &def)β ultimately called byintvalue. βvirtual size_t key_sizevalue (const char *key, const KeyValValue &def)β ultimately called bysizevalue. πvirtual char * key_pcharvalue (const char *key, const KeyValValue &def)β ultimately called bypcharvalue. πvirtual std::string key_stringvalue (const char *key, const KeyValValue &def)β ultimately called bystringvalue. πvirtual Ref< DescribedClass > key_describedclassvalue (const char *key, const KeyValValue &def)β ultimately called bydescribedclassvalue. π
π Protected Attributes π
int verbose_β this is the protected attribute, bestie. π«Ά
π Friends π
class AggregateKeyValclass PrefixKeyVal
π Detailed Description π
okay so picture this: the KeyVal class exists to make the whole "let the user pass keyword/value associations into a C++ program" thing so much easier. That's literally its whole job, and it ate. β¨
The way it works is you get a flexible input style and the programmer gets ease of use β both, at the same time, no cap. Keywords are represented by null terminated character arrays, and they're organized hierarchially, kind of like how a lot of file systems are set up. One character is special, and that's ':' β it's the lil separator between the various hierarchial labels, which we call 'segments', inside the keyword. π
the array situation (iykyk)
KeyVal also provides a convention for specifying arrays, bestie. Each index of the array is given by appending a segment containing the character representation of the index. So like, 'array:3:4' would be the keyword corresponding to the fourth row and fifth column of 'array' β because indexing starts at zero, obviously. π
the class association thing (don't panic)
So to let the KeyVal class have associations that can represent data for classes, the keyword can be associated with a class as well as a value. This permits polymorphic data to be unambiguously represented by keyword/value associations. Most use of KeyVal need not be concerned with this, so like... if that sounded like a lot, you can lowkey just move on. π«Ά
πΈ Member Function Documentation πΈ
β int sc::KeyVal::count (const char * = 0)
If the value of a keyword is an array, then this bad boy returns its length. And if no arguments are given? Then the top level will be checked to see if it is an array and, if so, the number of elements will be counted. slay. β¨
π¦ int sc::KeyVal::exists (const char *)
This one takes as its only argument a keyword. Returns 1 if the keyword has a value and 0 otherwise. That's it, that's the whole vibe check. π
π char* sc::KeyVal::pcharvalue (const char * key = 0, const KeyValValue & def = KeyValValuepchar())
Returns a copy of the string representation of the key's value. Storage for the copy is obtained with new β so yeah, that memory is yours now, bestie, don't forget about it. π
π Author π
Generated automatically by Doxygen for MPQC from the source code. (not a human, just vibes and a parser π )
fr fr, that's the whole page β every option, every signature, every lil default value, all of it, preserved and iconic. π
sign-off time π this gorgeous lil page is Version 2.3.1, dated Sun Oct 4 2020 β go forth and specify your keywords, bestie, you're gonna do amazing πβ¨π¦
π¦ where this page comes from
- ubuntu jammy: libsc-doc 2.3.1-21
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms