Remove dynamic exceptions
[anna.git] / include / anna / core / util / TextVariable.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_core_util_TextVariable_hpp
10 #define anna_core_util_TextVariable_hpp
11
12 #include <anna/core/util/Variable.hpp>
13 #include <anna/core/util/String.hpp>
14
15 namespace anna {
16
17 class DataBlock;
18
19 class TextComposer;
20
21 /**
22  * Variable que contiene los valores sobre los que trabaja el util::TextComposer.
23  */
24 class TextVariable : public Variable {
25 public:
26   /**
27    * Asignación a entero.
28    * \param value Valor a asignar a esta variable.
29    */
30   TextVariable& operator= (const int value) noexcept(false) { setValue(value); return *this; }
31
32   /**
33    * Asignación a cadena.
34    * \param value Valor a asignar a esta variable.
35    */
36   TextVariable& operator= (const char* value) noexcept(false) { setValue(value); return *this; }
37
38   /**
39    * Asignación a cadena.
40    * \param value Valor a asignar a esta variable.
41    */
42   TextVariable& operator= (const anna::String& value) noexcept(false) { setValue(value.c_str()); return *this; }
43
44   /**
45    * Asignación a entero de 64 bits.
46    * \param value Valor a asignar a esta variable.
47    */
48   TextVariable& operator= (const S64 value) noexcept(false) { setValue(value); return *this; }
49
50   /**
51    * Asignación a flotante.
52    * \param value Valor a asignar a esta variable.
53    */
54   TextVariable& operator= (const float value) noexcept(false) { setValue(value); return *this; }
55
56   /**
57    * Asignación a flotante.
58    * \param value Valor a asignar a esta variable.
59    */
60   TextVariable& operator= (const double value) noexcept(false) { setValue(value); return *this; }
61
62 protected:
63   /**
64    * Constructor.
65    * \param name Nombre de la variable.
66    * \param type Tipo de dato de la variable.
67    * \param expression Expresión asociada a esta variable.
68    */
69   TextVariable(const char* name, const Type::_v type, const anna::String& expression);
70
71
72 private:
73   const anna::String a_expression;
74
75   const char* compose(DataBlock& buffer) const noexcept(false);
76
77   friend class TextComposer;
78 };
79
80 }
81
82 #endif
83