Eneboo - Documentación para desarrolladores
tools/aqods/odf-gen/length.h
Ir a la documentación de este archivo.
00001 /*
00002 odf-gen: Simple API to generate OpenDocument documents.
00003     Copyright (C) 2009  Pablo Jorge, FuDePAN
00004 
00005     This file is part of the odf-gen project.
00006 
00007     odf-gen is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     odf-gen is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with odf-gen.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef LENGTH_H
00022 #define LENGTH_H
00023 
00024 #include <iostream>
00025 #include <string>
00026 #include <sstream>
00027 
00028 class Length
00029 {
00030 public:
00031     Length( float value )
00032         : _value( value )
00033     {}
00034     
00035     virtual const char* unit() const
00036     {
00037         return "";
00038     }
00039     
00040     std::string str() const
00041     {
00042         std::stringstream stream;
00043         stream << _value << this->unit();
00044         return stream.str();
00045     }
00046 
00047 private:
00048     float _value;
00049 };
00050 
00051 class Centimeters : public Length
00052 {
00053 public:
00054     Centimeters( float value )
00055         : Length( value )
00056     {}
00057     
00058     const char* unit() const
00059     {
00060         return "cm";
00061     }
00062 };
00063 
00064 #endif // LENGTH_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'