Logo Search packages:      
Sourcecode: condor version File versions  Download package

value.cpp

/***************************************************************
 *
 * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
 * University of Wisconsin-Madison, WI.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You may
 * obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************/

#include "condor_common.h"
#include "value.h"


Value::
Value()
{
      valueType = UNDEFINED_VALUE;
      integerValue = 0;
      realValue = 0.0;
      strValue = NULL;
}


Value::
~Value()
{
}


const Value& Value::
operator=( const Value& val )
{
      valueType = val.valueType;
      integerValue = val.integerValue;
      realValue = val.realValue;
      strValue = val.strValue;
      return( *this );
}


void Value::
clear()
{
      valueType = UNDEFINED_VALUE;
}


bool Value::
isNumber (int &i)
{
      switch (valueType)
      {
            case INTEGER_VALUE:
                  i = integerValue;
                  return true;

            case REAL_VALUE:
                  i = (int) realValue;    // truncation     
                  return true;

            default:
                  return false;
      }
}


bool Value::
isNumber (double &r)
{
      switch (valueType)
      {
            case INTEGER_VALUE:
                  r = (double) integerValue;
                  return true;

            case REAL_VALUE:
                  r = realValue;    
                  return true;

            default:
                  return false;
      }
}


void Value::
setRealValue (double r)
{
    clear();
    valueType=REAL_VALUE;
    realValue = r;
}

void Value::
setIntegerValue (int i)
{
    clear();
    valueType=INTEGER_VALUE;
    integerValue = i;
}

void Value::
setUndefinedValue (void)
{
    clear();
    valueType=UNDEFINED_VALUE;
}

void Value::
setErrorValue (void)
{
    clear();
    valueType=ERROR_VALUE;
}

void Value::
setStringValue(char *s)
{
    clear();
    valueType = STRING_VALUE;
    strValue = s;
}

Generated by  Doxygen 1.6.0   Back to index