source: cpp/frams/param/syntparam.cpp @ 884

Last change on this file since 884 was 720, checked in by Maciej Komosinski, 2 years ago

Param::save2() renamed to saveSingleLine(); unified Param::load() so that it gets a single-line/multi-line format selector

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#include <common/nonstd.h>
6#include "syntparam.h"
7#include "paramobj.h"
8#include <math.h>
9
10SyntParam::SyntParam(ParamEntry *init_pe, SString* autostr, bool handle_defaults_when_saving)
11        :autostring(autostr)
12{
13        Param::setParamTab(init_pe);
14        pe = ParamObject::makeParamTab(this);
15        Param::setParamTab(pe);
16        if (handle_defaults_when_saving)
17        {
18                def_obj = ParamObject::makeObject(pe);
19                Param::select(def_obj);
20                Param::setDefault();
21        }
22        else
23                def_obj = NULL;
24        obj = ParamObject::makeObject(pe);
25        Param::select(obj);
26        Param::setDefault();
27        revert();
28}
29
30SyntParam::SyntParam(const SyntParam& src)
31        :Param(), autostring(src.autostring)
32{
33        Param::setParamTab(src.pe);
34        pe = ParamObject::makeParamTab(this);
35        Param::setParamTab(pe);
36        obj = ParamObject::dupObject(src.obj);
37        def_obj = src.def_obj ? ParamObject::dupObject(src.def_obj) : NULL;
38        Param::select(obj);
39}
40
41SyntParam::~SyntParam()
42{
43        update();
44        ParamObject::freeParamTab(pe);
45        ParamObject::freeObject(obj);
46        ParamObject::freeObject(def_obj);
47}
48
49void SyntParam::update(SString *s)
50{
51        if (!s) s = autostring;
52        if (s) { *s = ""; Param::saveSingleLine(*s, def_obj, 0); }
53}
54
55void SyntParam::revert(SString *s)
56{
57        if (!s) s = autostring;
58        if (s)  {
59                Param::load(ParamInterface::FormatSingleLine, *s);
60        }
61}
Note: See TracBrowser for help on using the repository browser.