List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
casadi::StringSerializer Class Reference

#include <serializer.hpp>

Detailed Description

Definition at line 173 of file serializer.hpp.

Inheritance diagram for casadi::StringSerializer:
Inheritance graph
[legend]

Public Types

enum  SerializationType {
  SERIALIZED_SPARSITY , SERIALIZED_MX , SERIALIZED_DM , SERIALIZED_SX ,
  SERIALIZED_LINSOL , SERIALIZED_FUNCTION , SERIALIZED_GENERICTYPE , SERIALIZED_INT ,
  SERIALIZED_DOUBLE , SERIALIZED_STRING , SERIALIZED_SPARSITY_VECTOR , SERIALIZED_MX_VECTOR ,
  SERIALIZED_DM_VECTOR , SERIALIZED_SX_VECTOR , SERIALIZED_LINSOL_VECTOR , SERIALIZED_FUNCTION_VECTOR ,
  SERIALIZED_GENERICTYPE_VECTOR , SERIALIZED_INT_VECTOR , SERIALIZED_DOUBLE_VECTOR , SERIALIZED_STRING_VECTOR
}
 

Public Member Functions

 StringSerializer (const Dict &opts=Dict())
 Advanced serialization of CasADi objects. More...
 
 ~StringSerializer ()
 
std::string encode ()
 Returns a string that holds the serialized objects. More...
 
void pack (const Sparsity &e)
 
void pack (const MX &e)
 
void pack (const Matrix< double > &e)
 
void pack (const Matrix< SXElem > &e)
 
void pack (const Linsol &e)
 
void pack (const Function &e)
 
void pack (const GenericType &e)
 
void pack (const casadi_int &e)
 
void pack (const double &e)
 
void pack (const std::string &e)
 
void pack (const std::vector< Sparsity > &e)
 
void pack (const std::vector< MX > &e)
 
void pack (const std::vector< Matrix< double > > &e)
 
void pack (const std::vector< Matrix< SXElem > > &e)
 
void pack (const std::vector< Linsol > &e)
 
void pack (const std::vector< Function > &e)
 
void pack (const std::vector< GenericType > &e)
 
void pack (const std::vector< casadi_int > &e)
 
void pack (const std::vector< double > &e)
 
void pack (const std::vector< std::string > &e)
 
void connect (DeserializerBase &s)
 
void reset ()
 

Static Public Member Functions

static std::string type_to_string (SerializationType type)
 

Protected Member Functions

SerializingStreamserializer ()
 

Protected Attributes

std::unique_ptr< std::ostream > sstream_
 
std::unique_ptr< SerializingStreamserializer_
 

Member Enumeration Documentation

◆ SerializationType

Enumerator
SERIALIZED_SPARSITY 
SERIALIZED_MX 
SERIALIZED_DM 
SERIALIZED_SX 
SERIALIZED_LINSOL 
SERIALIZED_FUNCTION 
SERIALIZED_GENERICTYPE 
SERIALIZED_INT 
SERIALIZED_DOUBLE 
SERIALIZED_STRING 
SERIALIZED_SPARSITY_VECTOR 
SERIALIZED_MX_VECTOR 
SERIALIZED_DM_VECTOR 
SERIALIZED_SX_VECTOR 
SERIALIZED_LINSOL_VECTOR 
SERIALIZED_FUNCTION_VECTOR 
SERIALIZED_GENERICTYPE_VECTOR 
SERIALIZED_INT_VECTOR 
SERIALIZED_DOUBLE_VECTOR 
SERIALIZED_STRING_VECTOR 

Definition at line 78 of file serializer.hpp.

Constructor & Destructor Documentation

◆ StringSerializer()

casadi::StringSerializer::StringSerializer ( const Dict opts = Dict())

This class is intended for advanced users that want to circumvent the restrictions of standard pickling/matlab save load, ie no raw SX/MX symbols allowed.

x = SX.sym('x');
s = StringSerializer();
s.pack(x);
s.pack(sin(x));
 
data = s.encode();

s = StringDeserializer(data);
a = s.unpack();
b = s.unpack();

Note: Saving SX/MX objects individually has a substantial overhead (both time and length of encoded string). You are encouraged to use the vector/list variants of 'save' for SX/MX to reduce the overhead.

See also
Function::save, Function::serialize, StringDeserializer, FileSerializer

Extra doc: https://github.com/casadi/casadi/wiki/L_7o

◆ ~StringSerializer()

casadi::StringSerializer::~StringSerializer ( )

Member Function Documentation

◆ connect()

void casadi::SerializerBase::connect ( DeserializerBase s)
inherited

◆ encode()

std::string casadi::StringSerializer::encode ( )

As a side effect, this method clears the internal buffer

Extra doc: https://github.com/casadi/casadi/wiki/L_7p

◆ pack() [1/20]

void casadi::SerializerBase::pack ( const casadi_int &  e)
inherited

◆ pack() [2/20]

void casadi::SerializerBase::pack ( const double &  e)
inherited

◆ pack() [3/20]

void casadi::SerializerBase::pack ( const Function e)
inherited

◆ pack() [4/20]

void casadi::SerializerBase::pack ( const GenericType e)
inherited

◆ pack() [5/20]

void casadi::SerializerBase::pack ( const Linsol e)
inherited

◆ pack() [6/20]

void casadi::SerializerBase::pack ( const Matrix< double > &  e)
inherited

◆ pack() [7/20]

void casadi::SerializerBase::pack ( const Matrix< SXElem > &  e)
inherited

◆ pack() [8/20]

void casadi::SerializerBase::pack ( const MX e)
inherited

◆ pack() [9/20]

void casadi::SerializerBase::pack ( const Sparsity e)
inherited

◆ pack() [10/20]

void casadi::SerializerBase::pack ( const std::string &  e)
inherited

◆ pack() [11/20]

void casadi::SerializerBase::pack ( const std::vector< casadi_int > &  e)
inherited

◆ pack() [12/20]

void casadi::SerializerBase::pack ( const std::vector< double > &  e)
inherited

◆ pack() [13/20]

void casadi::SerializerBase::pack ( const std::vector< Function > &  e)
inherited

◆ pack() [14/20]

void casadi::SerializerBase::pack ( const std::vector< GenericType > &  e)
inherited

◆ pack() [15/20]

void casadi::SerializerBase::pack ( const std::vector< Linsol > &  e)
inherited

◆ pack() [16/20]

void casadi::SerializerBase::pack ( const std::vector< Matrix< double > > &  e)
inherited

◆ pack() [17/20]

void casadi::SerializerBase::pack ( const std::vector< Matrix< SXElem > > &  e)
inherited

◆ pack() [18/20]

void casadi::SerializerBase::pack ( const std::vector< MX > &  e)
inherited

◆ pack() [19/20]

void casadi::SerializerBase::pack ( const std::vector< Sparsity > &  e)
inherited

◆ pack() [20/20]

void casadi::SerializerBase::pack ( const std::vector< std::string > &  e)
inherited

◆ reset()

void casadi::SerializerBase::reset ( )
inherited

◆ serializer()

SerializingStream& casadi::SerializerBase::serializer ( )
protectedinherited

◆ type_to_string()

static std::string casadi::SerializerBase::type_to_string ( SerializationType  type)
staticinherited

Member Data Documentation

◆ serializer_

std::unique_ptr<SerializingStream> casadi::SerializerBase::serializer_
protectedinherited

Definition at line 109 of file serializer.hpp.

◆ sstream_

std::unique_ptr<std::ostream> casadi::SerializerBase::sstream_
protectedinherited

Definition at line 108 of file serializer.hpp.


The documentation for this class was generated from the following file: