Coder Social home page Coder Social logo

kb1vc / sodaformat Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 304 KB

A C++ formatting library that provides an "engineering" format for floating point numbers. It is inspired by the Qt "QString" formatting features.

License: BSD 2-Clause "Simplified" License

CMake 23.55% C++ 76.45%

sodaformat's Introduction

SoDa::Format print stuff.

To get to doxygen generated documentation that is more detailed than the following summary, go here

SoDa::Format is a class that allows intelligent formatting of integer, floating point, string, and character values into std::string objects or for output to a stream. The concept is inspired by the much more capable Qt::QString's formatting features. If you can afford the library dependency, use Qt. It's quite good.

SoDa::Format is meant to improve upon the tremendously awkward, antiquated, and bizarre stream output features of the standard template library. (C++ stream IO was a giant step backward from the comparatively flexible and intuitive FORTRAN "FORMAT" scheme. There isn't much in the computing world that is a giant step backward from FORTRAN circa 1975.)

One could use the BOOST format facility. (One could also eat brussels sprouts for breakfast, but it isn't my kind of thing. Is it yours?) boost::format is tremendously powerful and fabulously documented. It may be easily extended by beings living in some of the outer reaches of the Horse Head nebula. I just don't grok it myself. And carrying around a boost dependency is like growing an extra thumb -- it is useful at times, but it becomes less and less so as time goes on, and you can never quite remember why you got it in the first place.

What really motivated me to write SoDa::Format was the lack of an "engineering notation" format for floating point numbers in any of the common formatting facilities. As a dyed in the wool MKS engineer, this drives me right up the wall. Exponents should be multiples of three. If Adam had done any floating point arithmetic, he would have written it down in engineering notation. (Perhaps he did, and then lost it all when the serpent screwed everything up.)

So with SoDa::Format you can print out

322.0e-6 Farads

instead of the grotesque

3.22e-4 Farads.

Who even thinks like that?

Installing

Just like any other CMake project. For instance, to install the package in /usr/local ... From this directory

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local
make
sudo make install

This will install the libraries in /usr/local/lib or lib64 as appropriate and the include in /usr/local/include/SoDaFormat/Format.hxx

It will also write doxygen output that starts at /usr/local/share/sodaformat/doc/html/index.html

Testing and Using it all

Take a look at the CMakeLists.txt file and FormatExample.cxx in the example directory. If the installation has gone right, then you should be able to do this from this directory.

cd example
mkdir build
cd build
cmake ../
make
./FormatExample

Did that work?

sodaformat's People

Contributors

kb1vc avatar

Watchers

James Cloos 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.