]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGConfigFile.cpp
JSBSim tweaks.
[flightgear.git] / src / FDM / JSBSim / FGConfigFile.cpp
index f74a1c128ef75383b6472f7e8e5f649101b3de2b..2aa97e12a11928c6561489d42f5d624ddef6f7f4 100644 (file)
@@ -21,8 +21,10 @@ INCLUDES
 #include <stdlib.h>
 #include <math.h>
 
-static const char *IdSrc = "$Header$";
-static const char *IdHdr = "ID_CONFIGFILE";
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_CONFIGFILE;
+
+extern short debug_lvl;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
@@ -30,27 +32,34 @@ CLASS IMPLEMENTATION
 
 FGConfigFile::FGConfigFile(string cfgFileName)
 {
-  cfgfile.open(cfgFileName.c_str());
+  cfgfile.open(cfgFileName.c_str(), ios::in | ios::binary );
   CommentsOn = false;
   CurrentIndex = 0;
   Opened = true;
   if (cfgfile.is_open()) GetNextConfigLine();
   else Opened = false;
+
+  if (debug_lvl & 2) cout << "Instantiated: FGConfigFile" << endl;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGConfigFile::~FGConfigFile(void)
+FGConfigFile::~FGConfigFile()
 {
   cfgfile.close();
+  if (debug_lvl & 2) cout << "Destroyed:    FGConfigFile" << endl;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 string FGConfigFile::GetNextConfigLine(void)
 {
   do {
     CurrentLine = GetLine();
-    if (CurrentLine.find("<COMMENT>") != CurrentLine.npos) CommentsOn = true;
-    if (CurrentLine.find("</COMMENT>") != CurrentLine.npos) {
+    if ((CurrentLine.find("<COMMENT>") != CurrentLine.npos) ||
+        (CurrentLine.find("<!--") != CurrentLine.npos)) CommentsOn = true;
+    if ((CurrentLine.find("</COMMENT>") != CurrentLine.npos) ||
+        (CurrentLine.find("-->") != CurrentLine.npos)) {
       CommentsOn = false;
       GetNextConfigLine();
     }
@@ -60,6 +69,7 @@ string FGConfigFile::GetNextConfigLine(void)
   return CurrentLine;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 string FGConfigFile::GetValue(string val)
 {
@@ -128,12 +138,14 @@ string FGConfigFile::GetValue(string val)
   return string("");
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 string FGConfigFile::GetValue(void)
 {
   return GetValue("");
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 bool FGConfigFile::IsCommentLine(void)
 {
@@ -143,11 +155,12 @@ bool FGConfigFile::IsCommentLine(void)
   return false;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 string FGConfigFile::GetLine(void)
 {
   string scratch = "";
-  unsigned int test;
+  int test;
 
   while ((test = cfgfile.get()) != EOF) {
     if (test >= 0x20) {
@@ -163,6 +176,8 @@ string FGConfigFile::GetLine(void)
   return scratch;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 FGConfigFile& FGConfigFile::operator>>(double& val)
 {
   unsigned int pos, end;
@@ -178,6 +193,8 @@ FGConfigFile& FGConfigFile::operator>>(double& val)
   return *this;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 FGConfigFile& FGConfigFile::operator>>(float& val)
 {
   unsigned int pos, end;
@@ -193,6 +210,8 @@ FGConfigFile& FGConfigFile::operator>>(float& val)
   return *this;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 FGConfigFile& FGConfigFile::operator>>(int& val)
 {
   unsigned int pos, end;
@@ -208,6 +227,8 @@ FGConfigFile& FGConfigFile::operator>>(int& val)
   return *this;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 FGConfigFile& FGConfigFile::operator>>(eParam& val)
 {
   unsigned int pos, end;
@@ -223,6 +244,8 @@ FGConfigFile& FGConfigFile::operator>>(eParam& val)
   return *this;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 FGConfigFile& FGConfigFile::operator>>(string& str)
 {
   unsigned int pos, end;
@@ -237,9 +260,17 @@ FGConfigFile& FGConfigFile::operator>>(string& str)
   return *this;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGConfigFile::ResetLineIndexToZero(void)
 {
   CurrentIndex = 0;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGConfigFile::Debug(void)
+{
+    //TODO: Add your source code here
+}
+