Skip to content

API Reference

Andy Zhang edited this page Apr 9, 2024 · 6 revisions

API Reference

Steppable has an API in C++ and Python.

C++ API

You may use the API by adding a new component.

To add a new feature, a:

  1. Add a directory called src/a in the Steppable directory, with at least three files:

    • a.cpp - The main file. The main function should be present, as it is the entry point of the executable.
    • aReport.cpp - The report file to show the results.
    • aReport.hpp - A header that contains optional definition.

Note

Only the above-mentioned three files will be added to CMake.

  1. Make sure to document the code. Please use Doxygen to document this project.

  2. Add an entry to CMakeLists.txt at the root of the repository.

    set(COMPONENTS
        add
        ...
        a # Replace with yours
    )

Using the Header Files

You may include the Steppable header files. They are:

  • util.hpp - Useful utilities for string manipulation, numbers, etc.
  • colors.hpp - Printing with colors, or with custom formats.
  • argParse.hpp - Argument parsing for executables.
  • exceptions.hpp - Exceptions to throw in case of error.
  • format.hpp - String formatting.
  • fraction.hpp - Fractions in Steppable.
  • number.hpp - Numbers in Steppable.
  • logging.hpp - Log file creation and management.
  • output.hpp - Console logging utilities.
  • platform.hpp - Platform-specific functions.
  • rounding.hpp - Round off numbers.
  • symbols.hpp - Mathematical symbols.
  • testing.hpp - Unit testing utilities.
  • fn/basicArithm.hpp - Basic arithmetics.

Using the Namespaces

The symbols are sometimes inside namespaces. They are:

  • steppable - Root namespace. Public Methods are here.
  • steppable::__internals::arithmetic - Arithmetic functions.
  • steppable::__internals::utils - Utility functions.
  • steppable::exceptions - Exceptions.
  • steppable::output - Console logging utilities.
  • steppable::__internals::format - Text formatting.
  • namespace steppable::__internals::numUtils - Number manipulation utilities.
  • steppable::__internals::stringUtils - String manipulation utilities.
  • steppable::__internals::symbols - Mathematical symbols.
  • steppable::testing - Unit testing utilities.
  • namespace steppable::__internals::logging - Log file creation and management.

Using the Library

In namespace steppable, there are two classes, and one enum.

  • class Number - Steppable number. It can be added, subtracted, multiplied, divided, etc. For more information, see the documentation for this.
  • class Fraction - Steppable fraction. It also supports multiply arithmetic operators. For more information, see the documentation for this.
  • enum RoundingMode - Specifies how the result should be rounded.

In namespace steppable::__internals::arithmetic, there is one class and several methods.

  • struct QuotientRemainder - A struct representing the result and remainder from a division operation. For more information, see the documentation for this.
  • For the other methods, refer to the documentation.

Python API

The Python library is created using nanobind. You need to create the library on the same platform and using the same version of Python.

You may import the library as follows:

>>> import steppyble

Available Classes

There are three available classes.

  • class Number - Steppable number. It can be added, subtracted, multiplied, divided, etc. Operators are overloaded, same as in C++.
  • class Fraction - Steppable fraction. It also supports multiply arithmetic operators. Operators are overloaded, same as in C++.
  • enum RoundingMode - Specifies how the result should be rounded.

Contents

Introduction

Contributing

Building

Development

API Documentation

Others

  • Performance - Some benchmarks of Steppable for reference
  • Status - Status of Steppable, at a glance
Clone this wiki locally