Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 

README.md

LTSV for D

ltsv-d is a LTSV implementation for D

Usage

Parse LTSV format

  • fromLTSV

Returns an associative array by default:

import ltsv;

immutable apacheLog = "host:127.0.0.1\tident:-\tuser:foo\ttime:[10/Oct/2000:13:55:36 -0700]\treq:GET /apache.gif HTTP/1.0\tstatus:200\tsize:777\treferer:http://www.example.com/start.html\tua:Mozilla/4.08 [en] (Win98; I ;Nav)";

auto record = fromLTSV(apacheLog);
assert(record["host"] == "127.0.0.1");
assert(record["size"] == "700");

Can returns a struct or class:

struct ApacheLog
{
    string host, ident, user, time, req, referer, ua;
    size_t size, status;
}

/// convert into struct or class directly
auto record = fromLTSV!ApacheLog(apacheLog);
assert(record.host == "127.0.0.1");
assert(record.size == 777);

Dump D object into LTSV format

/// foo:bar\thoge:fuga\tpiyo:puyo
auto line = ["foo":"bar", "hoge":"fuga", "piyo":"puyo"].toLTSV();

struct or class:

struct Test
{
    string a = "D";
    size_t b = 1999;
    double c = 10.0;
}

/// a:D b:1999 c:10.0
auto line = Test().toLTSV();

Test

% rdmd -unittest --main src/ltsv.d

Link

Copyright

AuthorMasahiro Nakagawa
CopyrightCopyright (c) 2013- Masahiro Nakagawa
LicenseBoost Software License, Version 1.0

About

LTSV implemetation for D

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.