topical media & game development

talk show tell print

professional-program-10-PolymorphicSpreadsheet-DoubleSpreadsheetCell.c

? / professional-program-10-PolymorphicSpreadsheet-DoubleSpreadsheetCell.c


  include <iostream>
  include <sstream>
  
  include <DoubleSpreadsheetCell.h>
  
  using namespace std;
  
  DoubleSpreadsheetCell::DoubleSpreadsheetCell() : mValue(-1)
  { 
  }
  
  void DoubleSpreadsheetCell::set(double inDouble)
  {
    mValue = inDouble;
  }
  
  void DoubleSpreadsheetCell::set(string inString)
  {
    mValue = stringToDouble(inString);
  }
  
  string DoubleSpreadsheetCell::getString() const
  {
    return doubleToString(mValue);
  }
  
  string DoubleSpreadsheetCell::doubleToString(double inValue)
  {
    ostringstream ostr;
  
    ostr << inValue;
    return (ostr.str());
  }
  
  double DoubleSpreadsheetCell::stringToDouble(string inString)
  {
    double temp;
  
    istringstream istr(inString);
  
    istr >> temp;
    if (istr.fail() || !istr.eof()) {
      return (0);
    }
    return (temp);
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.