00001 /* 00002 * Copyright (C) 2003-2009 Olivier Boudeville 00003 * 00004 * This file is part of the Ceylan library. 00005 * 00006 * The Ceylan library is free software: you can redistribute it and/or modify 00007 * it under the terms of either the GNU Lesser General Public License or 00008 * the GNU General Public License, as they are published by the Free Software 00009 * Foundation, either version 3 of these Licenses, or (at your option) 00010 * any later version. 00011 * 00012 * The Ceylan library 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 Lesser General Public License and the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License and the GNU General Public License along with the Ceylan library. 00020 * If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Author: Olivier Boudeville (olivier.boudeville@esperide.com) 00023 * 00024 */ 00025 00026 00027 #include "CeylanTextDisplayable.h" 00028 00029 #include "CeylanStringUtils.h" // for formatStringList 00030 00031 00032 00033 using std::list ; 00034 using std::string ; 00035 00036 using namespace Ceylan ; 00037 00038 00039 00040 // Output format defaults to raw text. 00041 TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText ; 00042 00043 00044 00045 const std::string TextDisplayable::ToString( 00046 list<TextDisplayable*> displayables, Ceylan::VerbosityLevels level ) 00047 { 00048 00049 string res = "Description of TextDisplayable list is: " ; 00050 00051 list<string> descriptionList ; 00052 00053 for( list<TextDisplayable*>::const_iterator it = displayables.begin(); 00054 it != displayables.end(); it++ ) 00055 descriptionList.push_back( (*it)->toString( level ) ) ; 00056 00057 return res + formatStringList( descriptionList ) ; 00058 00059 } 00060 00061 00062 00063 TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat() 00064 { 00065 00066 return _OutputFormat ; 00067 00068 } 00069 00070 00071 00072 void TextDisplayable::SetOutputFormat( TextOutputFormat newOutputFormat ) 00073 { 00074 00075 _OutputFormat = newOutputFormat ; 00076 00077 } 00078 00079 00080 00081 std::ostream & operator << ( std::ostream & os, 00082 const Ceylan::TextDisplayable & textDisplayable ) 00083 { 00084 00085 return os << textDisplayable.toString( high ) ; 00086 00087 } 00088