Remove dynamic exceptions
[anna.git] / include / anna / io / TextReader.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_io_TextReader_hpp
10 #define anna_io_TextReader_hpp
11
12 #include <anna/io/AbstractReader.hpp>
13
14 namespace anna {
15
16 namespace io {
17
18 /**
19    Lector de ficheros de texto.
20 */
21 class TextReader : public AbstractReader {
22 public:
23   /**
24      Constructor.
25      \param maxLength Longitud máxima de línea del fichero a tratar.
26      \warning Con esta clase solo podemos tratar archivos de texto. Si utilizamos este constructor
27      debemos invocar al método open antes de usar cualquier otro método de la clase.
28   */
29   TextReader(const int maxLength = 512);
30
31   /**
32      Constructor.
33      \param filename Ruta completa del fichero a leer.
34      \param maxLength Longitud máxima de línea del fichero a tratar.
35      \warning Con esta clase solo podemos tratar archivos de texto.
36   */
37   TextReader(const char* filename, const int maxLength = 512);
38
39   /**
40      Constructor.
41      \param filename Ruta completa del fichero a leer.
42      \param maxLength Longitud máxima de línea del fichero a tratar.
43      \warning Con esta clase solo podemos tratar archivos de texto.
44   */
45   TextReader(const std::string& filename, const int maxLength = 512);
46
47   /**
48      Destructor.
49   */
50   virtual ~TextReader();
51
52   /**
53      Devuelve el contenido de la línea actual o NULL si se ha llegado al fin del fichero.
54      \return El contenido de la línea actual o NULL si se ha llegado al fin del fichero.
55   */
56   const char* fetch() noexcept(false);
57
58 private:
59   char* a_buffer;
60   const int a_maxLength;
61 };
62
63 }
64 }
65 #endif