math_bits.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : mathematical operations group                                     *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include "math_bits.h"
00016 
00017 #include <basis/astring.h>
00018 
00019 using namespace basis;
00020 
00021 namespace geometric {
00022 
00023 astring crop_numeric(const astring &input)
00024 {
00025   astring to_return(input);
00026   for (int i = 0; i < to_return.length(); i++)
00027     if ( ( (to_return[i] >= '0') && (to_return[i] <= '9') )
00028          || (to_return[i] == '.')
00029          || (to_return[i] == '+') || (to_return[i] == '-')
00030          || (to_return[i] == 'E') || (to_return[i] == 'e') ) {
00031       to_return.zap(i, i);  // remove non-useful character.
00032       i--;  // move backwards in loop.
00033     } else break;
00034   return to_return;
00035 }
00036 
00037 astring crop_non_numeric(const astring &input)
00038 {
00039   astring to_return(input);
00040   for (int i = 0; i < to_return.length(); i++)
00041     if ( ! ((to_return[i] >= '0') && (to_return[i] <= '9'))
00042          && (to_return[i] != '.')
00043          && (to_return[i] != '+') && (to_return[i] != '-')
00044          && (to_return[i] != 'E') && (to_return[i] != 'e') ) {
00045       to_return.zap(i, i);  // remove non-useful character.
00046       i--;  // move backwards in loop.
00047     } else break;
00048   return to_return;
00049 }
00050 
00051 }
00052 
Generated on Sat Jan 28 04:22:41 2012 for hoople2 project by  doxygen 1.6.3