//Copyright (C) 2005 Richard J. Northedge
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//This file is based on the PlainTextGISModelReader.java source file found in the
//original java implementation of MaxEnt. That source file contains the following header:
// Copyright (C) 2001 Jason Baldridge and Gann Bierner
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
using System;
using System.IO;
namespace BotSharp.MachineLearning.IO
{
///
/// A reader for GIS models stored in plain text format.
///
///
/// Jason Baldridge
///
///
/// Richard J. Northedge
///
///
/// based on PlainTextGISModelReader.java, $Revision: 1.1.1.1 $, $Date: 2001/10/23 14:06:53 $
///
public class PlainTextGisModelReader : GisModelReader
{
private StreamReader mInput;
///
/// Constructor which directly instantiates the StreamReader containing
/// the model contents.
///
///
/// The StreamReader containing the model information.
///
public PlainTextGisModelReader(StreamReader reader)
{
using (mInput = reader)
{
base.ReadModel();
}
}
///
/// Constructor which takes a file and creates a reader for it.
///
///
/// The full path and file name in which the model is stored.
///
public PlainTextGisModelReader(string fileName)
{
using (mInput = new StreamReader(fileName, System.Text.Encoding.UTF7))
{
base.ReadModel();
}
}
///
/// Reads a 32-bit signed integer from the model file.
///
protected override int ReadInt32()
{
return int.Parse(mInput.ReadLine(), System.Globalization.CultureInfo.InvariantCulture);
}
///
/// Reads a double-precision floating point number from the model file.
///
protected override double ReadDouble()
{
return double.Parse(mInput.ReadLine(), System.Globalization.CultureInfo.InvariantCulture);
}
///
/// Reads a string from the model file.
///
protected override string ReadString()
{
return mInput.ReadLine();
}
}
}