/[ghosts]/ghosts/gedcomparser/src/GEDCOMParser/Serializer/GEDCOMWriter.cpp
ViewVC logotype

Diff of /ghosts/gedcomparser/src/GEDCOMParser/Serializer/GEDCOMWriter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by cpcp, Sun Jan 26 21:15:21 2003 UTC revision 1.2 by cpcp, Mon Apr 7 22:03:28 2003 UTC
# Line 3  Line 3 
3  #include <algorithm>  #include <algorithm>
4  #include "string_utility/Converter.hh"  #include "string_utility/Converter.hh"
5    
6    #define TAG_SEPARATOR " "
7    
8    std::string const NEWLINE = "\n";
9    
10  void GEDCOMParser::GEDCOMWriter::WriteString(std::string const &name, std::string const &value)  void GEDCOMParser::GEDCOMWriter::WriteString(std::string const &name, std::string const &value)
11  {  {
12    if (value != "")    if (value != "")
13      {      {
14        outfile << name << " " << value << std::endl;        _buffer  = _buffer +  name +  TAG_SEPARATOR + value + NEWLINE;
15      }      }
16    return;    return;
17  }  }
# Line 30  void GEDCOMParser::GEDCOMWriter::WriteOb Line 34  void GEDCOMParser::GEDCOMWriter::WriteOb
34    
35  void GEDCOMParser::GEDCOMWriter::WriteText(std::string const &name, std::string const &value, int ref_level)  void GEDCOMParser::GEDCOMWriter::WriteText(std::string const &name, std::string const &value, int ref_level)
36  {  {
   std::string const NEWLINE = "\n";  
37    int const LINE_LENGTH = 255;    int const LINE_LENGTH = 255;
38    std::string const level = toString < int >(ref_level + 1);    std::string const level = toString < int >(ref_level + 1);
39    
# Line 43  void GEDCOMParser::GEDCOMWriter::WriteTe Line 46  void GEDCOMParser::GEDCOMWriter::WriteTe
46    std::string line_prefix = "";    std::string line_prefix = "";
47    
48    bool found = false;    bool found = false;
49    outfile << name << " ";    _buffer  = _buffer +  name + TAG_SEPARATOR;
50    do    do
51      {      {
52        found = false;        found = false;
# Line 82  void GEDCOMParser::GEDCOMWriter::WriteTe Line 85  void GEDCOMParser::GEDCOMWriter::WriteTe
85              }              }
86            head = std::string(tmp, 0, head_length);            head = std::string(tmp, 0, head_length);
87    
88            outfile << line_prefix + head << std::endl;            _buffer = _buffer + line_prefix + head  + NEWLINE;
89    
90            if (head_length != tmp.length())            if (head_length != tmp.length())
91              {              {
# Line 105  void GEDCOMParser::GEDCOMWriter::WriteDa Line 108  void GEDCOMParser::GEDCOMWriter::WriteDa
108  {  {
109    if (value != 0)    if (value != 0)
110      {      {
111        outfile << name << " " << value->getRawValue() << std::endl;        _buffer = _buffer + name + TAG_SEPARATOR + value->getRawValue() + NEWLINE;
     }  
   return;  
 }  
   
 void GEDCOMParser::GEDCOMWriter::setFile(std::string const &filename)  
 {  
   if (outfile.is_open())  
     {  
       outfile.close();  
     }  
   _filename = filename;  
   return;  
 }  
   
 void GEDCOMParser::GEDCOMWriter::OpenTransaction(void)  
 {  
   if (_filename != "")  
     {  
       outfile.open(_filename.c_str());  
     }  
   else  
     {  
       outfile.std::basic_ios<char>::rdbuf(std::cout.rdbuf());  
   
112      }      }
113    return;    return;
114  }  }
115    
 void GEDCOMParser::GEDCOMWriter::CloseTransaction(void)  
 {  
   outfile.close();  
   return;  
 }  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26