//================================================================================================== // D i s p l a y Interface // C o n s o l e // By Bruno Bachelet //================================================================================================== // Copyright (c) 1999-2016 // Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net // // This file is part of the B++ Library. This library is free software; you can redistribute it // and/or modify it under the terms of the GNU Library General Public License as published by the // Free Software Foundation; either version 2 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 Library General Public License for more details (http://www.gnu.org).
/*DESCRIPTION*/ /* This module provides a console display for the B++ Library. */
// File Name //------------------------------------------------------------------------------------- #line __LINE__ "display/console.hpp"
// Guardian //-------------------------------------------------------------------------------------- #ifndef guDisplayConsole #define guDisplayConsole
// Headers //--------------------------------------------------------------------------------------- #include <bpp/display.hpp> /*INCLUDE*/
namespace bpp {
// Importation/Exportation //----------------------------------------------------------------------- #ifdef INTERFACE_DLL #define dll_export DLL_EXPORT #else #define dll_export DLL_IMPORT #endif
// Namespaces //------------------------------------------------------------------------------------ #define public_area displayConsole #define private_area displayConsole_private
namespace public_area { /*NAMESPACE*/ using namespace standardKeyword; } namespace private_area { using namespace public_area; }
// Macrocommands //---------------------------------------------------------------------------------
// Types & Classes //------------------------------------------------------------------------------- namespace public_area { //------------------------------------------------------------------------------------------Classes class clDisplay; //-----------------------------------------------------------------------------------Constant Types typedef const clDisplay ctDisplay; }
namespace private_area {}
// Functions Interface //--------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// Errors //---------------------------------------------------------------------------------------- namespace public_area {}
// Constants & Variables //------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// D i s p l a y Interface //---------------------------------------------------------------------- namespace public_area { /*CLASS clDisplay */ /* Represents a console display. */ class clDisplay : public display::clDisplay { //-----------------------------------------------------------------------------------------Private private_property constructor clDisplay(ctDisplay &); private_property clDisplay & operator = (ctDisplay &); //------------------------------------------------------------------------------------------Public public_property constructor clDisplay(void); public_property destructor clDisplay(void);
public_property void activate(void); public_property void close(void); public_property void nextLine(void); public_property void open(void); public_property display::tyReturn quit(display::tyProgramResult); public_property void refresh(void); }; }
// Functions Inline //------------------------------------------------------------------------------ namespace public_area {} namespace private_area {}
// D i s p l a y Inline //------------------------------------------------------------------------- namespace public_area { //--------------------------------------------------------------------------------------Constructor /*METHOD clDisplay */ /* Builds a display. */ inline clDisplay::clDisplay(void) {} //---------------------------------------------------------------------------------------Destructor /*METHOD clDisplay */ /* Destructs the display. */ inline clDisplay::~clDisplay(void) {} //-----------------------------------------------------------------------------------------Activate /*METHOD clDisplay */ /* Activates the display, if not already done. */ inline void clDisplay::activate(void) {} //------------------------------------------------------------------------------------------Refresh /*METHOD clDisplay */ /* Refreshes the display. */ inline void clDisplay::refresh(void) {} }
// End //------------------------------------------------------------------------------------------- } #undef dll_export #undef public_area #undef private_area #endif |
//================================================================================================== // D i s p l a y Implementation // C o n s o l e // By Bruno Bachelet //================================================================================================== // Copyright (c) 1999-2016 // Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net // // This file is part of the B++ Library. This library is free software; you can redistribute it // and/or modify it under the terms of the GNU Library General Public License as published by the // Free Software Foundation; either version 2 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 Library General Public License for more details (http://www.gnu.org).
// File Name //------------------------------------------------------------------------------------- #line __LINE__ "display/console.cpp"
// DLL Belonging //--------------------------------------------------------------------------------- #define INTERFACE_DLL
// Headers //--------------------------------------------------------------------------------------- #include <bpp/display/console.hpp> /*INTERFACE*/ #include <contribution/string.hpp> /*NEED*/ #include <iostream> /*NEED*/
namespace bpp {
// Namespaces //------------------------------------------------------------------------------------ #define public_area displayConsole #define private_area displayConsole_private #define dll_export DLL_EXPORT
namespace public_area {} namespace private_area {}
// Errors //---------------------------------------------------------------------------------------- namespace public_area {}
// Constants & Variables //------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// Static Members //-------------------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// Functions Implementation //---------------------------------------------------------------------- namespace public_area {} namespace private_area {}
// D i s p l a y Implementation //----------------------------------------------------------------- namespace public_area { //--------------------------------------------------------------------------------------------Close /*METHOD clDisplay */ /* Closes the display. */ property void clDisplay::close(void) { atOutputFile.close(); delete [] atCurrentLine; delete [] atParameterFileName; delete [] atOutputFileName; } //-----------------------------------------------------------------------------------------NextLine /*METHOD clDisplay */ /* Jumps to the next line. */ property void clDisplay::nextLine(void) { refresh(); std::cout << atCurrentLine << std::endl; atOutputFile << atCurrentLine << end_line; atCurrentLine[0]=end_string; } //---------------------------------------------------------------------------------------------Open /*METHOD clDisplay */ /* Opens the display. */ property void clDisplay::open(void) { display::tcString lcParameterFileName = "bpp_library.ini"; display::tcString lcOutputFileName = "bpp_library.out";
atCurrentLine = new display::tyCharacter [65535];
atCurrentLine[0]=end_string;
display::tcString lcVariable = std::getenv(BPP_TOOLS_ENVIRONMENT_VARIABLE);
if (lcVariable==nil) { atParameterFileName=new display::tyCharacter [bpp::low::string::length(lcParameterFileName)+1]; atOutputFileName=new display::tyCharacter [bpp::low::string::length(lcOutputFileName)+1];
bpp::low::string::copy(atParameterFileName,lcParameterFileName); bpp::low::string::copy(atOutputFileName,lcOutputFileName); } else { atParameterFileName=new display::tyCharacter [bpp::low::string::length(lcVariable) +bpp::low::string::length(lcParameterFileName)+2];
atOutputFileName=new display::tyCharacter [bpp::low::string::length(lcVariable) +bpp::low::string::length(lcOutputFileName)+2];
bpp::low::string::copy(atParameterFileName,lcVariable); bpp::low::string::concatenate(atParameterFileName,FILE_NAME_SEPARATOR); bpp::low::string::concatenate(atParameterFileName,lcParameterFileName);
bpp::low::string::copy(atOutputFileName,lcVariable); bpp::low::string::concatenate(atOutputFileName,FILE_NAME_SEPARATOR); bpp::low::string::concatenate(atOutputFileName,lcOutputFileName); }
atOutputFile.open(atOutputFileName,std::ios::out|std::ios::trunc); } //---------------------------------------------------------------------------------------------Quit /*METHOD clDisplay */ /* Quits the program. */ property display::tyReturn clDisplay::quit(display::tyProgramResult agResult) { if (agResult==display::success) return (EXIT_SUCCESS); else return (EXIT_FAILURE); } }
// End //------------------------------------------------------------------------------------------- } |
|