inline void Serialiser::decode( std::string const &key, T * &value )
{
    Map::iterator pos = objectContext_->find( key );

    if( pos == objectContext_->end() )
	throw UnknownKeyException( key );

    Primitive &v = pos->second.get();
    Pointer &p = boost::get<Pointer>(v.value);
    int index = p.index;
    if( index == 0 )
	value = 0;
    else
    {
	ObjectCasterMap::iterator ociter = casters().find(p.type);
	if( ociter == casters().end() )
	    throw UnknownTypeException(p.type);

	BaseCasterMap::iterator bciter = ociter->second.find(
	    toast::type_id<T>().name() );
	if( bciter == ociter->second.end() )
	    throw UnknownCastException(p.type, toast::type_id<T>().name());

	IndexObjectMap::iterator diter = decodedPointers_.find(index);

	if( diter != decodedPointers_.end() )
	{
	    value = static_cast<T *>( bciter->second(diter->second) );
	}
	else
	{
	    ClassFactoryMap::iterator fiter = factories().find( p.type );
	    if( fiter == factories().end() )
		throw UnknownTypeException(p.type);

	    ObjectMap::iterator objIter = referencedValues_.find(index);
	    if( objIter == referencedValues_.end() )
		throw ObjectNotDecodedException(p.index);

	    Array *temp = arrayContext_;
	    Array context;
	    context.push_back( objIter->second );
	    void *obj = fiter->second();
	    arrayContext_ = &context;
	    value = static_cast<T *>( bciter->second(obj) );
	    decode( 0, *value );
	    arrayContext_ = temp;
	    decodedPointers_[index] = obj;
	}
    }
}
示例#2
0
Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
{
	if (useFilter && isFiltered() && !isAllowed(row))
		throw InvalidAccessException("Row not allowed");

	if (isNull(metaColumn(name).position(), row)) return Poco::Dynamic::Var();

	switch (columnType(name))
	{
	case MetaColumn::FDT_BOOL:      return value<bool>(name, row, useFilter);
	case MetaColumn::FDT_INT8:      return value<Int8>(name, row, useFilter);
	case MetaColumn::FDT_UINT8:     return value<UInt8>(name, row, useFilter);
	case MetaColumn::FDT_INT16:     return value<Int16>(name, row, useFilter);
	case MetaColumn::FDT_UINT16:    return value<UInt16>(name, row, useFilter);
	case MetaColumn::FDT_INT32:	    return value<Int32>(name, row, useFilter);
	case MetaColumn::FDT_UINT32:    return value<UInt32>(name, row, useFilter);
	case MetaColumn::FDT_INT64:     return value<Int64>(name, row, useFilter);
	case MetaColumn::FDT_UINT64:    return value<UInt64>(name, row, useFilter);
	case MetaColumn::FDT_FLOAT:     return value<float>(name, row, useFilter);
	case MetaColumn::FDT_DOUBLE:    return value<double>(name, row, useFilter);
	case MetaColumn::FDT_STRING:    return value<std::string>(name, row, useFilter);
	case MetaColumn::FDT_WSTRING:   return value<UTF16String>(name, row, useFilter);
	case MetaColumn::FDT_BLOB:      return value<BLOB>(name, row, useFilter);
	case MetaColumn::FDT_DATE:      return value<Date>(name, row, useFilter);
	case MetaColumn::FDT_TIME:      return value<Time>(name, row, useFilter);
	case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(name, row, useFilter);
	default:
		throw UnknownTypeException("Data type not supported.");
	}
}
示例#3
0
//**********************************************************************
// find the numeric form of type of expression from a text form
//**********************************************************************
void setType(Rule& r,
             const LimaString& s,
             const std::vector<LimaString>& activeEntityGroups) 
{
  LimaString str;
  //std::string::size_type i(findSpecialCharacter(s,CHAR_POS_TR,0));
  int i(findSpecialCharacter(s,CHAR_POS_TR,0));
  if (i != -1) { // there are linguistic properties
    r.setLinguisticProperties(static_cast<LinguisticCode>(s.mid(i+1).toInt()));
    str=s.left(i);
  }
  else {
    r.setLinguisticProperties(static_cast<LinguisticCode>(0));
    str=s;
  }

  Common::MediaticData::EntityType type=
    resolveEntityName(str,activeEntityGroups);
  if (type.isNull()) {
    std::ostringstream oss;
    oss << "type [" << str.toUtf8().data() << "] not recognized";
    throw UnknownTypeException(oss.str());
  }
  r.setType(type);
}
示例#4
0
/*
 * Create an instance of an aggregator for the specified aggregate
 * type, column type, and result type. The object is constructed in
 * memory from the provided memrory pool.
 */
