Logo Search packages:      
Sourcecode: jaula version File versions

jaula_value_boolean.cc

/*
 * jaula_value_boolean.cc : JSON Analysis User Library Acronym
 * JSON boolean values definitions
 *
 * Copyright (C) 2007, 2008 Kombo Morongo <morongo666@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 *
 * svn info:
 * $Author: morongo $
 * $HeadURL: https://jaula.svn.sourceforge.net/svnroot/jaula/tags/jaula-1.3.0-1/jaula/jaula_value_boolean.cc $
 * $Id: jaula_value_boolean.cc 38 2008-07-05 12:00:37Z morongo $
 * $Revision: 38 $
 */

extern "C"
{
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
}


#include <jaula/jaula_value_boolean.h>

namespace JAULA
{                                // namespace JAULA

00042   Value_Boolean::Value_Boolean(bool data)
    : Value(TYPE_BOOLEAN)
    , data_(data)
    {}

00047   Value_Boolean::~Value_Boolean()
    {}

00050   bool Value_Boolean::getData(void) const
  {
    return data_;
  }

00055   void Value_Boolean::repr(std::ostream &ostr) const
  {
    if (data_)
      ostr << "true";
    else
      ostr << "false";
  }

00063   void Value_Boolean::set(bool data)
  {
    data_ = data;
  }

00068   void Value_Boolean::set(Value const &origin) throw(Bad_Data_Type)
  {
    try
    {
      Value::set(origin);
      Value_Boolean const *pOrg =
        dynamic_cast<Value_Boolean const *>(&origin);
      if (!pOrg)
        throw Bad_Data_Type("Origin and Destination types do not match"
          , "narrowing origin to destination type");
      data_ = pOrg->getData();
    }
    catch(Bad_Data_Type &ex)
    {
      ex.addOrigin("Value_Boolean::set(Value const &)");
      throw ex;
    }
  }

}                                // namespace JAULA


// EOF $Id: jaula_value_boolean.cc 38 2008-07-05 12:00:37Z morongo $

Generated by  Doxygen 1.6.0   Back to index