Ignore:
Timestamp:
01/14/18 11:24:22 (6 years ago)
Author:
Maciej Komosinski
Message:

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

File:
1 edited

Legend:

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

    r650 r720  
    2828#define PARAM_NOSTATIC  256     //< (FramScript) don't access this member in a static object (ClassName.field)
    2929#define PARAM_CONST     512     //< (FramScript) constant value
    30 #define PARAM_CANOMITNAME 1024  //< affects Param::save2()/load2() - for example one-liners in f0 genetic encoding
     30#define PARAM_CANOMITNAME 1024  //< affects Param::saveSingleLine()/loadSingleLine() - for example one-liners in f0 genetic encoding
    3131#define PARAM_DONTLOAD    2048  //< Param::load() skips this field
    3232#define PARAM_NOISOLATION 4096  //< don't use proxy object in master/slave interactions
     
    170170        void quickCopyFrom(ParamInterface *src);
    171171
     172        enum FileFormat { FormatMultiLine, FormatSingleLine }; // FormatJSON in the future?
     173        struct LoadOptions {
     174                bool warn_unknown_fields; bool *abortable; int *linenum; int offset; bool parse_failed;
     175                LoadOptions() : warn_unknown_fields(false), abortable(NULL), linenum(NULL), offset(0), parse_failed(false) {}
     176        };
     177
    172178        int save(VirtFILE*, const char* altname = NULL, bool force = 0);
    173179        int saveprop(VirtFILE*, int i, const char* p, bool force = 0);
    174         int load(VirtFILE*, bool warn_unknown_fields = true, bool *abortable = NULL, int *linenum = NULL);///< @return the number of fields loaded
    175         int load2(const SString &, int &);///< @return the number of fields loaded (or'ed with LOAD2_PARSE_FAILED if a parsing error was detected)
     180
     181        int load(FileFormat format, VirtFILE*, LoadOptions *load_options = NULL);///< @return the number of fields loaded
     182        int load(FileFormat format, const SString &, LoadOptions *load_options = NULL);///< @return the number of fields loaded
     183protected:
     184        int loadMultiLine(VirtFILE*, LoadOptions &options);///< @return the number of fields loaded
     185        int loadSingleLine(const SString &, LoadOptions &options);///< @return the number of fields loaded
     186public:
    176187
    177188        static const char* SERIALIZATION_PREFIX;
    178         static const int LOAD2_PARSE_FAILED = (1 << 30); ///< this bit is set in return value from load2 if a parse error was detected while loading. usage: if (load2(...) & LOAD2_PARSE_FAILED) ...
    179         static const int LOAD2_IGNORE_PARSE_FAILED = (~LOAD2_PARSE_FAILED); ///< bitmask to be used if the parsing error is to be ignored. usage: int number_of_loaded_fields=load2(...) & LOAD2_IGNORE_PARSE_FAILED;
    180189
    181190        static bool isValidTypeDescription(const char* t);
     
    299308
    300309        int isequal(int i, void* defdata);
    301         void save2(SString&, void *defdata, bool addcr = true, bool all_names = true);
     310        void saveSingleLine(SString&, void *defdata, bool addcr = true, bool all_names = true);
    302311
    303312        virtual void setDefault();
Note: See TracChangeset for help on using the changeset viewer.