mirror of https://github.com/buggins/dlangui.git
95 lines
4.2 KiB
HTML
95 lines
4.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
|
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
|
|
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
|
|
<link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
|
|
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<title>DlangUI - cross platform GUI library for D programming language - dlangui.core.linestream</title>
|
|
</head>
|
|
<body>
|
|
<div id="container">
|
|
<div class="inner">
|
|
<header>
|
|
<h1>DlangUI</h1>
|
|
<h2>Cross Platform GUI for D programming language</h2>
|
|
</header>
|
|
<section id="downloads" class="clearfix">
|
|
<a href="index.html" id="home" class="button"><span>Home</span></a>
|
|
<a href="api.html" id="home" class="button"><span>API Docs</span></a>
|
|
<a href="screenshots.html" id="home" class="button"><span>Screenshots</span></a>
|
|
<a href="https://github.com/buggins/dlangui/zipball/master" id="download-zip" class="button"><span>Download .zip</span></a>
|
|
<!--a href="https://github.com/buggins/dlangui/tarball/master" id="download-tar-gz" class="button"><span>Download .tar.gz</span></a-->
|
|
<a href="https://github.com/buggins/dlangui" id="view-on-github" class="button"><span>View on GitHub</span></a>
|
|
</section>
|
|
|
|
<hr>
|
|
<section id="main_content">
|
|
<h1>dlangui.core.linestream</h1>
|
|
<!-- Generated by Ddoc from src\dlangui\core\linestream.d -->
|
|
This module contains text file reader implementation.
|
|
<br><br>
|
|
Support utf8, utf16, utf32 be and le encodings, and line endings - according to D language source file specification.
|
|
<br><br>
|
|
|
|
Low resource consuming. Doesn't flood with GC allocations. Dup line if you want to store it somewhere.
|
|
<br><br>
|
|
|
|
Tracks line number.
|
|
<br><br>
|
|
|
|
|
|
<br><br>
|
|
<b>Synopsis:</b><br>
|
|
<pre class="d_code"><font color=blue>import</font> dlangui.core.<u>linestream</u>;
|
|
|
|
<font color=blue>import</font> std.stdio;
|
|
<font color=blue>import</font> std.conv;
|
|
<font color=blue>import</font> std.utf;
|
|
string fname = <font color=red>"somefile.d"</font>;
|
|
writeln(<font color=red>"opening file"</font>);
|
|
std.stream.File f = <font color=blue>new</font> std.stream.File(fname);
|
|
<font color=blue>scope</font>(exit) { f.close(); }
|
|
<font color=blue>try</font> {
|
|
LineStream lines = LineStream.create(f, fname);
|
|
<font color=blue>for</font> (;;) {
|
|
<font color=blue>dchar</font>[] s = lines.readLine();
|
|
<font color=blue>if</font> (s <font color=blue>is</font> <font color=blue>null</font>)
|
|
<font color=blue>break</font>;
|
|
writeln(<font color=red>"line "</font> ~ to!string(lines.line()) ~ <font color=red>":"</font> ~ toUTF8(s));
|
|
}
|
|
<font color=blue>if</font> (lines.errorCode != 0) {
|
|
writeln(<font color=red>"Error "</font>, lines.errorCode, <font color=red>" "</font>, lines.errorMessage, <font color=red>" -- at line "</font>, lines.errorLine, <font color=red>" position "</font>, lines.errorPos);
|
|
} <font color=blue>else</font> {
|
|
writeln(<font color=red>"EOF reached"</font>);
|
|
}
|
|
} <font color=blue>catch</font> (Exception e) {
|
|
writeln(<font color=red>"Exception "</font> ~ e.toString);
|
|
}
|
|
|
|
</pre>
|
|
|
|
<br><br>
|
|
<b>License:</b><br>
|
|
Boost License 1.0
|
|
<br><br>
|
|
<b>Authors:</b><br>
|
|
Vadim Lopatin, coolreader.org@gmail.com<br><br>
|
|
|
|
|
|
</section>
|
|
<footer>
|
|
Dlangui is maintained by <a href="https://github.com/buggins">buggins</a><br>
|
|
This page was generated by <a href="http://pages.github.com">GitHub Pages</a>. Tactile theme by <a href="https://twitter.com/jasonlong">Jason Long</a>.
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|