]> git.tdb.fi Git - libs/datafile.git/commitdiff
Use nullptr instead of 0 for pointers
authorMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 18:52:56 +0000 (20:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 18:52:56 +0000 (20:52 +0200)
15 files changed:
source/binaryparser.cpp
source/builtinsource.cpp
source/collection.cpp
source/collection.h
source/directorysource.cpp
source/dynamicobjectloader.h
source/input.cpp
source/jsonparser.cpp
source/loader.cpp
source/loader.h
source/output.cpp
source/packsource.cpp
source/parser.cpp
source/parsermode.h
source/textparser.cpp

index e105393f3d02c16f1fbb21ff5a5922f365e8534b..fa1cf1daa86cd490f3d3697fbf83f5c8949a1a59 100644 (file)
@@ -16,7 +16,7 @@ namespace DataFile {
 BinaryParser::BinaryParser(Input &i, const string &s):
        ParserMode(i, s),
        float_precision(32),
 BinaryParser::BinaryParser(Input &i, const string &s):
        ParserMode(i, s),
        float_precision(32),
-       cur_info(0)
+       cur_info(nullptr)
 {
        dict[-1] = StatementInfo("__kwd", "iss");
        dict[-2] = StatementInfo("__str", "is");
 {
        dict[-1] = StatementInfo("__kwd", "iss");
        dict[-2] = StatementInfo("__str", "is");
@@ -29,7 +29,7 @@ Statement BinaryParser::parse()
        if(cur_info)
        {
                key = &cur_info->key;
        if(cur_info)
        {
                key = &cur_info->key;
-               cur_info = 0;
+               cur_info = nullptr;
        }
        else
        {
        }
        else
        {
@@ -119,14 +119,14 @@ const StatementKey *BinaryParser::peek(unsigned level)
                for(unsigned i=sub_remaining.back(); i-->0; )
                        parse();
                sub_remaining.pop_back();
                for(unsigned i=sub_remaining.back(); i-->0; )
                        parse();
                sub_remaining.pop_back();
-               cur_info = 0;
+               cur_info = nullptr;
        }
 
        if(!sub_remaining.empty() && sub_remaining.back()==0)
        {
                // No more substatements on this level
        }
 
        if(!sub_remaining.empty() && sub_remaining.back()==0)
        {
                // No more substatements on this level
-               cur_info = 0;
-               return 0;
+               cur_info = nullptr;
+               return nullptr;
        }
 
        if(cur_info)
        }
 
        if(cur_info)
@@ -134,7 +134,7 @@ const StatementKey *BinaryParser::peek(unsigned level)
 
        int id = parse_int();
        if(!in)
 
        int id = parse_int();
        if(!in)
-               return 0;
+               return nullptr;
 
        cur_info = &get_item(dict, id);
        return &cur_info->key;
 
        cur_info = &get_item(dict, id);
        return &cur_info->key;
@@ -169,7 +169,7 @@ bool BinaryParser::parse_and_load(unsigned level, Loader &ldr, const LoaderActio
        if(!sub_remaining.empty())
                --sub_remaining.back();
        sub_remaining.push_back(parse_int());
        if(!sub_remaining.empty())
                --sub_remaining.back();
        sub_remaining.push_back(parse_int());
-       cur_info = 0;
+       cur_info = nullptr;
 
        act.execute(ldr, args);
 
 
        act.execute(ldr, args);
 
index 65b2718b80357660e8664ac803e6d855badf382b..3fbc2698025fd4cc9446bffdca5d0ba82483f424 100644 (file)
@@ -49,12 +49,12 @@ IO::Seekable *BuiltinSource::open(const string &name) const
        if(i!=objects.end())
                return new IO::Memory(i->second.data, i->second.size);
 
        if(i!=objects.end())
                return new IO::Memory(i->second.data, i->second.size);
 
-       return 0;
+       return nullptr;
 }
 
 
 BuiltinSource::Object::Object():
 }
 
 
 BuiltinSource::Object::Object():
-       data(0),
+       data(nullptr),
        size(0)
 { }
 
        size(0)
 { }
 
index d222568403355f4f3af1b1b0896a27f9311c7696..8e9543a0d1feef9717184c2a06d10c5e64f6f489 100644 (file)
@@ -8,7 +8,7 @@ namespace Msp {
 namespace DataFile {
 
 Collection::Collection():
 namespace DataFile {
 
 Collection::Collection():
-       fallback(0)
+       fallback(nullptr)
 { }
 
 Collection::~Collection()
 { }
 
 Collection::~Collection()
@@ -67,7 +67,7 @@ const Variant *Collection::find_var(const string &name, const CollectionItemType
        }
 
        i = items.find(name);
        }
 
        i = items.find(name);
-       return (i!=items.end() ? &i->second : 0);
+       return (i!=items.end() ? &i->second : nullptr);
 }
 
 void Collection::gather_items(vector<const Variant *> *vars, list<string> *names, const CollectionItemTypeBase &type, bool include_sources) const
 }
 
 void Collection::gather_items(vector<const Variant *> *vars, list<string> *names, const CollectionItemTypeBase &type, bool include_sources) const
@@ -107,7 +107,7 @@ CollectionItemTypeBase *Collection::get_type(const CollectionItemTypeBase &type)
        for(CollectionItemTypeBase *t: types)
                if(t->is_same_type(type))
                        return t;
        for(CollectionItemTypeBase *t: types)
                if(t->is_same_type(type))
                        return t;
-       return 0;
+       return nullptr;
 }
 
 CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const
 }
 
 CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const
@@ -115,7 +115,7 @@ CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const
        for(CollectionItemTypeBase *t: types)
                if(t->check_item_type(var))
                        return t;
        for(CollectionItemTypeBase *t: types)
                if(t->check_item_type(var))
                        return t;
-       return 0;
+       return nullptr;
 }
 
 void Collection::add_source(const CollectionSource &s)
 }
 
 void Collection::add_source(const CollectionSource &s)
