Re: Line endings in strings

Jean-Claude Wippler <[email protected]>
Newsgroups gmane.comp.db.metakit
Message-ID <[email protected]>
John Fletcher wrote:

> I am doing some work adapting E4Graph to export RDF/XML.
>
> To do this I want to be able to add some end of lines to the output
> to improve readability.  I have done this for Linux using \n.
>
> The problem is, of course, that for Windows and MacOS the need
> is different.  Is there a system of defines setup within Metakit or
> E4Graph for testing for the operating system, or have I to go back
> to each OS for that?

There's some boilerplate checking in mk4.h, but at that level MK really 
tries to stay out of as many details as possible.  For Windows, it 
uses:
	#ifdef _WIN32
For classic Mac, you ought to be able to use:
	#ifdef macintosh
For Mac OS X, the line ending is \n, i.e. as in every other Unix 
variant.

Look in src/fileio.cpp, that's the only spot where system dependencies 
in MK are supposed to matter.  Note however that q4_UNIX, q4_WIN32, etc 
are only defined during the compilation of MK itself.  As I said, the 
"mk4.h" public header goes out of its way to not be conditional on OS 
or STL/MFC.

Isn't it simpler to make the output code emit (fopen, puts, etc) the 
proper line ending, and stick to always using \n in C/C++ code and in 
MK storage?  That way line endings differences needn't affect most of 
the code.

-jcw

_____________________________________________
Metakit mailing list  -  [email protected]
http://www.equi4.com/mailman/listinfo/metakit
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.