Coder Social home page Coder Social logo

isabella232 / infact Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google/infact

0.0 0.0 0.0 2.59 MB

Provides a lightweight interpreter and factory for dynamically creating C++ objects at runtime.

Home Page: http://google.github.io/infact/

License: BSD 3-Clause "New" or "Revised" License

Shell 21.43% C++ 78.57%

infact's Introduction

InFact: An easy way to construct C++ objects dynamically

InFact provides an interpreter and factory for the construction of instances of C++ classes. The syntax is very much like that of C++ itself, and objects may be created that wrap other objects, just like in C++. It supports all the common primitive types (bool, int, double, string), as well as vectors of primitives or of Factory-constructible objects. Here's what it looks like:

// Construct a cow with a required argument, its name.
Cow c1 = Cow(name("Bessie"));

// Construct a second cow with a different name, and an optional age.
// Also, specifying a type is optional, since InFact does type inference.
c2 = Cow(name("Lani Moo"), age(2));

// Construct a human pet owner with the two cows as pets.
PetOwner p = HumanPetOwner(pets({c1, c2}));

Feeding the above to InFact’s Interpreter class will construct three new objects at run-time (the referents of c1, c2 and p) without any new C++ code.

While being very powerful, the library is also quite lightweight: it is a simple recursive-descent parser with a single token of look-ahead, with the entire library implemented with fewer than 1000 C++ statements. The inspiration was the BeanShell library for Java, which provides a very convenient mechanism for configuration of any Java project. Similarly, InFact can be used as an effective configuration mechansim for C++ projects. See the ReFr project for an example, especially the default configuration file.

The interpreted InFact language supports type inference and named parameters. Compile-time equivalents of these two properties are available with the Boost Parameter library.

For documentation, please visit our documentation site.

infact's People

Contributors

dbikel 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.