@@ -129,7 +129,7 @@ IO::Seekable *Collection::open_raw(const string &name) const
                if(IO::Seekable *io = s->open(name))
                        return io;
 
                if(IO::Seekable *io = s->open(name))
                        return io;
 
-       return 0;
+       return nullptr;
 }
 
 void Collection::gather_names_from_sources(list<string> &names, const CollectionItemTypeBase &type) const
 }
 
 void Collection::gather_names_from_sources(list<string> &names, const CollectionItemTypeBase &type) const
index fb9470d591025e8beaa9377d7cd15fba2d4e5131..4a2f736de49cdabc4df1c9da4ce4ee96cda4753e 100644 (file)
@@ -540,7 +540,7 @@ CollectionItemTypeBase *Collection::get_type(const std::string &name) const
        for(CollectionItemTypeBase *t: types)
                if(dynamic_cast<CollectionItemType<T> *>(t))
                        return t;
        for(CollectionItemTypeBase *t: types)
                if(dynamic_cast<CollectionItemType<T> *>(t))
                        return t;
-       CollectionItemTypeBase *type = 0;
+       CollectionItemTypeBase *type = nullptr;
        for(CollectionItemTypeBase *t: types)
                if(t->can_extract<T>())
                {
        for(CollectionItemTypeBase *t: types)
                if(t->can_extract<T>())
                {
index e9f95fc830c9686997bc13088460c0da38847642..7e1e438a2a49ab1ed87996ca87b806eb3e8dc18e 100644 (file)
@@ -46,7 +46,7 @@ IO::Seekable *DirectorySource::open(const string &name) const
        if(lookup_file(name, file))
                return new IO::BufferedFile(file.str());
 
        if(lookup_file(name, file))
                return new IO::BufferedFile(file.str());
 
-       return 0;
+       return nullptr;
 }
 
 bool DirectorySource::lookup_file(const string &name, FS::Path &result) const
 }
 
 bool DirectorySource::lookup_file(const string &name, FS::Path &result) const
