From daca21051927eabee098e422fe5a0990acacfb96 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 31 Oct 2021 20:52:56 +0200 Subject: [PATCH] Use nullptr instead of 0 for pointers --- source/binaryparser.cpp | 14 +++++++------- source/builtinsource.cpp | 4 ++-- source/collection.cpp | 10 +++++----- source/collection.h | 2 +- source/directorysource.cpp | 2 +- source/dynamicobjectloader.h | 4 ++-- source/input.cpp | 2 +- source/jsonparser.cpp | 2 +- source/loader.cpp | 8 ++++---- source/loader.h | 2 +- source/output.cpp | 2 +- source/packsource.cpp | 4 ++-- source/parser.cpp | 2 +- source/parsermode.h | 2 +- source/textparser.cpp | 4 ++-- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/source/binaryparser.cpp b/source/binaryparser.cpp index e105393..fa1cf1d 100644 --- a/source/binaryparser.cpp +++ b/source/binaryparser.cpp @@ -16,7 +16,7 @@ namespace DataFile { 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"); @@ -29,7 +29,7 @@ Statement BinaryParser::parse() if(cur_info) { key = &cur_info->key; - cur_info = 0; + cur_info = nullptr; } else { @@ -119,14 +119,14 @@ const StatementKey *BinaryParser::peek(unsigned level) 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 - cur_info = 0; - return 0; + cur_info = nullptr; + return nullptr; } if(cur_info) @@ -134,7 +134,7 @@ const StatementKey *BinaryParser::peek(unsigned level) int id = parse_int(); if(!in) - return 0; + return nullptr; 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()); - cur_info = 0; + cur_info = nullptr; act.execute(ldr, args); diff --git a/source/builtinsource.cpp b/source/builtinsource.cpp index 65b2718..3fbc269 100644 --- a/source/builtinsource.cpp +++ b/source/builtinsource.cpp @@ -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); - return 0; + return nullptr; } BuiltinSource::Object::Object(): - data(0), + data(nullptr), size(0) { } diff --git a/source/collection.cpp b/source/collection.cpp index d222568..8e9543a 100644 --- a/source/collection.cpp +++ b/source/collection.cpp @@ -8,7 +8,7 @@ namespace Msp { namespace DataFile { Collection::Collection(): - fallback(0) + fallback(nullptr) { } Collection::~Collection() @@ -67,7 +67,7 @@ const Variant *Collection::find_var(const string &name, const CollectionItemType } i = items.find(name); - return (i!=items.end() ? &i->second : 0); + return (i!=items.end() ? &i->second : nullptr); } void Collection::gather_items(vector *vars, list *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; - return 0; + return nullptr; } 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; - return 0; + return nullptr; } 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; - return 0; + return nullptr; } void Collection::gather_names_from_sources(list &names, const CollectionItemTypeBase &type) const diff --git a/source/collection.h b/source/collection.h index fb9470d..4a2f736 100644 --- a/source/collection.h +++ b/source/collection.h @@ -540,7 +540,7 @@ CollectionItemTypeBase *Collection::get_type(const std::string &name) const for(CollectionItemTypeBase *t: types) if(dynamic_cast *>(t)) return t; - CollectionItemTypeBase *type = 0; + CollectionItemTypeBase *type = nullptr; for(CollectionItemTypeBase *t: types) if(t->can_extract()) { diff --git a/source/directorysource.cpp b/source/directorysource.cpp index e9f95fc..7e1e438 100644 --- a/source/directorysource.cpp +++ b/source/directorysource.cpp @@ -46,7 +46,7 @@ IO::Seekable *DirectorySource::open(const string &name) const 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 diff --git a/source/dynamicobjectloader.h b/source/dynamicobjectloader.h index 551a0a6..ee1827b 100644 --- a/source/dynamicobjectloader.h +++ b/source/dynamicobjectloader.h @@ -71,8 +71,8 @@ Loader::ActionMap DynamicObjectLoader::shared_actions; template DynamicObjectLoader::DynamicObjectLoader(Collection *c): coll(c), - object(0), - obj_loader(0) + object(nullptr), + obj_loader(nullptr) { set_actions(shared_actions); } diff --git a/source/input.cpp b/source/input.cpp index 4a44dea..86623ea 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -6,7 +6,7 @@ namespace DataFile { Input::Input(IO::Base &i): in(&i), - compressed(0), + compressed(nullptr), line(1), next(-1) { } diff --git a/source/jsonparser.cpp b/source/jsonparser.cpp index 44c7b06..e26ce5f 100644 --- a/source/jsonparser.cpp +++ b/source/jsonparser.cpp @@ -82,7 +82,7 @@ Statement JsonParser::parse_statement(const Token *t, State outer_state, const s if(t) { token = *t; - t = 0; + t = nullptr; } else token = parse_token(); diff --git a/source/loader.cpp b/source/loader.cpp index 5fd32c9..1ee6df3 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -48,8 +48,8 @@ namespace Msp { namespace DataFile { Loader::Loader(): - actions(0), - cur_st(0), + actions(nullptr), + cur_st(nullptr), 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) - return 0; + return nullptr; 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); - LoaderAction *act = 0; + LoaderAction *act = nullptr; int match = 0; for(auto i=begin; i!=end; ++i) { diff --git a/source/loader.h b/source/loader.h index 926a2a1..85e26d9 100644 --- a/source/loader.h +++ b/source/loader.h @@ -130,7 +130,7 @@ protected: /** 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 *); diff --git a/source/output.cpp b/source/output.cpp index 2d33810..5ee1911 100644 --- a/source/output.cpp +++ b/source/output.cpp @@ -8,7 +8,7 @@ namespace DataFile { Output::Output(IO::Base &o): out(&o), - compressed(0) + compressed(nullptr) { } Output::~Output() diff --git a/source/packsource.cpp b/source/packsource.cpp index b2fb17a..4a0bb15 100644 --- a/source/packsource.cpp +++ b/source/packsource.cpp @@ -51,7 +51,7 @@ void PackSource::add_pack_file(const string &fn) 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) @@ -155,7 +155,7 @@ IO::Seekable *PackSource::open(const string &fn) const if(i!=files.end()) return i->second->open().release(); - return 0; + return nullptr; } diff --git a/source/parser.cpp b/source/parser.cpp index 7e4d3dd..7d0bb3b 100644 --- a/source/parser.cpp +++ b/source/parser.cpp @@ -103,7 +103,7 @@ const StatementKey *Parser::peek(unsigned level) return key; } - return 0; + return nullptr; } bool Parser::parse_and_load(unsigned level, Loader &ldr, const LoaderAction &act) diff --git a/source/parsermode.h b/source/parsermode.h index 5c9dece..9d47ae4 100644 --- a/source/parsermode.h +++ b/source/parsermode.h @@ -27,7 +27,7 @@ public: 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; } }; diff --git a/source/textparser.cpp b/source/textparser.cpp index b8515a9..c7b13e9 100644 --- a/source/textparser.cpp +++ b/source/textparser.cpp @@ -16,7 +16,7 @@ TextParser::TextParser(Input &i, const string &s): Statement TextParser::parse() { - return parse_statement(0); + return parse_statement(nullptr); } Statement TextParser::parse_statement(const Token *t) @@ -30,7 +30,7 @@ Statement TextParser::parse_statement(const Token *t) if(t) { token = *t; - t = 0; + t = nullptr; } else token = parse_token(); -- 2.45.2