sc::KeyVal(3)

πŸ“¦
version 2.3.1 Β· 5 versions
, in ubuntu jammy

✨ 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, with def as the default. πŸ’…
  • int booleanvalue (const char *key=0, const KeyValValue &def=KeyValValueboolean()) β€” returns the boolean value of key, where 0 = false and 1 = true. 🫢
  • double doublevalue (const char *key=0, const KeyValValue &def=KeyValValuedouble()) β€” returns the double value of key. πŸ”₯
  • float floatvalue (const char *key=0, const KeyValValue &def=KeyValValuefloat()) β€” returns the float value of key. 🌸
  • char charvalue (const char *key=0, const KeyValValue &def=KeyValValuechar()) β€” returns the char value of key. πŸŽ€
  • int intvalue (const char *key=0, const KeyValValue &def=KeyValValueint()) β€” returns the int value of key. ⭐
  • size_t sizevalue (const char *key=0, const KeyValValue &def=KeyValValuesize()) β€” returns the size_t value of key. 🌈
  • 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 type DescribedClass. πŸ‘‘

πŸ¦‹ 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 of err. πŸŽ€
  • const char * errormsg () β€” returns a textual representation of the current error. 🌸
  • virtual void errortrace (std::ostream &fp=ExEnv::err0()) β€” writes a message to fp describing the error. ✨
  • virtual void dump (std::ostream &fp=ExEnv::err0()) β€” writes a message to fp describing the error. 🫢
  • virtual void print_unseen (std::ostream &fp=ExEnv::out0()) β€” prints keywords that were never looked at, if possible. πŸ¦‹
  • virtual int have_unseen () β€” returns 1 if there were unseen keywords, 0 if there are none, or -1 when 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 by exists. πŸ”₯
  • virtual int key_count (const char *=0) β€” ultimately called by count. 🌈
  • virtual Ref< KeyValValue > key_value (const char *, const KeyValValue &def)=0 β€” ultimately called by value. πŸŽ€
  • virtual int key_booleanvalue (const char *, const KeyValValue &def) β€” ultimately called by booleanvalue. 🫢
  • virtual double key_doublevalue (const char *key, const KeyValValue &def) β€” ultimately called by doublevalue. ✨
  • virtual float key_floatvalue (const char *key, const KeyValValue &def) β€” ultimately called by floatvalue. 🌸
  • virtual char key_charvalue (const char *key, const KeyValValue &def) β€” ultimately called by charvalue. πŸ¦‹
  • virtual int key_intvalue (const char *key, const KeyValValue &def) β€” ultimately called by intvalue. ⭐
  • virtual size_t key_sizevalue (const char *key, const KeyValValue &def) β€” ultimately called by sizevalue. πŸ’œ
  • virtual char * key_pcharvalue (const char *key, const KeyValValue &def) β€” ultimately called by pcharvalue. πŸ’€
  • virtual std::string key_stringvalue (const char *key, const KeyValValue &def) β€” ultimately called by stringvalue. πŸ“
  • virtual Ref< DescribedClass > key_describedclassvalue (const char *key, const KeyValValue &def) β€” ultimately called by describedclassvalue. πŸ‘‘

πŸ’œ Protected Attributes πŸ’œ

  • int verbose_ β€” this is the protected attribute, bestie. 🫢

πŸ‘‘ Friends πŸ‘‘

  • class AggregateKeyVal
  • class 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