-// Copyright (C) 2006-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
_value._s=new StringOnHeap(val);
}
+AtomAny::AtomAny(const std::string& val, TypeCode* type):Any(type)
+{
+ _value._s=new StringOnHeap(val);
+}
+
AtomAny::AtomAny(const AtomAny& other):Any(other)
{
- if(_type->isA(Runtime::_tc_string))
+ if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
{
StringOnHeap *cpy=(other._value._s)->deepCopy();
memcpy(&_value._s,&cpy,_type->getSizeInByteOfAnyReprInSeq());
AtomAny::AtomAny(char *data, TypeCode* type):Any(type)
{
- if(type->isA(Runtime::_tc_string))
+ if(type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
{
void **tmp=(void **)data;
StringOnHeap *cpy=((StringOnHeap *)(*tmp))->deepCopy();
return new AtomAny(val,dealloc);
}
-AnyPtr AtomAny::operator[](int i) const throw(YACS::Exception)
+AtomAny *AtomAny::New(const std::string& val, TypeCode *type)
+{
+ return new AtomAny(val,type);
+}
+
+AnyPtr AtomAny::operator[](int i) const
{
throw InvalidExtractionException(_type->kind(),Sequence);
}
-AnyPtr AtomAny::operator[](const char *key) const throw(YACS::Exception)
+AnyPtr AtomAny::operator[](const char *key) const
{
throw Exception("AtomAny::operator[] : try to get a part of a partitionned data whereas atomical.");
}
return _value._i==otherC._value._i;
else if(_type->isA(Runtime::_tc_bool))
return _value._b==otherC._value._b;
- else if(_type->isA(Runtime::_tc_string))
+ else if(_type->isA(Runtime::_tc_string) || _type->kind()==Objref)
return (*_value._s)==*(otherC._value._s);
else
return false;
}
-int AtomAny::getIntValue() const throw(YACS::Exception)
+int AtomAny::getIntValue() const
{
if(_type->isA(Runtime::_tc_int))
return _value._i;
throw Exception("Value is not an int");
}
-bool AtomAny::getBoolValue() const throw(YACS::Exception)
+bool AtomAny::getBoolValue() const
{
if(_type->isA(Runtime::_tc_bool))
return _value._b;
throw Exception("Value is not a bool");
}
-double AtomAny::getDoubleValue() const throw(YACS::Exception)
+double AtomAny::getDoubleValue() const
{
if(_type->isA(Runtime::_tc_double))
return _value._d;
throw Exception("Value is not a double");
}
-std::string AtomAny::getStringValue() const throw(YACS::Exception)
+std::string AtomAny::getStringValue() const
{
- if(_type->isA(Runtime::_tc_string))
+ if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
{
std::size_t sz(_value._s->size());
if(sz==0)
const char *AtomAny::getBytesValue(std::size_t& len) const
{
- if(_type->isA(Runtime::_tc_string))
+ if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
{
len=_value._s->size();
return _value._s->cStr();
*/
void AtomAny::putMyReprAtPlace(char *data) const
{
- if(_type->isA(Runtime::_tc_string))
+ if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
{
StringOnHeap *tmp=_value._s->deepCopy();
memcpy(data,&tmp,_type->getSizeInByteOfAnyReprInSeq());
*/
void AtomAny::putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy)
{
- if(type->isA(Runtime::_tc_string))
+ if(type->isA(Runtime::_tc_string) || type->kind()==YACS::ENGINE::Objref)
{
void **tmp1=(void **)src;
StringOnHeap *tmp=((const StringOnHeap *)(*tmp1))->deepCopy();
void AtomAny::destroyReprAtPlace(char *data, const TypeCode *type)
{
DynType typ=type->kind();
- if(typ==String)
+ if(typ==String || typ==Objref)
{
if(!Any::IsNull(data))
{
AtomAny::~AtomAny()
{
- if(_type->kind() == String)
+ if(_type->kind() == String || _type->kind()==Objref)
delete _value._s;
}
_type->decrRef();
}
-AnyPtr ComposedAny::operator[](const char *key) const throw(YACS::Exception)
+AnyPtr ComposedAny::operator[](const char *key) const
{
throw Exception("AtomAny::operator[] : try to get a part of a partitionned data not localizable by a string.");
}
-void ComposedAny::checkTypeOf(const Any *elem) const throw(YACS::Exception)
+void ComposedAny::checkTypeOf(const Any *elem) const
{
if(!elem->getType()->isA(_type->contentType()))
throw Exception("ComposedAny::checkTypeOf : invalid type.");
}
-int ComposedAny::getIntValue() const throw(YACS::Exception)
+int ComposedAny::getIntValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_int->kind());
}
-bool ComposedAny::getBoolValue() const throw(YACS::Exception)
+bool ComposedAny::getBoolValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_bool->kind());
}
-double ComposedAny::getDoubleValue() const throw(YACS::Exception)
+double ComposedAny::getDoubleValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_double->kind());
}
-std::string ComposedAny::getStringValue() const throw(YACS::Exception)
+std::string ComposedAny::getStringValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_string->kind());
}
return true;
}
-void SequenceAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
+void SequenceAny::setEltAtRank(int i, const Any *elem)
{
checkTypeOf(elem);
_alloc.destroy(_alloc._start+i*_alloc._sizeOf1Elm,_type->contentType());
_alloc.construct(_alloc._start+i*_alloc._sizeOf1Elm,elem);
}
-AnyPtr SequenceAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr SequenceAny::operator[](int i) const
{
return _type->contentType()->getOrBuildAnyFromZippedData(_alloc._start+i*_alloc._sizeOf1Elm);
}
SequenceAny *SequenceAny::New(const TypeCode *typeOfContent)
{
- if(typeOfContent->kind() == Objref)
- {
- //In case of Objref, use a sequence of string
- return new SequenceAny(Runtime::_tc_string);
- }
- else
return new SequenceAny(typeOfContent);
}
SequenceAny *SequenceAny::New(const TypeCode *typeOfContent, unsigned lgth)
{
- if(typeOfContent->kind() == Objref)
- {
- //In case of Objref, use a sequence of string
- return new SequenceAny(Runtime::_tc_string,lgth);
- }
- else
return new SequenceAny(typeOfContent,lgth);
}
}
}
-void ArrayAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
+void ArrayAny::setEltAtRank(int i, const Any *elem)
{
checkTypeOf(elem);
const TypeCode *subType=_type->contentType();
return true;
}
-AnyPtr ArrayAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr ArrayAny::operator[](int i) const
{
const TypeCode *subType=_type->contentType();
unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
return true;
}
-AnyPtr StructAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr StructAny::operator[](int i) const
{
const char what[]="StructAny::operator[](int i) : Struct key are strings not integers.";
throw Exception(what);
}
-AnyPtr StructAny::operator[](const char *key) const throw(YACS::Exception)
+AnyPtr StructAny::operator[](const char *key) const
{
const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
char *whereToGet=_data;
return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
}
-void StructAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
+void StructAny::setEltAtRank(int i, const Any *elem)
{
const char what[]="Struct key are strings not integers.";
throw Exception(what);
}
-void StructAny::setEltAtRank(const char *key, const Any *elem) throw(YACS::Exception)
+void StructAny::setEltAtRank(const char *key, const Any *elem)
{
const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
unsigned offset;