Oops, I meant to send this to the list. ------- Forwarded message follows ------- From: John Fletcher <[EMAIL PROTECTED]> To: Jean-Claude Wippler <[EMAIL PROTECTED]> Subject: Re: [Metakit] Line endings in strings Date sent: Fri, 26 Nov 2004 11:37:13 -0000
From: Jean-Claude Wippler <[EMAIL PROTECTED]> Subject: Re: [Metakit] Line endings in strings Date sent: Fri, 26 Nov 2004 12:18:30 +0100 To: Metakit list <[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 > jc Thanks for the quick reply. The problem arises during recompilation of e4xmlgenerator.cpp, part of Jacob's e4xml suite. What I am doing is injecting an extra \n into a string which is being put together for output later by some other part of the code. At the moment I put in \n and have sent it to Jacob like that. At some later stage the string will be output with that code in. What I wanted to do was to make it consistent by putting in conditional compilation so that the builds for different operating systems would do the correct thing for that system. That could be done by reinterpreting the \n at output time, which would need a change to a different part of the code, the output operator for the string class. Really it is for Jacob to decide as it is his code, but I was trying to sort out the cleanest way to do it so it works for everyone without them having to bother about it. John ------- End of forwarded message --------------------------------------------- ----------------------------- Dr John P. Fletcher Tel: (44) 121 204 3389 (direct line) Chemical Engineering and Applied Chemistry (CEAC), School of Engineering and Applied Science (SEAS), Aston University, Fax: (44) 121 359 4094 Aston Triangle, Email: [EMAIL PROTECTED] BIRMINGHAM B4 7ET U.K. CEAC Web site http://www.ceac.aston.ac.uk/ _____________________________________________ Metakit mailing list - [EMAIL PROTECTED] http://www.equi4.com/mailman/listinfo/metakit
