Ignore:
Timestamp:
02/06/15 00:15:08 (10 years ago)
Author:
Maciej Komosinski
Message:

Unified parsing of ints and floats; hex notation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/paramobj.h

    r286 r326  
    77
    88#include "param.h"
     9#include <frams/util/extvalue.h>
    910
    10 class ParamObject
     11class ParamObject : public DestrBase
    1112{
    12   public:
    13 /** make a ParamEntry* array for use with Param object.
    14     offsets in the array are calculated for the ExtObject array as the target.
    15     valid array can be created with makeObject().
    16     sample code:
    17     @code
    18     ParamInterface *pi=...; // any param interface
    19     ParamEntry *tab=ParamObject::makeParamTab(pi);
    20     void* obj=ParamObject::makeObject(tab);
    21     void* obj2=ParamObject::makeObject(tab);
    22     Param par(tab,obj);
    23     par.set(...), par.get(...), par.load(...), par.save(...);
    24     par.select(obj);
    25     par.select(obj2);
    26     ParamObject::freeObject(obj);
    27     ParamObject::freeObject(obj2);
    28  */
    29 static ParamEntry* makeParamTab(ParamInterface *pi,bool stripgroups=0,bool stripproc=0,int firstprop=0,int maxprops=9999,bool dupentries=false, int flagsexclude=0);
     13        ParamObject(int _numfields, ParamEntry *_tab);
     14public:
     15        int numfields;
     16        Param par;
     17        ExtValue fields[0];
     18        ParamObject() { numfields = 0; }
     19        ~ParamObject();
    3020
    31 /** deallocate paramtab obtained from makeParamTab() */
    32 static void freeParamTab(ParamEntry *pe);
     21        void* operator new(size_t s, int numfields){ return ::operator new(s + sizeof(ExtValue)*numfields); }
     22        void* operator new(size_t s){ return ::operator new(s); }
     23        ParamObject *clone();
     24        static void p_new(void* obj, ExtValue *args, ExtValue *ret);
    3325
    34 static bool paramTabEqual(ParamEntry *pe1,ParamEntry *pe2);
     26        void operator=(const ParamObject& src);
    3527
    36 /** @return the object, suitable for Param.select(...).
    37     @return NULL if 'pi' has no usable properties */
    38 static void* makeObject(ParamEntry *tab);
     28        static int firstFieldOffset();
    3929
    40 /** copy data from src to dst  */
    41 static void copyObject(void* dst,void* src);
     30        /** make a ParamEntry* array for use with Param object.
     31                offsets in the array are calculated for the ExtObject array as the target.
     32                valid array can be created with makeObject().
     33                sample code:
     34                @code
     35                ParamInterface *pi=...; // any param interface
     36                ParamEntry *tab=ParamObject::makeParamTab(pi);
     37                void* obj=ParamObject::makeObject(tab);
     38                void* obj2=ParamObject::makeObject(tab);
     39                Param par(tab,obj);
     40                par.set(...), par.get(...), par.load(...), par.save(...);
     41                par.select(obj);
     42                par.select(obj2);
     43                ParamObject::freeObject(obj);
     44                ParamObject::freeObject(obj2);
     45                */
     46        static ParamEntry* makeParamTab(ParamInterface *pi, bool stripgroups = 0, bool stripproc = 0, int firstprop = 0, int maxprops = 9999, bool dupentries = false, int flagsexclude = 0, bool addnew = false, const char* rename = NULL);
    4247
    43 /** duplicate object */
    44 static void* dupObject(void* obj);
     48        /** deallocate paramtab obtained from makeParamTab() */
     49        static void freeParamTab(ParamEntry *pe);
    4550
    46 /** delete all data in the array and deallocate it  */
    47 static void freeObject(void* obj);
     51        static void setParamTabText(ParamEntry *pe, const char* &ptr, const char* txt);
     52        static bool paramTabAllocatedString(ParamEntry *pe);
     53        static bool paramTabEqual(ParamEntry *pe1, ParamEntry *pe2);
     54
     55        /** @return the object, suitable for Param.select(...).
     56                @return NULL if 'pi' has no usable properties */
     57        static ParamObject* makeObject(ParamEntry *tab);
     58
     59        /** copy data from src to dst (compatibility with older implementation), same as operator=  */
     60        static void copyObject(void* dst, void* src);
     61
     62        /** duplicate object (compatibility with older implementation), same as clone()  */
     63        static void* dupObject(void* obj);
     64
     65        /** delete all data in the array and deallocate it (compatibility with older implementation), same as delete */
     66        static void freeObject(void* obj);
     67};
     68
     69class ParamTabOwner
     70{
     71public:
     72        ParamEntry *pe;
     73        ParamTabOwner(ParamEntry *_pe) :pe(_pe) {}
     74        ~ParamTabOwner() { ParamObject::freeParamTab(pe); }
    4875};
    4976
Note: See TracChangeset for help on using the changeset viewer.