mikymod 12 лет назад
Родитель
Сommit
a3a949dba7
3 измененных файлов с 83 добавлено и 0 удалено
  1. 2 0
      src/CMakeLists.txt
  2. 50 0
      src/core/settings/StringSetting.cpp
  3. 31 0
      src/core/settings/StringSetting.h

+ 2 - 0
src/CMakeLists.txt

@@ -171,11 +171,13 @@ set (COMPRESSORS_HEADERS
 set (SETTINGS_SRC
 	core/settings/IntSetting.cpp
 	core/settings/FloatSetting.cpp
+	core/settings/StringSetting.cpp
 )
 
 set (SETTINGS_HEADERS
 	core/settings/IntSetting.h
 	core/settings/FloatSetting.h
+	core/settings/StringSetting.h
 )
 
 set (INPUT_SRC

+ 50 - 0
src/core/settings/StringSetting.cpp

@@ -0,0 +1,50 @@
+#include "StringSetting.h"
+
+namespace crown
+{
+
+static StringSetting* g_string_settings_head = NULL;
+
+StringSetting::StringSetting(const char* name, const char* synopsis, const char* value) :
+	m_name(name),
+	m_synopsis(synopsis),
+	m_value(value),
+	m_next(NULL)
+{
+	*this = value;
+
+	if (g_string_settings_head == NULL)
+	{
+		g_string_settings_head = this;
+		m_next = NULL;
+	}
+	else
+	{
+		m_next = g_string_settings_head;
+		g_string_settings_head = this;
+	}
+}
+
+const char* StringSetting::name() const
+{
+	return m_name;
+}
+
+const char* StringSetting::synopsis() const
+{
+	return m_synopsis;
+}
+
+const char*	StringSetting::value() const
+{
+	return m_value;
+}
+
+StringSetting&	StringSetting::operator=(const char* value)
+{
+	m_value = value;
+
+	return *this;
+}
+
+} // namespace crown

+ 31 - 0
src/core/settings/StringSetting.h

@@ -0,0 +1,31 @@
+#pragma once
+
+#include "Types.h"
+
+namespace crown
+{
+
+/// Facility to store global string settings.
+class StringSetting
+{
+public:
+
+						StringSetting(const char* name, const char* synopsis, const char* value);
+
+	const char*			name() const;
+	const char*			synopsis() const;
+
+	const char*			value() const;
+
+	StringSetting&		operator=(const char* value);
+
+private:
+
+	const char*			m_name;
+	const char*			m_synopsis;
+	const char*			m_value;
+
+	StringSetting*		m_next;
+};
+
+} // namespace crown