Skip to content
/ disco Public

A header-only library for parsing data in fixed-width ascii format

License

Notifications You must be signed in to change notification settings

njoy/disco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Disco

Disco is a header-only library to parse fixed-width text, providing constructs which map one-to-one to Fortran format statements.

Minimal Example

#include <assert.h>
#include "disco.hpp"

using namespace disco;

int main(){
  std::string source = "        1.0       1000 Hello\n";
  auto it = source.begin();
  auto end = source.end();
  
  double myDouble;
  int myInt;
  std::string myString;
  
  /* Equivalent Fortran Format: (E11.4, I11, 1X, A5 ) */
  using myFormat = Format< Exponential<11,4>, 
                           Integer<11>, 
                           ColumnPosition<1>, 
                           Character<5> >;
                           
  myFormat::read( it, end, myDouble, myInt, myString );
  
  assert( myDouble == 1.0 );
  assert( myInt == 1000 );
  assert( myString == "Hello" );
}

About

A header-only library for parsing data in fixed-width ascii format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •