Gorgon Game Engine
Validators.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include "../String.h"
5 
6 namespace Gorgon { namespace UI {
7 
44  template<class T_>
46  public:
47  using Type = T_;
48 
50  bool IsValid(std::string) const {
51  return true;
52  }
53 
55  bool AllowInsert(std::string /*start*/, std::string /*insert*/, std::string /*end*/) const {
56  return true;
57  }
58 
60  bool AllowErase(std::string /*before*/, int /*count*/, std::string /*after*/) const {
61  return true;
62  }
63 
65  bool AllowReplace(std::string /*before*/, int /*count*/, std::string /*insert*/, std::string /*after*/) const {
66  return true;
67  }
68 
70  Type From(std::string text) const {
71  return String::To<Type>(text);
72  }
73 
75  std::string ToString(const Type &value) const {
76  return String::From(value);
77  }
78 
79  };
80 
81 } }
Gorgon::UI::generator
Widgets::Generator * generator
Definition: UI.cpp:9
Gorgon::Widgets::Generator
Generators create templates for widgets.
Definition: Generator.h:16
Gorgon::String::From
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
Gorgon::Widgets::SimpleGenerator
This class generates very simple templates.
Definition: Generator.h:132
Gorgon::UI::ConversionValidator
Accepts all input and tries to convert using in-library functions.
Definition: Validators.h:45
Gorgon::UI::ConversionValidator::AllowErase
bool AllowErase(std::string, int, std::string) const
Checks if given number of characters can be erased from before.
Definition: Validators.h:60
Gorgon::UI::ConversionValidator::IsValid
bool IsValid(std::string) const
Checks if the given string is valid.
Definition: Validators.h:50
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::WindowManager::Monitor::Primary
static Monitor & Primary()
Returns the default monitor.
Definition: WindowManager.h:122
Gorgon::UI::Initialize
void Initialize(std::string fontname="", float density=7.5, int min=9)
Initializes the UI system.
Definition: UI.cpp:12
Gorgon::UI::ConversionValidator::From
Type From(std::string text) const
Converts the given string to the type. If input is not valid, return initial value.
Definition: Validators.h:70
Gorgon::UI::ConversionValidator::AllowReplace
bool AllowReplace(std::string, int, std::string, std::string) const
Checks if given number of characters can be replace with insert at the end of before.
Definition: Validators.h:65
Gorgon::UI::ConversionValidator::AllowInsert
bool AllowInsert(std::string, std::string, std::string) const
Checks if given string can be inserted between start and end.
Definition: Validators.h:55
Gorgon::UI::ConversionValidator::ToString
std::string ToString(const Type &value) const
Converts the given value to string.
Definition: Validators.h:75
Gorgon::UI::ConversionValidator::Type
T_ Type
Definition: Validators.h:47
Gorgon::Widgets::Registry
This class stores templates for elements.
Definition: Registry.h:12