Pfarah


Pfarah

Pfarah is an extremely fast and easy to use solution for parsing files created by Clausewitz engine from Paradox Interactive

Pfarah can be installed from NuGet:
PM> Install-Package Pfarah

Getting Started

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
#r "Pfarah.dll"
open Pfarah
open Pfarah.Operators

// Parse strings. Great for discovering how to work with Pfarah or the sample
// data
let obj = ParaValue.Parse "foo=bar"
obj?foo |> asString

// Load files. Great for performance
let obj2 = ParaValue.LoadText @"C:\somefilepath"

Documentation

  • Tutorial contains a great walkthrough of the API

  • API Reference contains automatically generated documentation for all types, modules and functions in the library.

Note on Memory Usage

While Pfarah tries to be memory conscious (parsing based on streams and not whole strings), the resulting data structure may be considered a memory hug. A 60MB file parsed by Pfarah will consume about 300MB of memory while the parsed document data structure hangs around. The data structure allows for easy quering on the data at the cost of memory. Thus, it is recommended that as soon as the file is parsed to keep around only what is needed and cast the data to the expected formats (such as an integer), which will consume less space. This will allow the garbage collector to clean up the intermediary 300MB data structure.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. You might also want to read the library design notes to understand how it works.

The library is available under the MIT license. For more information see the License file in the GitHub repository.

namespace Pfarah
module Operators

from Pfarah
Multiple items
val obj : ParaValue

Full name: Index.obj

--------------------
type obj = System.Object

Full name: Microsoft.FSharp.Core.obj
Multiple items
module ParaValue

from Pfarah

--------------------
type ParaValue =
  | Bool of bool
  | Number of float
  | Hsv of float * float * float
  | Rgb of byte * byte * byte
  | Date of DateTime
  | String of string
  | Array of elements: ParaValue []
  | Record of properties: (string * ParaValue) []
  override ToString : unit -> string
  static member Load : stream:Stream * binHeader:string * txtHeader:string * lookup:Lazy<IDictionary<int16,string>> -> ParaValue
  static member Load : file:string * binHeader:string * txtHeader:string * lookup:Lazy<IDictionary<int16,string>> -> ParaValue
  static member LoadBinary : stream:Stream * lookup:IDictionary<int16,string> * header:string option -> ParaValue
  static member LoadText : file:string -> ParaValue
  static member LoadText : stream:Stream -> ParaValue
  static member Parse : text:string -> ParaValue
  static member private Prettify : value:ParaValue -> indent:int -> string
  static member Save : stream:Stream * data:ParaValue -> unit
  static member private collect : prop:string -> obj:ParaValue -> ParaValue
  static member ( / ) : obj:ParaValue * propertyName:string -> ParaValue

Full name: Pfarah.ParaValue

--------------------
type ParaValue<'a> = ParaValue -> ParaResult<'a> * ParaValue

Full name: Pfarah.ParaValue<_>
static member ParaValue.Parse : text:string -> ParaValue
val obj2 : ParaValue

Full name: Index.obj2
static member ParaValue.LoadText : file:string -> ParaValue
static member ParaValue.LoadText : stream:System.IO.Stream -> ParaValue
Fork me on GitHub