VValue

From Armagetron
Revision as of 15:27, 9 August 2006 by Luke-Jr (talk | contribs) (some done)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Intro

vValue holds stuff that gives a value. It should be used for any and all configuration things. Especially when DCT is usable. wrtlprnft invented it as gHudValue. ph added some collection stuff. Luke modularized it and made an expression parser. Nobody really knows how it all works.

How To Use It

Basic Type

You'll want either vValue::Expr::Core::Base* or vValue::Type::BasePtr depending on what your use is, what day of the week you're born on, etc...

Construction

you make the vValue either C++ style:

e = new classname(arguments);

... by parsing a string:

e = vValue::Parser::parse("3 + 2 / 8");

... or by asking the vValue registry to do it for you:

std::vector<tString> flags;
arglist args;
flags.push_back("func");
args.push_back(vValue::Expr::Core::Int(7));
e = vValue::Registry::theRegistry.create(flags, "classname", args);

Getting the Value

= GetValue

to get the value, you use GetValue:

e->GetValue()

Get<>

GetValue returns a Variant, which could be a string, float, integer, you name it! Since you usually have a particular type in mind that you need, it's better to use Get<>:

e->Get<float>()

vValue Classes

values/vCore

This defines the core stuff needed for vValue.

vValue::Expr::Core

Core expression classes.

Base

This is just your basic expression. It doesn't do much useful. Its value is null.

Number<>

This template is used to define both Int and Float.

Int

Int holds a literal integer value.

Float

Float holds a literal floating point number value.

String

String holds a literal tString value.

UnaryOp

A base class for unary operators, such as Expr::Logic::Not

BinaryOp

A base class for binary operators, such as Expr::Math::Add

vValue::Type

You can omit the '::Type' if you want. These are types defined for vValue.

Set

TODO: someone who knows, describe it!

BasePtr

It's a shared pointer to an expression object. It automatically deletes when nobody wants it anymore...

Variant

This could be any literal value. Right now, this means either int, float, or tString.

arglist

This is just a deque of BasePtr arguments to pass to the registry for construction of a new expression.

vValue::Creator<>

This template is more or less an automatic factory. It turns constructors into static functions so you can pass a pointer to it.

values/vParser

vValue::Parser

This is the expression parser. It takes a tString and turns it into a tree of vValue expressions.

values/vRegistry

The registry allows expressions to be registered as functions to be called from strings the Parser takes.

vValue::Registry

Registration

This class is used to register a function:

Registration register_sin("func\nmath", "sin", 1, (Registration::fptr)
                          ( ctor::a1* )& Creator<Trig::Sin>::create<BasePtr> );
Registry

This is the class for the registry itself, instancised as theRegistry.

theRegistry

This is the registry. It is used to dynamically create expression classes that are registered with it.

ctor

These are static constructor function definitions, for a number of arguments. ctor::a0 is a ctor that has no arguments.

values/vCollection

TODO: I have no idea how this is supposed to work-- ph?

vValue::MiscWTF

FooPtrOps

TODO

myCol

TODO

vValue::Expr::Collection

BaseExt
ColNode
ColUnary
ColPickOne
ColBinary
ColUnion
ColItersection
ColDifference

values/veComparison

vValue::Expr::Comparison

GreaterThan

> operator

GreaterOrEquals

>= operator

Equals

== operator

LessOrEquals

<= operator

         LessThan 
         Compare 
                     *** tools/values/veLogic *** 
      Logic 
         Condition 
         Not 
                     *** tools/values/veMath *** 
      Math 
         Add 
         Subtract 
         Multiply 
         Divide 
         Trig 
            Sin 
         Random 
                     *** tools/values/vebCFunction *** 
      Bindings 
         CFunction 
            CfZeroary 
            CfUnary 
            CfBinary 
                     *** tools/values/vebLegacy *** 
         Legacy 
            Callback?? 
            ConfItem?? 
                     *** tools/values/vebMathExpr *** 
         MathExpr