1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Introduce std::string_view into wider use (#14368)

This commit is contained in:
sfan5 2024-02-17 15:35:33 +01:00 committed by GitHub
parent fa47af737f
commit 6ca214fefc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 501 additions and 456 deletions

View file

@ -23,8 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "util/basic_macros.h"
#include <string>
#include <list>
#include <set>
#include <map>
#include <mutex>
class Settings;
@ -124,18 +124,17 @@ typedef std::unordered_map<std::string, SettingsEntry> SettingEntries;
class Settings {
public:
/* These functions operate on the global hierarchy! */
static Settings *createLayer(SettingsLayer sl, const std::string &end_tag = "");
static Settings *createLayer(SettingsLayer sl, std::string_view end_tag = "");
static Settings *getLayer(SettingsLayer sl);
/**/
Settings(const std::string &end_tag = "") :
Settings(std::string_view end_tag = "") :
m_end_tag(end_tag)
{}
Settings(const std::string &end_tag, SettingsHierarchy *h, int settings_layer);
Settings(std::string_view end_tag, SettingsHierarchy *h, int settings_layer);
~Settings();
Settings & operator += (const Settings &other);
Settings & operator = (const Settings &other);
Settings & operator=(const Settings &other);
/***********************
* Reading and writing *
@ -258,8 +257,8 @@ private:
bool updateConfigObject(std::istream &is, std::ostream &os,
u32 tab_depth=0);
static bool checkNameValid(const std::string &name);
static bool checkValueValid(const std::string &value);
static bool checkNameValid(std::string_view name);
static bool checkValueValid(std::string_view value);
static std::string getMultiline(std::istream &is, size_t *num_lines=NULL);
static void printEntry(std::ostream &os, const std::string &name,
const SettingsEntry &entry, u32 tab_depth=0);
@ -276,9 +275,7 @@ private:
// For sane mutex locking when iterating
friend class LuaSettings;
void updateNoLock(const Settings &other);
void clearNoLock();
void clearDefaultsNoLock();
void doCallbacks(const std::string &name) const;