Salome HOME
WIP
[modules/yacs.git] / src / engine / Any.hxx
old mode 100755 (executable)
new mode 100644 (file)
index cc9a51c..f8d1e67
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -42,6 +42,12 @@ namespace YACS
     class TypeCodeStruct;
     typedef void (*Deallocator)(void *);
 
+#ifndef SWIG
+    YACSLIBENGINE_EXPORT std::string ToBase64(const std::string& bytes);
+    YACSLIBENGINE_EXPORT std::string FromBase64(const std::string& bytes);
+    YACSLIBENGINE_EXPORT std::string FromBase64Safe(const std::string& bytes);
+#endif
+    
     class YACSLIBENGINE_EXPORT StringOnHeap
     {
       friend class Any;
@@ -49,14 +55,17 @@ namespace YACS
       friend class ArrayAny;
     private:
       StringOnHeap(const char *val);
+      StringOnHeap(const char *val, std::size_t len);
       StringOnHeap(const std::string& val);
       StringOnHeap(char *val, Deallocator deAlloc);
       bool operator ==(const StringOnHeap& other) const;
       StringOnHeap *deepCopy() const;
       const char *cStr() const { return _str; }
+      std::size_t size() const { return _len; }
       ~StringOnHeap();
     private:
       char *_str;
+      std::size_t _len;
       Deallocator _dealloc;
     };
 
@@ -91,7 +100,8 @@ namespace YACS
       Any(TypeCode* type);
       Any(const Any& other);
       virtual void putMyReprAtPlace(char *data) const = 0;
-      static AnyPtr buildAnyFromCoarseData(char *data, TypeCode* type); //Factory Method
+      //static AnyPtr buildAnyFromCoarseData(char *data, TypeCode* type); //Factory Method
+      static bool IsNull(char *data);
     protected:
       TypeCode* _type;
     };
@@ -101,6 +111,7 @@ namespace YACS
     class YACSLIBENGINE_EXPORT AtomAny : public Any
     {
       friend class TypeCode;
+      friend class TypeCodeObjref;
 
       union ValueContainer
       {
@@ -114,6 +125,7 @@ namespace YACS
       template<class T>
       static AtomAny *New(T val) { return new AtomAny(val); }
       static AtomAny *New(char *val, Deallocator dealloc);
+      static AtomAny *New(const std::string& val, TypeCode *type);
       AnyPtr operator[](int i) const throw(Exception);
       AnyPtr operator[](const char *key) const throw(Exception);
       bool operator ==(const Any& other) const;
@@ -121,6 +133,7 @@ namespace YACS
       bool getBoolValue() const throw(Exception);
       double getDoubleValue() const throw(Exception);
       std::string getStringValue() const throw(Exception);
+      const char *getBytesValue(std::size_t& len) const;
     protected:
       void putMyReprAtPlace(char *data) const;
       static void putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy);
@@ -134,6 +147,7 @@ namespace YACS
       AtomAny(double val);
       AtomAny(const char *val);
       AtomAny(const std::string& val);
+      AtomAny(const std::string& val, TypeCode* type);
       AtomAny(const AtomAny& other);
       AtomAny(char *data, TypeCode* type);
       AtomAny(char *val, Deallocator deAlloc);
@@ -162,6 +176,9 @@ namespace YACS
       void destroy(char *pt, const TypeCode *tc);
       void deallocate(char *pt);
       unsigned int size() const;
+      std::vector<unsigned int> getSetItems() const;
+    public:
+      static const char DFT_CHAR_VAR;
     };
     
     class YACSLIBENGINE_EXPORT ComposedAny : public Any
@@ -201,6 +218,8 @@ namespace YACS
       static SequenceAny *New(const TypeCode *typeOfContent, unsigned lgth);
       template<class T>
       static SequenceAny *New(T *val, unsigned int lgth, Deallocator deAlloc);
+      std::vector<unsigned int> getSetItems() const { return _alloc.getSetItems(); }
+      SequenceAny *removeUnsetItemsFromThis() const;
     protected:
       void putMyReprAtPlace(char *data) const;
       static void putReprAtPlace(char *data, const char *src, const TypeCode *type, bool deepCpy);