00001 /* 00002 * ******** fete: From ENDF To ENDL ********* 00003 * 00004 * Copyright (c) 2006, The Regents of the University of California. 00005 * All rights reserved. 00006 * 00007 * Produced at the Lawrence Livermore National Laboratory. 00008 * Written by David A. Brown, Gerry Hedstrom, Tony Hill 00009 * 00010 * This file is part of fete v1.0 (UCRL-CODE-218718) 00011 * 00012 * Please read the COPYING file for "Our Notice and GNU General 00013 * Public License" in the root of this software distribution. 00014 * 00015 * This program is free software; you can redistribute it and/or modify 00016 * it under the terms of the GNU General Public License (as published by 00017 * the Free Software Foundation) version 2, dated June 1991. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 00022 * and conditions of the GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License along 00025 * with this program; if not, write to the Free Software Foundation, Inc., 00026 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00027 * 00028 * $Revision: 1781 $ 00029 * $Date: 2006-03-22 09:55:41 -0800 (Wed, 22 Mar 2006) $ 00030 * $Author: dbrown $ 00031 * $Id: convert.hpp 1781 2006-03-22 17:55:41Z dbrown $ 00032 * 00033 * ******** fete: From ENDF To ENDL ********* 00034 */ 00035 00036 // prototypes of conversion functions 00037 00038 #ifndef CONVERT_UTILITIES 00039 #define CONVERT_UTILITIES 00040 00041 #include <string> 00042 #include <cmath> 00043 #include <iostream> 00044 #include <vector> 00045 00046 using namespace std; 00047 00048 //! A function that converts a string to a double precision number. 00049 double stod( string instring ); 00050 00051 //! A function that converts a string to a single precision number. 00052 float stof( string instring ); 00053 00054 //! A function that converts a string to an integer. 00055 int stoi( string instring ); 00056 00057 //! A function that removes the leading blanks of a string 00058 string remove_leading_blanks( string instring ); 00059 00060 //! A function that removes the trailing blanks of a string 00061 string remove_trailing_blanks( string instring ); 00062 00063 //! A function that removes extra blanks in a string 00064 string remove_extra_blanks( string instring ); 00065 00066 //! A function that removes all blanks in a string 00067 string remove_all_blanks( string instring ); 00068 00069 //! splits a string at all occurances of "pattern" and returns 00070 //! the substrings in a list 00071 vector< string > split(const string& s, const string pattern=" "); 00072 00073 //! joins a list of strings using "pattern" as glue 00074 string join(const vector< string >& ls, const string pattern=","); 00075 00076 //! A function that lower-cases strings 00077 string tolower(const string& s); 00078 00079 //! i copies of a string x pasted together 00080 string operator*(int i, const string x); 00081 00082 //! center a string in a field of a certain length 00083 string center(const string stuff, int len); 00084 00085 //! left justify a string in a field of a certain length 00086 string ljust(const string stuff, int len); 00087 00088 //! right justify a string in a field of a certain length 00089 string rjust(const string stuff, int len); 00090 00091 #endif 00092