/** @(#) utilpos/builderpos.cpp */ #ifndef BUILDERPOS_H #define BUILDERPOS_H //---------------------------------------------------------------------------- #include "matrixdouble/vectordouble.h" #include <vcl.h> #include <iostream> #include <string> #include <stdexcept> // runtime_error using namespace std; /** * Reservar memoria. * No hace operaciones aritmeticas. * Entrada y salida de arreglos. * @author Omar Posada Villarreal * @version 1.1, 24/04/2002 first [-N, +N] * @version 1.0, 13/04/2002 */ //template <class TC> class BuilderPos { //---------------------------------------------------------------------------- private: //---------------------------------------------------------------------------- public: /** Extrae flotantes de TEdit a VectorDouble. * Logica cero. */ static void toVectorDouble(TEdit *edit, VectorDouble &vect) throw (invalid_argument) { // CHECAR istringstream, mas facil int size = vect.getSize(); vect.setLogic(0); int len = edit->GetTextLen(); //Get length of string in Edit1 ++len; //Add room for null character char *buffer = new char[len]; //Creates Buffer dynamic variable char *pToken; edit->GetTextBuf(buffer, len); //Puts Edit1->Text into Buffer pToken = strtok(buffer, ", \t\n"); int i; for (i = 0; i < size; ++i) { if (pToken == NULL) { throw invalid_argument ("\ntoVector: Dimensiones distintas."); } vect[i] = static_cast<double>( atof(pToken) ); pToken = strtok(NULL, ", \t\n"); } delete buffer; } // constructor, ~, friend----------------------------------------------------- }; // } BuilderPos------------------------------------------------------------ #endif // Fin------------------------------------------------------------------------