0.0.5 • Published 13 years ago

swapm v0.0.5

Weekly downloads
24
License
-
Repository
github
Last release
13 years ago

Swapm (Not ready for the public yet)

Code generation for the rest of us

Example

Source File: project/foo.h

#ifndef FOO_H_
#define FOO_H_

#include <libpq-fe.h>
#include <libpqtypes.h>

class Foo {
private:
  /*{{template: "t1", data: "d1"}}*/

                      <-- generated code will go here

  /*{{end}}*/
public:
  Foo(PGresult * res);
  virtual ~Foo();
};

#endif /* FOO_H_ */

Data File: project/swapm/data/d1.json

{
  stuff: [
    { name: "id", type: "int8"  },
    { name: "bar",type: "float4"}
  ]
}

Template File: project/swapm/templates/t1.tmpl

Mustache templates are used by default, but the engine will be configurable :)

{{#stuff}}
  PG{{type}} * _{{name}};
{{/stuff}}

Generate

swap foo.h

Output

#ifndef FOO_H_
#define FOO_H_

#include <libpq-fe.h>
#include <libpqtypes.h>

class Foo {
private:
  /*{ template: "t1", data: "d1" }*/
  PGint8 * _id;
  PGfloat4 * _bar;
  /*{end}*/
public:
  Foo(PGresult * res);
  virtual ~Foo();
};

#endif /* FOO_H_ */
0.0.5

13 years ago

0.0.4

13 years ago

0.0.3

13 years ago

0.0.2

13 years ago

0.0.1

13 years ago