GithubHelp home page GithubHelp logo

npc's Introduction

Nick's Packet Compiler

+-------+ | BUILD | +-------+

To re-compile, just run 'make'. You will need the Haskell platform.

+------------+ | INVOCATION | +------------+

The tool may be invoked using either 'npc --all [--inc=FILE]' or 'npc [--inc=FILE] packet1 [packet2...]'. The --all flag (short option -a) will run the tool on all files in the directory with a .packet extension. The --inc=FILE flag (short option -iFILE) specifies the inclusion file for user-defined classes (see USER CLASSES below). It is necessary if and only if your packets contain user-defined classes.

Instead of using --all, you may invoke npc by explicitly naming the packets you wish to compile.

Help on the npc command can be found by invoking npc with no arguments.

+--------+ | FORMAT | +--------+

The format of packets is as follows:

packet <packet_name> { <C_type> <field_name>; ... }

Standard C++ naming rules apply. <packet_name> may not be Packet. Empty packets are allowed.

Packets in the same .packet file will be in the same .h/.cpp files.

+---------------+ | ALLOWED TYPES | +---------------+

Support is built-in for all primitives, size_t, time_t, (C++) strings, pairs, vectors, lists, and maps. No pointers or references are allowed. Types may be nested, e.g. map<string, vector>. If <C_type> is a user-defined class, that class must define - unsigned int SerializedSize() const - void Serialize(ByteBuffer &) const - void Deserialize(ByteBuffer &)

+------------+ | USER TYPES | +------------+

For user-defined types, you will need to specify an inclusions file that tells npc which header files to include for those classes. This should be specified with the --inc=FILE option. The file itself should look like

class_name1:header_file1; class_name2:header_file2; ...

Each class you use must be specified in the inclusions file, or a "Map.find" error will be thrown.

+----------+ | COMMENTS | +----------+

Block comments (/* ... */) are allowed outside and only outside packet definitions. Nesting block comments is NOT allowed.

Single-line comments (// ...) are allowed inside and only inside packet definitions. Single line comments are also allowed in the inclusions file.

Allowed (packet files):

/* This packet is for requests. I like requests. */ packet Request { // Here are the fields int status; // OK //bool debug; string name; }

Not allowed (packet files):

// The best response ever packet Response { /* I don't want these now bool save; string filename; */ int number; }

Allowed (inclusions file):

MyClass:myclass.h // awesome //Foo:foo.h

Not Allowed (inclusions file):

MyClass:myclass.h /* Foo:foo.h Bar:bar.h */

+--------------+ | KNOWN ISSUES | +--------------+

None.

+-----------+ | CHANGELOG | +-----------+

Version 1.6: Added support for pairs.

Version 1.5: Added TypeString method to Packet Added virtual destructor to Packet, made ctor/dtor public Added support for size_t and time_t

Version 1.4: Added support for lists Added sequence numbers

Version 1.3: Added inclusions file. Removed --main option. Removed boolean err from Packet::DeserializePacket

Version 1.2: Added more convenient deserialization Reduced number of I/O operations Fixed empty packet bug

Version 1.1: Non-const accessors removed for primitives, since they're useless Source file Npc.hs now has comments

Version 1.0: Initial release

npc's People

Contributors

njwatson32 avatar

Watchers

 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.