comparison mde/mergetag/Reader.d @ 67:108d123238c0

Changes to work with tango r3700 (post 0.99.6). Changes to logging. Replaced many uses of PathView with FilePath.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 03 Jul 2008 12:40:31 +0100
parents e0839643ff52
children ea58f277f487
comparison
equal deleted inserted replaced
65:891211f034f2 67:108d123238c0
26 import mde.mergetag.internal; 26 import mde.mergetag.internal;
27 27
28 import tango.core.Exception; 28 import tango.core.Exception;
29 29
30 // tango imports 30 // tango imports
31 import tango.io.FilePath;
31 import tango.io.UnicodeFile; 32 import tango.io.UnicodeFile;
32 import Util = tango.text.Util; 33 import Util = tango.text.Util;
33 import ConvInt = tango.text.convert.Integer; 34 import ConvInt = tango.text.convert.Integer;
34 import tango.util.collection.model.View : View; 35 //import tango.util.collection.model.View : View;
35 import tango.util.collection.HashSet : HashSet; 36 import tango.util.collection.HashSet : HashSet;
36 import tango.util.log.Log : Log, Logger; 37 import tango.util.log.Log : Log, Logger;
37 38
38 private Logger logger; 39 private Logger logger;
39 static this() { 40 static this() {
51 * $(TR $(TH Exception) $(TH Thrown when)) 52 * $(TR $(TH Exception) $(TH Thrown when))
52 * $(TR $(TD MTFileIOException) $(TD When extension given is neither mtt nor mtb)) 53 * $(TR $(TD MTFileIOException) $(TD When extension given is neither mtt nor mtb))
53 * ) 54 * )
54 * 55 *
55 */ 56 */
56 IReader makeReader (PathView path, DataSet ds = null, bool rdHeader = false) { 57 IReader makeReader (FilePath path, DataSet ds = null, bool rdHeader = false) {
57 if (path.ext == "mtb") return new MTBReader (path, ds, rdHeader); 58 if (path.ext == "mtb") return new MTBReader (path, ds, rdHeader);
58 else if (path.ext == "mtt") return new MTTReader (path, ds, rdHeader); 59 else if (path.ext == "mtt") return new MTTReader (path, ds, rdHeader);
59 else throw new MTFileIOException ("Invalid mergetag extension"); 60 else throw new MTFileIOException ("Invalid mergetag extension");
60 } 61 }
61 62
62 /** Resolve a file path. 63 /** Resolve a file path.
63 * 64 *
64 * Tries adding both ".mtt" and ".mtb" extensions, returning whichever exists (the most recently 65 * Tries adding both ".mtt" and ".mtb" extensions, returning whichever exists (the most recently
65 * modified if both exist), or returns null if neither exist. */ 66 * modified if both exist), or returns null if neither exist. */
66 PathView findFile (char[] path) { 67 FilePath findFile (char[] path) {
67 if (path is null) return null; 68 if (path is null) return null;
68 69
69 FilePath tPath = new FilePath (path ~ ".mtt"); 70 FilePath tPath = new FilePath (path ~ ".mtt");
70 FilePath bPath = new FilePath (path ~ ".mtb"); 71 FilePath bPath = new FilePath (path ~ ".mtb");
71 72
211 */ 212 */
212 public this (char[] path, DataSet ds = null, bool rdHeader = false) { 213 public this (char[] path, DataSet ds = null, bool rdHeader = false) {
213 this (new FilePath (path), ds, rdHeader); 214 this (new FilePath (path), ds, rdHeader);
214 } 215 }
215 /** ditto */ 216 /** ditto */
216 public this (PathView path, DataSet ds = null, bool rdHeader = false) { 217 public this (FilePath path, DataSet ds = null, bool rdHeader = false) {
217 // Create a dataset or use an existing one 218 // Create a dataset or use an existing one
218 if (ds !is null) _dataset = ds; 219 if (ds !is null) _dataset = ds;
219 else _dataset = new DataSet(); 220 else _dataset = new DataSet();
220 221
221 // Open & read the file 222 // Open & read the file