index 551a0a63dd1f454cbc691cbe53ebf96b620f23f1..ee1827bbd067f10e32123bde3e484743e64d0495 100644 (file)
@@ -71,8 +71,8 @@ Loader::ActionMap DynamicObjectLoader<T, C>::shared_actions;
 template<typename T, typename C>
 DynamicObjectLoader<T, C>::DynamicObjectLoader(Collection *c):
        coll(c),
 template<typename T, typename C>
 DynamicObjectLoader<T, C>::DynamicObjectLoader(Collection *c):
        coll(c),
-       object(0),
-       obj_loader(0)
+       object(nullptr),
+       obj_loader(nullptr)
 {
        set_actions(shared_actions);
 }
 {
        set_actions(shared_actions);
 }
index 4a44dea05228ae14d1d91e698ebe4eecf98cb662..86623ea36dd6063d94f037428f5c026b47fcf528 100644 (file)
@@ -6,7 +6,7 @@ namespace DataFile {
 
 Input::Input(IO::Base &i):
        in(&i),
 
 Input::Input(IO::Base &i):
        in(&i),
-       compressed(0),
+       compressed(nullptr),
        line(1),
        next(-1)
 { }
        line(1),
        next(-1)
 { }
index 44c7b06d64c7da744154f3d658cc153427d84826..e26ce5fa2ee6116fbc5cb26d68daf865fa253e85 100644 (file)
@@ -82,7 +82,7 @@ Statement JsonParser::parse_statement(const Token *t, State outer_state, const s
                if(t)
                {
                        token = *t;
                if(t)
                {
                        token = *t;
-                       t = 0;
+                       t = nullptr;
                }
                else
                        token = parse_token();
                }
                else
                        token = parse_token();
index 5fd32c93fb59f403244deafa81904222f2f2a902..1ee6df3057ae9e7bad8e31cc0fb36ada2265ba0e 100644 (file)
@@ -48,8 +48,8 @@ namespace Msp {
 namespace DataFile {
 
 Loader::Loader():
 namespace DataFile {
 
 Loader::Loader():
-       actions(0),
-       cur_st(0),
+       actions(nullptr),
+       cur_st(nullptr),
        direct(false),
        check_sub_loads(false)
 { }
        direct(false),
        check_sub_loads(false)
 { }
@@ -212,7 +212,7 @@ bool Loader::has_action(const StatementKey &key) const
 LoaderAction *Loader::find_action(const StatementKey &key) const
 {
        if(!actions)
 LoaderAction *Loader::find_action(const StatementKey &key) const
 {
        if(!actions)
-               return 0;
+               return nullptr;
 
        auto begin = actions->lower_bound(StatementKey(key.keyword, string()));
        auto end = actions->upper_bound(StatementKey(key.keyword, "~"));
 
        auto begin = actions->lower_bound(StatementKey(key.keyword, string()));
        auto end = actions->upper_bound(StatementKey(key.keyword, "~"));
@@ -220,7 +220,7 @@ LoaderAction *Loader::find_action(const StatementKey &key) const
        if(begin==end)
                throw unknown_keyword(key.keyword);
 
        if(begin==end)
                throw unknown_keyword(key.keyword);
 
-       LoaderAction *act = 0;
+       LoaderAction *act = nullptr;
        int match = 0;
        for(auto i=begin; i!=end; ++i)
        {
        int match = 0;
        for(auto i=begin; i!=end; ++i)
        {
index 926a2a16a4adbf2d542701867a47358ad09a3467..85e26d938b0aba5ac8a5efb67d5593e8c7137f45 100644 (file)
@@ -130,7 +130,7 @@ protected:
 
        /** Adds a keyword that is recognized but ignored. */
        void add(const std::string &k)
 
        /** Adds a keyword that is recognized but ignored. */
        void add(const std::string &k)
-       { add(k, 0); }
+       { add(k, nullptr); }
 
 private:
        void add(const std::string &, LoaderAction *);
 
 private:
        void add(const std::string &, LoaderAction *);
index 2d33810b5b86d720db9ec437d689ff4e3c57a554..5ee19115a5b0eedad79ee18ccbdcb9b9adb7b254 100644 (file)
@@ -8,7 +8,7 @@ namespace DataFile {
 
 Output::Output(IO::Base &o):
        out(&o),
 
 Output::Output(IO::Base &o):
        out(&o),
-       compressed(0)
+       compressed(nullptr)
 { }
 
 Output::~Output()
 { }
 
 Output::~Output()
index b2fb17abc5ae9393feabf2f223130b547a3c072e..4a0bb15e1a34554be1ef6668537081da716c589c 100644 (file)
@@ -51,7 +51,7 @@ void PackSource::add_pack_file(const string &fn)
 
 void PackSource::add_pack_file(const string &fn, const string &filter)
 {
 
 void PackSource::add_pack_file(const string &fn, const string &filter)
 {
-       add_pack(0, fn, filter);
+       add_pack(nullptr, fn, filter);
 }
 
 void PackSource::add_pack_io(IO::Seekable &io, const string &fn)
 }
 
 void PackSource::add_pack_io(IO::Seekable &io, const string &fn)
@@ -155,7 +155,7 @@ IO::Seekable *PackSource::open(const string &fn) const
        if(i!=files.end())
                return i->second->open().release();
 
        if(i!=files.end())
                return i->second->open().release();
 
-       return 0;
+       return nullptr;
 }
 
 
 }
 
 
index 7e4d3dd7f93942b9d4c9c3b69f2715d93b25b492..7d0bb3b465d7d2f1a8c36db3826aa60bdcdc90f8 100644 (file)
@@ -103,7 +103,7 @@ const StatementKey *Parser::peek(unsigned level)
                        return key;
        }
 
                        return key;
        }
 
-       return 0;
+       return nullptr;
 }
 
 bool Parser::parse_and_load(unsigned level, Loader &ldr, const LoaderAction &act)
 }
 
 bool Parser::parse_and_load(unsigned level, Loader &ldr, const LoaderAction &act)
index 5c9deceb7d2c289b224c7b5a20ed8dc9cf69131d..9d47ae422f8753bfb7a7a16f401e40b615a43729 100644 (file)
@@ -27,7 +27,7 @@ public:
        virtual Statement parse() = 0;
        virtual void process_control_statement(const Statement &) { }
 
        virtual Statement parse() = 0;
        virtual void process_control_statement(const Statement &) { }
 
-       virtual const StatementKey *peek(unsigned) { return 0; }
+       virtual const StatementKey *peek(unsigned) { return nullptr; }
        virtual bool parse_and_load(unsigned, Loader &, const LoaderAction &) { return false; }
 };
 
        virtual bool parse_and_load(unsigned, Loader &, const LoaderAction &) { return false; }
 };
 
index b8515a9b487fa2749d78c5c41a734c2f00c1b70f..c7b13e93c11e927178929289cf1ebf2164add537 100644 (file)
@@ -16,7 +16,7 @@ TextParser::TextParser(Input &i, const string &s):
 
 Statement TextParser::parse()
 {
 
 Statement TextParser::parse()
 {
-       return parse_statement(0);
+       return parse_statement(nullptr);
 }
 
 Statement TextParser::parse_statement(const Token *t)
 }
 
 Statement TextParser::parse_statement(const Token *t)
@@ -30,7 +30,7 @@ Statement TextParser::parse_statement(const Token *t)
                if(t)
                {
                        token = *t;
                if(t)
                {
                        token = *t;
-                       t = 0;
+                       t = nullptr;
                }
                else
                        token = parse_token();
                }
                else
                        token = parse_token();