LCOV - code coverage report
Current view: top level - alma/Enumerations - CFieldCode.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 49 0.0 %
Date: 2024-12-11 20:54:31 Functions: 0 12 0.0 %

          Line data    Source code
       1             : 
       2             : /*
       3             :  * ALMA - Atacama Large Millimeter Array
       4             :  * (c) European Southern Observatory, 2002
       5             :  * (c) Associated Universities Inc., 2002
       6             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       7             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       8             :  * All rights reserved.
       9             :  * 
      10             :  * This library is free software; you can redistribute it and/or
      11             :  * modify it under the terms of the GNU Lesser General Public
      12             :  * License as published by the Free software Foundation; either
      13             :  * version 2.1 of the License, or (at your option) any later version.
      14             :  * 
      15             :  * This library is distributed in the hope that it will be useful,
      16             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :  * Lesser General Public License for more details.
      19             :  * 
      20             :  * You should have received a copy of the GNU Lesser General Public
      21             :  * License along with this library; if not, write to the Free Software
      22             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      23             :  * MA 02111-1307  USA
      24             :  * 
      25             :  * /////////////////////////////////////////////////////////////////
      26             :  * // WARNING!  DO NOT MODIFY THIS FILE!                          //
      27             :  * //  ---------------------------------------------------------  //
      28             :  * // | This is generated code!  Do not modify this file.       | //
      29             :  * // | Any changes will be lost when the file is re-generated. | //
      30             :  * //  ---------------------------------------------------------  //
      31             :  * /////////////////////////////////////////////////////////////////
      32             :  *
      33             :  * File CFieldCode.cpp
      34             :  */
      35             : #include <sstream>
      36             : #include <alma/Enumerations/CFieldCode.h>
      37             : #include <string>
      38             : using namespace std;
      39             : 
      40           0 : int CFieldCode::version() {
      41           0 :         return FieldCodeMod::version;
      42             :         }
      43             :         
      44           0 : string CFieldCode::revision () {
      45           0 :         return FieldCodeMod::revision;
      46             : }
      47             : 
      48           0 : unsigned int CFieldCode::size() {
      49           0 :         return 1;
      50             :         }
      51             :         
      52             :         
      53             : const std::string& CFieldCode::sNONE = "NONE";
      54             :         
      55           0 : const std::vector<std::string> CFieldCode::names() {
      56           0 :     std::vector<std::string> enumSet;
      57             :     
      58           0 :     enumSet.insert(enumSet.end(), CFieldCode::sNONE);
      59             :         
      60           0 :     return enumSet;
      61           0 : }
      62             : 
      63           0 : std::string CFieldCode::name(const FieldCodeMod::FieldCode& f) {
      64           0 :     switch (f) {
      65             :     
      66           0 :     case FieldCodeMod::NONE:
      67           0 :       return CFieldCode::sNONE;
      68             :         
      69             :     }
      70             :     // Impossible siutation but....who knows with C++ enums
      71           0 :     throw badInt((int) f);
      72             : }
      73             : 
      74           0 : FieldCodeMod::FieldCode CFieldCode::newFieldCode(const std::string& name) {
      75             :                 
      76           0 :     if (name == CFieldCode::sNONE) {
      77           0 :         return FieldCodeMod::NONE;
      78             :     }
      79             :     
      80           0 :     throw badString(name);
      81             : }
      82             : 
      83           0 : FieldCodeMod::FieldCode CFieldCode::literal(const std::string& name) {
      84             :                 
      85           0 :     if (name == CFieldCode::sNONE) {
      86           0 :         return FieldCodeMod::NONE;
      87             :     }
      88             :     
      89           0 :     throw badString(name);
      90             : }
      91             : 
      92           0 : FieldCodeMod::FieldCode CFieldCode::from_int(unsigned int i) {
      93           0 :         vector<string> names_ = names();
      94           0 :         if (i >= names_.size()) throw badInt(i);
      95           0 :         return newFieldCode(names_.at(i));
      96           0 : }
      97             : 
      98           0 : string CFieldCode::badString(const string& name) {
      99           0 :         return "'"+name+"' does not correspond to any literal in the enumeration 'FieldCode'.";
     100             : }
     101             : 
     102           0 : string CFieldCode::badInt(unsigned int i) {
     103           0 :         ostringstream oss ;
     104           0 :         oss << "'" << i << "' is out of range for the enumeration 'FieldCode'.";
     105           0 :         return oss.str();
     106           0 : }
     107             : 
     108             : namespace FieldCodeMod {
     109           0 :         std::ostream & operator << ( std::ostream & out, const FieldCode& value) {
     110           0 :                 out << CFieldCode::name(value);
     111           0 :                 return out;
     112             :         }
     113             : 
     114           0 :         std::istream & operator >> ( std::istream & in , FieldCode& value ) {
     115           0 :                 in.clear();
     116           0 :                 string s ; 
     117           0 :                 in >> s;
     118             :                 try {
     119           0 :                 value = CFieldCode::literal(s);
     120             :                 }
     121           0 :                 catch (string & m) {
     122           0 :                 in.setstate(ios::failbit);
     123           0 :                 }
     124           0 :                 return in;
     125           0 :         }
     126             : }
     127             : 

Generated by: LCOV version 1.16