Coder Social home page Coder Social logo

librakaly's Introduction

ci

LibRakaly

librakaly is a shared library for PDX Tools functionality that exposes a C and C++ interface and can be embedded in any application that can call C or C++ code.

Below is a whirlwind tour of the C++ API (for more usage, see sample.cpp).

namespace fs = std::filesystem;

rakaly::GameFile parseSave(fs::path filePath, const std::string &input) {
  if (filePath.extension() == ".eu4") {
    return rakaly::parseEu4(input);
  } else if (filePath.extension() == ".ck3") {
    return rakaly::parseCk3(input);
  } else if (filePath.extension() == ".hoi4") {
    return rakaly::parseHoi4(input);
  } else if (filePath.extension() == ".rome") {
    return rakaly::parseImperator(input);
  } else if (filePath.extension() == ".v3") {
    return rakaly::parseVic3(input);
  } else {
    throw std::runtime_error("unrecognized file extension");
  }
}

int main(int argc, const char *argv[]) {
  // ... snip getting file path and reading file ...
  const auto save = parseSave(filePath, input);
  if (save.is_binary()) {
    std::cerr << "cool! This save is binary!\n";
  }

  auto melt = save.melt();

  if (melt.has_unknown_tokens()) {
    std::cerr << "unable to melt all fields\n";
  }

  melt.writeData(input);
  std::cout << input;
}

Tutorial

While these steps are linux specific, librakaly can also be used with ease on windows or mac. This tutorial will assume using the prebuilt shared library. If one wants to build librakaly for themselves, see the "Building" section.

  • Create a directory to house the tutorial
  • Go to the latest librakaly release
  • Download the librakaly.so
  • Download the rakaly.h
  • Download sample.cpp for the C++ example. If writing C, one can base their implementation off the C++ wrapper in ./src/cpp_helper.h
  • Invoke gcc as follows
g++ sample.cpp -std=c++17 -o melter -O2 librakaly.so
  • Then invoke the melter like:
LD_LIBRARY_PATH=. ./melter save my-ironman-save.eu4

Building

To build:

  • Have the rust toolchain installed
  • Define an environment variable EU4_IRONMAN_TOKENS pointing to a file containing the ironman tokens. More info in the eu4save repo.
  • Define an environment variable CK3_IRONMAN_TOKENS pointing to a file containing the ironman tokens. More info in the ck3save repo.
  • Define an environment variable IMPERATOR_TOKENS pointing to a file containing the ironman tokens. More info in the imperator repo.
  • Define an environment variable HOI4_IRONMAN_TOKENS pointing to a file containing the ironman tokens. More info in the hoi4 repo.
  • Invoke
cargo build --release

librakaly's People

Contributors

dlbuunk avatar idhrendur avatar nickbabcock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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