Line data Source code
1 : /* 2 : * ALMA - Atacama Large Millimeter Array 3 : * (c) European Southern Observatory, 2002 4 : * (c) Associated Universities Inc., 2002 5 : * Copyright by ESO (in the framework of the ALMA collaboration), 6 : * Copyright by AUI (in the framework of the ALMA collaboration), 7 : * All rights reserved. 8 : * 9 : * This library is free software; you can redistribute it and/or 10 : * modify it under the terms of the GNU Lesser General Public 11 : * License as published by the Free software Foundation; either 12 : * version 2.1 of the License, or (at your option) any later version. 13 : * 14 : * This library is distributed in the hope that it will be useful, 15 : * but WITHOUT ANY WARRANTY, without even the implied warranty of 16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 : * Lesser General Public License for more details. 18 : * 19 : * You should have received a copy of the GNU Lesser General Public 20 : * License along with this library; if not, write to the Free Software 21 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 : * MA 02111-1307 USA 23 : * 24 : * File Long.cpp 25 : */ 26 : 27 : #include <alma/ASDM/LongWrapper.h> 28 : #include <alma/ASDM/NumberFormatException.h> 29 : 30 : #include <sstream> 31 : 32 : #include <iostream> 33 : using namespace std; 34 : 35 : namespace asdm { 36 : 37 : const int64_t Long::MIN_VALUE = 0x8000000000000000LL; 38 : const int64_t Long::MAX_VALUE = 0x7fffffffffffffffLL; 39 : 40 279667 : int64_t Long::parseLong(const string &s) { 41 : // istringstream *in = new istringstream(s.c_str()); 42 279667 : istringstream in; 43 279667 : in.str(s.c_str()); 44 : int64_t x; 45 : // (*in) >> x; 46 279667 : in >> x; 47 : // if (in->rdstate() == istream::failbit) 48 279667 : if (in.rdstate() == istream::failbit) 49 0 : throw NumberFormatException (s); 50 : // delete in; 51 559334 : return x; 52 : } 53 : 54 7716 : string Long::toString(int64_t x) { 55 15432 : ostringstream out ; 56 7716 : out.width(35); 57 7716 : out.precision(25); 58 7716 : out << x; 59 15432 : string s = out.str(); 60 7716 : int i = 0; 61 159214 : while (i < 35 && s.at(i) == ' ') 62 151498 : ++i; 63 15432 : return s.substr(i,s.length() - i); 64 : } 65 : 66 : } // End namespace.