Giter Club home page Giter Club logo

marshalfx's Introduction

Extensions for the Visual Studio C++/CLI marshaling framework

This project provides an alternative entry point for marshaling C++/CLI types to C++ types and the other way around. It specifically adds support for marshaling STL and CLR collections, such as std::vector and System::Collections::Generic::Dictionary. Nested collections are also supported (e.g. std::map<std::string, std::vector<int>>).

This is a header-only library. You need the marshal_fx.h and marshal_fx_details.h header files to use the library. The rest of the code are tests and cruft required by the Visual Studio project system.

Usage examples (also see the unit tests for more examples):

#include "marshal_fx.h"

auto num = marshal_fx::marshal_as<int>(42); // useless but supported
auto str = marshal_fx::marshal_as<std::string>(gcnew System::String("string"));

namespace SCG = System::Collections::Generic;

auto list = marshal_fx::marshal_as<SCG::List<int>^>(std::vector<int>{ 1, 2, 3 });
auto vect = marshal_fx::marshal_as<std::vector<int>>(list);

auto dictionary = marshal_fx::marshal_as<SCG::Dictionary<System::String^, int>^>(
	std::map<std::string, int>{ { "first", 1 }, { "second", 2 } }
);

To extend the library such that it works with your own custom types, DO NOT specialize the marshal_fx::marshal_as method. Instead, specialize the msclr::interop::marshal_as method, as per Microsoft instructions. Then, marshal_fx::marshal_as will pick up your customization and use it.

marshalfx's People

Contributors

goldshtn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.