Agg *GetAggInstance(ExpressionType agg_type) {
  Agg *aggregator;

  switch (agg_type) {
    case EXPRESSION_TYPE_AGGREGATE_COUNT:
      aggregator = new CountAgg();
      break;
    case EXPRESSION_TYPE_AGGREGATE_COUNT_STAR:
      aggregator = new CountStarAgg();
      break;
    case EXPRESSION_TYPE_AGGREGATE_SUM:
      aggregator = new SumAgg();
      break;
    case EXPRESSION_TYPE_AGGREGATE_AVG:
      aggregator = new AvgAgg(false);
      break;
    case EXPRESSION_TYPE_AGGREGATE_MIN:
      aggregator = new MinAgg();
      break;
    case EXPRESSION_TYPE_AGGREGATE_MAX:
      aggregator = new MaxAgg();
      break;
    default: {
      std::string message =
          "Unknown aggregate type " + std::to_string(agg_type);
      throw UnknownTypeException(agg_type, message);
    }
  }

  return aggregator;
}
inline void Serialiser::decode( std::string const &key,
    std::map<std::string, T> &value )
{
    Map *temp = objectContext_;
    Map::iterator pos = objectContext_->find( key );

    if( pos == objectContext_->end() )
	throw UnknownKeyException( key );

    Primitive &v = pos->second.get();
    objectContext_ = &boost::get<Map>( v.value );
    decodedPointers_[v.index] = &value;

    ClassFactoryMap::iterator fiter = factories().find( Codec<T>::classID() );
    if( fiter == factories().end() )
	throw UnknownTypeException(Codec<T>::classID());

    for( Map::iterator iter = objectContext_->begin();
	iter != objectContext_->end(); ++iter )
    {
	T *t = static_cast<T *>(fiter->second());
	decode( iter->first, *t );
	value.insert( std::make_pair(iter->first, *t) );
	delete t;
    }

    objectContext_ = temp;

}
示例#6
0
/*
 * Create an instance of an aggregator for the specified aggregate
 * type, column type, and result type. The object is constructed in
 * memory from the provided memrory pool.
 */
