Ignore:
Timestamp:
10/17/22 12:28:47 (18 months ago)
Author:
Maciej Komosinski
Message:

Introduced a class to quickly copy field values between two compatible Param's, and added a constructor that checks if the paramtab structure is correct

File:
1 edited

Legend:

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

    r1155 r1184  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2022  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4949        return (const char*)memchr((const void*)t, ch, limit - t);
    5050}
     51
     52
     53Param2ParamCopy::Param2ParamCopy(ParamInterface& schema, const std::initializer_list<const char*> names)
     54{
     55        for (const char* n : names)
     56        {
     57                int i = schema.findId(n);
     58                if (i >= 0)
     59                        fields.push_back(i);
     60                else
     61                        logPrintf("Param2ParamCopy", "findId", LOG_CRITICAL, "Can't find '%s.%s'", schema.getName(), n);
     62        }
     63}
     64
     65void Param2ParamCopy::operator()(const ParamInterface& from, ParamInterface& to)
     66{
     67        ExtValue tmp;
     68        for (int i : fields)
     69        {
     70                ((ParamInterface&)from).get(i, tmp);
     71                to.set(i, tmp);
     72        }
     73}
     74
    5175
    5276void ParamInterface::copyFrom(ParamInterface *src)
Note: See TracChangeset for help on using the changeset viewer.