GithubHelp home page GithubHelp logo

bitcoinclassic / cmf-bindings Goto Github PK

View Code? Open in Web Editor NEW
4.0 5.0 4.0 55 KB

Language Bindings for the Compact Message Format

C# 13.77% C++ 52.20% QMake 0.34% Java 14.84% Python 9.20% CMake 0.49% C 9.17%
language-bindings parser builder cmf

cmf-bindings's Introduction

The Compact Message Format bindings project

Bitcoin Classic introduced the Compact Message Format as a very simple but powerful format to encode and decode any type of messages.

The compact message format is a key/value-pair based format. Each key/value pair is called a token and a message is build up of a series of tokens.

Take this as a short example, a message with 3 tokens. Each having a name and a value.

   Name=Paris
   Population=2229621
   Area=105.6

In all object oriented languages there are very similar constructions available to create or parse the messages. Please refer to the API docs of your language bindings for details. I'll give a generic example here, to explain the concepts.

Message Creation

For creation of messages we use the builder pattern in the form of the MessageBuilder class.

The MessageBuilder class has a series of add() methods each of which appends a token to your message.

  byte[] bytes = new byte[100];
  MessageBuilder builder = new MessageBuilder(bytes);
  builder.add(City.Name, "Paris");
  builder.add(City.Population, 2229621);
  builder.add(City.Area, 105.6);
  builder.close();

This allows really easy to read and understand code.

Message Parsing

The MessageParser is using more of a SOX parser approach where you call MessageParser.Next() and then you can ask the parser for the tag-is and the actual value.

  MessageParser parser = new MessageParser(inputMessage);
  while (parser.next() == MessageParser.FoundTag) {
     if (parser.tag() == City.Population) {
         int population = parser.data.toInt();
         break;
     }
  }

At this time there are implementations for;

  • C++ which depend on Qt
  • C++ with boost
  • C# Should work with any version, the project assumes 4.5
  • Java
  • Python
  • C

cmf-bindings's People

Contributors

dagurval avatar ftrader avatar zander avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cmf-bindings's Issues

Test Method Deprecated C#

I'm not up on Visual Studio and C# so I'm just posting my findings.

/cmf-bindings/C#/CompactMessageFormat/test/NUnitTestClass.cs(3,3): Error CS0619: 'TestFixtureAttribute' is obsolete: 'The NUnit framework shipped with Mono is deprecated and will be removed in a future release. It was based on NUnit 2.4 which is long outdated. Please move to the NUnit NuGet package or some other form of acquiring NUnit.' (CS0619) (CompactMessageFormat)

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.