Skip to content

Instantly share code, notes, and snippets.

@vadz
Created March 4, 2019 13:39
Show Gist options
  • Save vadz/1d7a7c1be4f55fe45b46ea06454349e1 to your computer and use it in GitHub Desktop.
Save vadz/1d7a7c1be4f55fe45b46ea06454349e1 to your computer and use it in GitHub Desktop.
Main optional.i file
%{
#include "optionalvalue.h"
%}
// Provide simplified declarations of various template classes we use for SWIG.
template <typename T>
class OptionalValue
{
public:
OptionalValue();
OptionalValue(const T& value);
OptionalValue(const OptionalValue& other);
OptionalValue& operator=(const OptionalValue& other);
bool IsValid() const;
const T& Get() const;
};
#if defined(SWIGCSHARP)
%include "csharp/optional.i"
#elif defined(SWIGJAVA)
%include "java/optional.i"
#elif defined(SWIGPYTHON)
%include "python/optional.i"
#else
#error "No OptionalValue<> typemaps for this language."
#endif
// If there is no language-specific DEFINE_OPTIONAL_CLASS() definition, assume
// that we only have "simple" optional values.
#ifndef DEFINE_OPTIONAL_CLASS
%define DEFINE_OPTIONAL_CLASS(scope, classname)
DEFINE_OPTIONAL_SIMPLE(Optional ## classname, scope::classname)
%enddef
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment