/*@@@**************************************************************************
* \file  stringop
* \author Hernan Badino
* \date  Mon Apr 27 14:06:43 EDT 2009
* \notes 
*******************************************************************************
******************************************************************************/

/* INCLUDES */
#include "stringOp.h"

using namespace VIC;

CStringOp::CStringOp ( )
{}

CStringOp::~CStringOp ( )
{}


bool 
CStringOp::trimLeft ( std::string &fr_str )
{
    unsigned int i;
        
    for ( i = 0; 
          ( i < fr_str.length() && 
            isspace(fr_str[i]) );
          ++i) { }
    
        
    if (i)
    {
        std::string newStr = fr_str.substr( i );
        fr_str = newStr;
    }
        
    return true;
}

bool 
CStringOp::trimRight ( std::string &fr_str )
{
    int i;
    
    for ( i = fr_str.length() - 1; 
          ( i >= 0 && 
            isspace(fr_str[i]) );
          --i) {}

    if ( i < (int)fr_str.length() - 1 )
    {
        std::string newStr = fr_str.substr( 0, i + 1 );
        fr_str = newStr;
    }
    
    return true;
}

bool 
CStringOp::trim ( std::string &fr_str )
{
    bool res1_b;
    bool res2_b;
    
    res1_b = trimLeft  ( fr_str );
    res2_b = trimRight ( fr_str );

    return res1_b && res2_b;
}

/* ////////////  Version History ///////////////
 *  $Log: stringOp.cpp,v $
 *  Revision 1.2  2009/11/18 15:50:14  badino
 *  badino: global changes.
 *
 *//////////////////////////////////////////////
