|
/*
Eva library C++ (www.elxala.de)
Copyright (C) 2005 Alejandro Xalabarder Aulet
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Eva.h
@author Alejandro Xalabarder 03.07.2003 23:35
03.07.2003 23:36 Pasar a C++
*/
#ifndef _CELTA_EVA_EVAFILE_H_
#define _CELTA_EVA_EVAFILE_H_
#include "EvaClasses.h"
namespace celta
{
/**
@class EvaFile
@author Alejandro Xalabarder
@date 03.07.2003
@memo
Class to read and write EvaUnit structures in a file (persistency). An object of this
class can do just three things : get the names of all EvaUnits in a file, load a specific
EvaUnit from a file and save a EvaUnit in a file.
@todo General review, document it in english and make it conform with Eva specification 1.1
@example
<pre>
EvaFile eFile;
vector<string> catalogo;
if (eFile.getEvaUnitCatalog ("file.eva", catalogo))
cout << "the file contains " << catalogo.size () << " EvaUnit's\n";
EvaUnit eUnit;
if (catalogo.size () > 0 &&
eFile.load (eUnit, "file.eva", catalogo[0].c_str()))
cout << "the fisrt unit is " << eUnit.getName ().c_str() << "\n";
eFile.saveSingleUnit (eUnit, "file_00.eva");
cout << "new file file_00.eva created\n";
</pre>
*/
class EvaFile
{
public:
/**
Read a eva file and writes all the EvaUnit names in a String array.
@param FileName The file name of the EVA file where the EvaUnits lie.
@return A String array with all the EvaUnit names in the file. If the
file doesn't exists then returns null.
*/
bool getEvaUnitCatalog (const string & FileName, vector<string> & vCatalog);
/**
Loads an eva unit in 'eUnit' from the file 'FileName' unit 'unitName'
Example:
EvaFile ef;
EvaUnit eu;
if (efi.load (eu, "myfile.eva", "data"))
...
@param eUnit EvaUnit to be updated with new 'unitName'
@param FileName The file name of the EVA file where the unit lies.
@param UnitName The name of the unit of evas (without ## symbols)
@return if the load of the unit succeded
*/
bool load (EvaUnit & eUnit, const string & FileName, const string & unitName);
/**
Salva la unidad 'ueva' en el fichero de nombre 'FileName'. El fichero
resultante ser� creado o sobreescrito y al final s�lo contendr� una �nica
EvaUnit.
@param ueva Unit of Evas to save (without ## symbols)
@param FileName File name of the eva file where we want to save the unit of evas. If
the file don't exists then it will be new created otherwise will be
overwritten. The final content of the file will be a single Eva Unit!.
@return If the unit has been successfully saved on the file then returns true, otherwise
returns false.
*/
bool saveSingleUnit (EvaUnit & ueva, const string & FileName);
private:
enum rLineType
{
esFIN_FICHERO_HARD,
esFIN_FICHERO_SOFT,
esFIN_FICHERO,
esUNIDAD,
esEVA,
esCOMENTARIO,
esDATOS
};
static const char MARCA_Unit []; // "#"
static const char MARCA_Eva1 []; // "<"
static const char MARCA_Eva2 []; // ">"
static const char MARCA_FinEva []; // "#**"
string cNombre;
Cadena cLinFiltrada;
string cLinBruta;
string cLinSobrante;
FILE * m_file;
// ========== direct file functions
//
bool OpenFile (const string & FileName);
bool ReadLine ();
void CloseFile ();
// ==========
/** Lee el fichero hasta posicionarse en la unidad escogida
*/
bool BuscaUniEva (const string & nom);
/** Determina la naturaleza de la l�nea (unidad, eva, dato, comentario ...)
*/
rLineType QueEs ();
/**
Lee una linea del fichero eva y la filtra
*/
rLineType LeeLineaNeta (bool AhorraComentario);
/**
*/
rLineType NextUoE ();
/**
* Buscar en un fichero EVA la siguiente eva de la unidad en curso
* Retorna: TRUE si la encuentra y FALSE si fin de fichero o FinEva
*/
bool SiguienteEva();
/**
* Buscar en un fichero EVA la siguiente unidad
* Retorna: TRUE si la encuentra y FALSE si fin de fichero o FinEva
*/
bool SiguienteUniEva();
};
}; // namespace celta
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have a Telecomunications Engineering degree but since I learnt the first language (Pascal), almost I haven't stopped developing software. Mainly with C and C++ but I have touched many other languages and scripts. I use also to develop for fun (reinventing the wheel, of course!), currently almost all of such programs and tools are written in java (visit www.elxala.de).