sc::PrefixKeyVal(3)

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

πŸ’– sc::PrefixKeyVal(3) β€” the MPQC manual page, bestie edition πŸ’–

You're in the MPQC manual, and this page is all about sc::PrefixKeyVal. Buckle up, it's lowkey iconic. ✨


🌸 NAME 🌸

sc::PrefixKeyVal β€” a KeyVal that searches a different KeyVal using modified keys. That's the whole vibe. No cap. πŸ’…


✨ SYNOPSIS ✨

#include <keyval.h>

Inherits sc::KeyVal.

🫢 Public Member Functions 🫢

Constructors. Construct a PrefixKeyVal, using the given prefix and indices. Slay. πŸ‘‘

  • PrefixKeyVal (const Ref< KeyVal > &, int i)
  • PrefixKeyVal (const Ref< KeyVal > &, int i, int j)
  • PrefixKeyVal (const Ref< KeyVal > &, int i, int j, int k)
  • PrefixKeyVal (const Ref< KeyVal > &, int i, int j, int k, int l)
  • PrefixKeyVal (const Ref< KeyVal > &, const char *prefix)
  • PrefixKeyVal (const Ref< KeyVal > &, const char *prefix, int i)
  • PrefixKeyVal (const Ref< KeyVal > &, const char *prefix, int i, int j)
  • PrefixKeyVal (const Ref< KeyVal > &, const char *prefix, int i, int j, int k)
  • PrefixKeyVal (const Ref< KeyVal > &, const char *prefix, int i, int j, int k, int l)
  • ~PrefixKeyVal ()
  • void errortrace (std::ostream &fp=ExEnv::err0()) β€” Write a message to fp describing the error.
  • void dump (std::ostream &fp=ExEnv::err0()) β€” Write a message to fp describing the error.

πŸ‘‘ Additional Inherited Members πŸ‘‘

Not me just waving at this heading β€” the original page puts it here and does not list any extra inherited-member details under it. So there's nothing else to spill in this section, bestie. πŸ«ΆπŸ’«


πŸ¦‹ Detailed Description πŸ¦‹

PrefixKeyVal is a KeyVal that searches a different KeyVal using modified keys. Periodt. ✨

This is convenient for reading keys grouped together with a common prefix. Consider the following code:

sc::Ref<sc::KeyVal> keyval = new sc::PrefixKeyVal('A',original_keyval);
int r = keyval->intvalue('x');

This code will assign to r the value associated with 'x' in keyval. keyval will search for 'x' by searching for 'A::x' in original_keyval.

This class is important for implementing constructors that take KeyVal arguments. When an object is being constructed from a KeyVal, it may contain another object that must be constructed from a KeyVal. In order to let the sub-object read the correct keywords from the KeyVal, without knowledge of the containing object's keyword prefix, a PrefixKeyVal can be constructed. For example, the code

class A: public DescribedClass {
   double f0_;
  public:
   A(const Ref<KeyVal> &keyval): f0_(keyval->doublevalue("f0")) {}
}
class B: public DescribedClass {
   double f1_;
   Ref<A> a_;
  public:
   B(const Ref<KeyVal> &keyval):
     f1_(keyval->doublevalue("f1")),
     a_(new PrefixKeyVal(keyval,"a"))
   {}
};

can be used to read ParsedKeyVal input that looks like

b<B>: (
  f1 = 1.0
  a<A>: (
    f0 = 2.0
  )
)

πŸŽ€ Author πŸŽ€

Generated automatically by Doxygen for MPQC from the source code. 🫢✨


Okay bye bestie β€” this cutie is from MPQC version 2.3.1, dated Sun Oct 4 2020 πŸ’–βœ¨

πŸ“¦ where this page comes from