AbstractAttributeAggregator *GetAttributeAggregatorInstance(ExpressionType agg_type) {
  AbstractAttributeAggregator *aggregator;

  switch (agg_type) {
    case ExpressionType::AGGREGATE_COUNT:
      aggregator = new CountAggregator();
      break;
    case ExpressionType::AGGREGATE_COUNT_STAR:
      aggregator = new CountStarAggregator();
      break;
    case ExpressionType::AGGREGATE_SUM:
      aggregator = new SumAggregator();
      break;
    case ExpressionType::AGGREGATE_AVG:
      aggregator = new AvgAggregator(false);
      break;
    case ExpressionType::AGGREGATE_MIN:
      aggregator = new MinAggregator();
      break;
    case ExpressionType::AGGREGATE_MAX:
      aggregator = new MaxAggregator();
      break;
    default: {
      std::string message =
          "Unknown aggregate type " + ExpressionTypeToString(agg_type);
      throw UnknownTypeException(static_cast<int>(agg_type), message);
    }
  }

  return aggregator;
}
const char *
SkillerDebugInterface::enum_tostring(const char *enumtype, int val) const
{
  if (strcmp(enumtype, "GraphDirectionEnum") == 0) {
    return tostring_GraphDirectionEnum((GraphDirectionEnum)val);
  }
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
示例#8
0
const char *
KickerInterface::enum_tostring(const char *enumtype, int val) const
{
  if (strcmp(enumtype, "GuideBallSideEnum") == 0) {
    return tostring_GuideBallSideEnum((GuideBallSideEnum)val);
  }
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
const char *
SkillerInterface::enum_tostring(const char *enumtype, int val) const
{
  if (strcmp(enumtype, "SkillStatusEnum") == 0) {
    return tostring_SkillStatusEnum((SkillStatusEnum)val);
  }
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
示例#10
0
const char *
TestInterface::enum_tostring(const char *enumtype, int val) const
{
  if (strcmp(enumtype, "TestEnum") == 0) {
    return tostring_TestEnum((TestEnum)val);
  }
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
示例#11
0
/* =========== message create =========== */
Message *
LocalizationInterface::create_message(const char *type) const
{
  if ( strncmp("SetInitialPoseMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetInitialPoseMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
/* =========== message create =========== */
Message *
RobotinoSensorInterface::create_message(const char *type) const
{
  if ( strncmp("SetBumperEStopEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetBumperEStopEnabledMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
/* =========== message create =========== */
Message *
SpeechRecognitionInterface::create_message(const char *type) const
{
  if ( strncmp("ResetMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new ResetMessage();
  } else if ( strncmp("SetEnabledMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetEnabledMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#14
0
/* =========== message create =========== */
Message *
BatteryInterface::create_message(const char *type) const
{
  if ( strncmp("PushButtonMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new PushButtonMessage();
  } else if ( strncmp("SleepMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SleepMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#15
0
/* =========== message create =========== */
Message *
SkillerDebugInterface::create_message(const char *type) const
{
  if ( strncmp("SetGraphMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetGraphMessage();
  } else if ( strncmp("SetGraphDirectionMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetGraphDirectionMessage();
  } else if ( strncmp("SetGraphColoredMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetGraphColoredMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#16
0
/* =========== message create =========== */
Message *
TestInterface::create_message(const char *type) const
{
  if ( strncmp("SetTestIntMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetTestIntMessage();
  } else if ( strncmp("SetTestStringMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetTestStringMessage();
  } else if ( strncmp("CalculateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new CalculateMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#17
0
/* =========== message create =========== */
Message *
KickerInterface::create_message(const char *type) const
{
  if ( strncmp("KickMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new KickMessage();
  } else if ( strncmp("ResetCounterMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new ResetCounterMessage();
  } else if ( strncmp("GuideBallMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new GuideBallMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#18
0
/* =========== message create =========== */
Message *
SwitchInterface::create_message(const char *type) const
{
  if ( strncmp("SetMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new SetMessage();
  } else if ( strncmp("EnableSwitchMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new EnableSwitchMessage();
  } else if ( strncmp("DisableSwitchMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new DisableSwitchMessage();
  } else if ( strncmp("EnableDurationMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new EnableDurationMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#19
0
void AbstractBinder::bind(std::size_t pos, const DynamicAny& val, Direction dir)
{
	const std::type_info& type = val.type();

	if(type == typeid(Int32))
		bind(pos, val.extract<Int32>(), dir);
	else if(type == typeid(std::string))
		bind(pos, val.extract<std::string>(), dir);
	else if (type == typeid(bool))
		bind(pos, val.extract<bool>(), dir);
	else if(type == typeid(char))
		bind(pos, val.extract<char>(), dir);
	else if(type == typeid(Int8))
		bind(pos, val.extract<Int8>(), dir);
	else if(type == typeid(UInt8))
		bind(pos, val.extract<UInt8>(), dir);
	else if(type == typeid(Int16))
		bind(pos, val.extract<Int16>(), dir);
	else if(type == typeid(UInt16))
		bind(pos, val.extract<UInt16>(), dir);
	else if(type == typeid(UInt32))
		bind(pos, val.extract<UInt32>(), dir);
	else if(type == typeid(Int64))
		bind(pos, val.extract<Int64>(), dir);
	else if(type == typeid(UInt64))
		bind(pos, val.extract<UInt64>(), dir);
	else if(type == typeid(float))
		bind(pos, val.extract<float>(), dir);
	else if(type == typeid(double))
		bind(pos, val.extract<double>(), dir);
	else if(type == typeid(DateTime))
		bind(pos, val.extract<DateTime>(), dir);
	else if(type == typeid(Date))
		bind(pos, val.extract<Date>(), dir);
	else if(type == typeid(Time))
		bind(pos, val.extract<Time>(), dir);
	else if(type == typeid(BLOB))
		bind(pos, val.extract<BLOB>(), dir);
#ifndef POCO_LONG_IS_64_BIT
	else if(type == typeid(long))
		bind(pos, val.extract<long>(), dir);
#endif
	else
		throw UnknownTypeException(std::string(val.type().name()));
}
/* =========== message create =========== */
Message *
SkillerInterface::create_message(const char *type) const
{
  if ( strncmp("ExecSkillMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new ExecSkillMessage();
  } else if ( strncmp("ExecSkillContinuousMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new ExecSkillContinuousMessage();
  } else if ( strncmp("RestartInterpreterMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new RestartInterpreterMessage();
  } else if ( strncmp("StopExecMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new StopExecMessage();
  } else if ( strncmp("AcquireControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new AcquireControlMessage();
  } else if ( strncmp("ReleaseControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
    return new ReleaseControlMessage();
  } else {
    throw UnknownTypeException("The given type '%s' does not match any known "
                               "message type for this interface type.", type);
  }
}
示例#21
0
/**
 * Determine the maximum number of bytes when serialized for Export.
 * Excludes the bytes required by the row header (which includes
 * the null bit indicators) and ignores the width of metadata columns.
 */
size_t Tuple::ExportSerializationSize() const {
  size_t bytes = 0;
  int column_count = GetColumnCount();

  for (int column_itr = 0; column_itr < column_count; ++column_itr) {
    switch (GetType(column_itr)) {
      case common::Type::TINYINT:
      case common::Type::SMALLINT:
      case common::Type::INTEGER:
      case common::Type::BIGINT:
      case common::Type::TIMESTAMP:
      case common::Type::DECIMAL:
        // case common::Type::DOUBLE:
        bytes += sizeof(int64_t);
        break;

      // case common::Type::DECIMAL:
      // Decimals serialized in ascii as
      // 32 bits of length + max prec digits + radix pt + sign
      // bytes += sizeof(int32_t) + Value::kMaxDecPrec + 1 + 1;
      // break;

      case common::Type::VARCHAR:
      case common::Type::VARBINARY:
        // 32 bit length preceding value and
        // actual character data without null string terminator.
        if (!GetValue(column_itr)->IsNull()) {
          bytes += (sizeof(int32_t) +
                    ((common::VarlenValue *)GetValue(column_itr))->GetLength());
        }
        break;

      default:
        throw UnknownTypeException(
            GetType(column_itr),
            "Unknown ValueType found during Export serialization.");
        return (size_t)0;
    }
  }
  return bytes;
}
const char *
SpeechRecognitionInterface::enum_tostring(const char *enumtype, int val) const
{
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
const char *
Position2DTrackInterface::enum_tostring(const char *enumtype, int val) const
{
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
/* =========== message create =========== */
Message *
Position2DTrackInterface::create_message(const char *type) const
{
  throw UnknownTypeException("The given type '%s' does not match any known "
                             "message type for this interface type.", type);
}
示例#25
0
const char *
Laser720Interface::enum_tostring(const char *enumtype, int val) const
{
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
const char *
RobotinoSensorInterface::enum_tostring(const char *enumtype, int val) const
{
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
示例#27
0
 static TPtrBase onCreationOfUnknownType(const TTypeIdentifier& id) { throw UnknownTypeException(id); }
示例#28
0
/* =========== message create =========== */
Message *
HumanSkeletonProjectionInterface::create_message(const char *type) const
{
  throw UnknownTypeException("The given type '%s' does not match any known "
                             "message type for this interface type.", type);
}
示例#29
0
const char *
HumanSkeletonProjectionInterface::enum_tostring(const char *enumtype, int val) const
{
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}
const char *
LocalizerControlInterface::enum_tostring(const char *enumtype, int val) const
{
  throw UnknownTypeException("Unknown enum type %s", enumtype);
}