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

Last change on this file since 875 was 720, checked in by Maciej Komosinski, 7 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
RevLine 
[286]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.
[109]4
5#include <common/nonstd.h>
6#include "syntparam.h"
7#include "paramobj.h"
8#include <math.h>
9
[720]10SyntParam::SyntParam(ParamEntry *init_pe, SString* autostr, bool handle_defaults_when_saving)
[109]11        :autostring(autostr)
12{
[720]13        Param::setParamTab(init_pe);
14        pe = ParamObject::makeParamTab(this);
15        Param::setParamTab(pe);
16        if (handle_defaults_when_saving)
[109]17        {
[720]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);
[109]26        Param::setDefault();
[720]27        revert();
[109]28}
29
30SyntParam::SyntParam(const SyntParam& src)
[720]31        :Param(), autostring(src.autostring)
[109]32{
[720]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);
[109]39}
40
41SyntParam::~SyntParam()
42{
[720]43        update();
44        ParamObject::freeParamTab(pe);
45        ParamObject::freeObject(obj);
46        ParamObject::freeObject(def_obj);
[109]47}
48
49void SyntParam::update(SString *s)
50{
[720]51        if (!s) s = autostring;
52        if (s) { *s = ""; Param::saveSingleLine(*s, def_obj, 0); }
[109]53}
54
55void SyntParam::revert(SString *s)
56{
[720]57        if (!s) s = autostring;
58        if (s)  {
59                Param::load(ParamInterface::FormatSingleLine, *s);
[109]60        }
61}
Note: See TracBrowser for help on using the repository browser.