1package org.codeworker;
2
3class SizeAttributes {
4	public int _iSize;
5	public int _iReadCursor;
6	public int _iWriteCursor;
7	public char _cEndChar;
8	public SizeAttributes _pShiftedStream;
9
10	public SizeAttributes() {
11		_iSize = -1;
12		_iReadCursor = -1;
13		_iWriteCursor = -1;
14		_cEndChar = '\0';
15	}
16
17	public SizeAttributes(SizeAttributes copy) {
18		_iSize = copy._iSize;
19		_iReadCursor = copy._iReadCursor;
20		_iWriteCursor = copy._iWriteCursor;
21		_cEndChar = copy._cEndChar;
22		if ((copy._pShiftedStream != null))
23			{
24				_pShiftedStream = new SizeAttributes(copy._pShiftedStream);
25			}
26		else
27			_pShiftedStream = null;
28	}
29
30	protected void finalize() {
31	}
32	public boolean empty() {
33		return (_iSize < 0);
34	}
35
36}
37
38public class ScpStream {
39	public static int IN = 1;
40	public static int OUT = 2;
41	public static int INOUT = 3;
42	public static int APPEND = 4;
43	public static int PATH = 8;
44	public static String ENDL = "\n";
45	private char[] _tcStream;
46	private int _iCacheMemory;
47	private int _iSize;
48	private int _iReadCursor;
49	private int _iWriteCursor;
50	private boolean _bInsertText;
51	private String _sIndentation;
52	private int _iMode;
53	private String _sFilename;
54	private org.codeworker.ScpStream _pParentStream;
55	private org.codeworker.ScpStream _pShiftedStream;
56	private int _iShiftedStreamPosition;
57	private org.codeworker.ScpStream _pPrecStream;
58	private org.codeworker.ScpStream _pNextStream;
59	private int _iLineCounter;
60	private int _iLinePosition;
61	private java.util.Map<String,java.lang.Integer> _mapOfFloatingLocations;
62	private java.util.Set<String> _setOfTextsToInsertOnce;
63	private static java.util.List<String> _listOfIncludePaths;
64	private static java.util.Map<String,String> _listOfVirtualFiles;
65	private org.codeworker.END_STREAM_CALLBACK _pfStreamReaderCallback;
66	private java.lang.Object _pStreamReaderCBKData;
67	private org.codeworker.END_STREAM_CALLBACK _pfStreamWriterCallback;
68	private java.lang.Object _pStreamWriterCBKData;
69
70//##protect##"Java ScpStream Methods"
71	protected static void memcpy(char[] dest, char[] org) {
72		memcpy(dest, org, org.length);
73	}
74
75	protected static void memcpy(char[] dest, char[] org, int iLength) {
76		for (int i = 0; i < iLength; i++) {
77			dest[i] = org[i];
78		}
79	}
80
81	protected void copy(char[] tcDest, int iDestStart, char[] tcOrg, int iOrgStart, int iLength) {
82		for (int i = 0; i < iLength; i++) {
83			tcDest[iDestStart + i] = tcOrg[iOrgStart + i];
84		}
85	}
86
87	public boolean isEqualTo(char ch) {
88		int iChar = readChar();
89		if ((iChar == ((int) ch)))
90			return true;
91		if ((iChar >= 0))
92			goBack();
93		return false;
94	}
95
96	public static boolean createVirtualFile(String sHandle, char[] sContent) {
97		return createVirtualFile(sHandle, new String(sContent));
98	}
99
100	private void WRITECHAR(byte a) {
101		WRITECHAR((char) a);
102	}
103
104	private void WRITECHAR(char a) {
105		_tcStream[_iWriteCursor++] = a;
106		if (_iWriteCursor >= _iCacheMemory) {
107			int iOldSize = _iCacheMemory;
108			_iCacheMemory *= 2;
109			char[] tcStream = new char[_iCacheMemory];
110			memcpy(tcStream, _tcStream, iOldSize);
111			_tcStream = tcStream;
112		}
113	}
114
115	private void writeText(String tcText) {
116		writeBinaryData(tcText.toCharArray(), tcText.length());
117	}
118//##protect##"Java ScpStream Methods"
119
120	public ScpStream(int iCacheMemory) {
121		_iCacheMemory = iCacheMemory;
122		_iSize = 0;
123		_iReadCursor = 0;
124		_iWriteCursor = 0;
125		_bInsertText = false;
126		_iMode = 0;
127		_iShiftedStreamPosition = 0;
128		_iLineCounter = 1;
129		_iLinePosition = 0;
130		_tcStream = new char[iCacheMemory];
131	}
132
133	public ScpStream(String sFilename, int iMode, int iCacheMemory, int iLength) {
134		_iCacheMemory = iCacheMemory;
135		_iSize = 0;
136		_iReadCursor = 0;
137		_iWriteCursor = 0;
138		_bInsertText = false;
139		_iMode = iMode;
140		_sFilename = sFilename;
141		_iShiftedStreamPosition = 0;
142		_iLineCounter = 1;
143		_iLinePosition = 0;
144//##protect##"Java ScpStream::ScpStream.const string&.int.int.int"
145		throw new java.lang.RuntimeException("ScpStream::ScpStream.const string&.int.int.int not implemented yet!");
146//##protect##"Java ScpStream::ScpStream.const string&.int.int.int"
147	}
148
149	public ScpStream(String sFilename, java.io.InputStream f, int iCacheMemory) {
150		_sFilename = sFilename;
151		_iCacheMemory = iCacheMemory;
152		_iSize = 0;
153		_iReadCursor = 0;
154		_iWriteCursor = 0;
155		_bInsertText = false;
156		_iMode = IN;
157		_iShiftedStreamPosition = 0;
158		_iLineCounter = 1;
159		_iLinePosition = 0;
160//##protect##"Java ScpStream::ScpStream.const string&.FILE*.int"
161		int iFileSize = (int) new java.io.File(sFilename).length();
162		if (iFileSize >= _iCacheMemory) _iCacheMemory = iFileSize + 1;
163		_tcStream = new char[_iCacheMemory];
164		if (iFileSize > 0) {
165			byte[] tbFileData = new byte[iFileSize];
166			do {
167				iFileSize = f.read(tbFileData);
168				for (int i = 0; i < iFileSize; ++i) {
169					_tcStream[_iSize + i] = (char) tbFileData[i];
170				}
171				if (iFileSize > 0) _iSize += iFileSize;
172			} while (iFileSize >= 0);
173		}
174		f.close();
175//##protect##"Java ScpStream::ScpStream.const string&.FILE*.int"
176	}
177
178	public ScpStream(String sText) {
179		_iSize = 0;
180		_iReadCursor = 0;
181		_iWriteCursor = 0;
182		_bInsertText = false;
183		_iMode = 0;
184		_iShiftedStreamPosition = 0;
185		_iLineCounter = 1;
186		_iLinePosition = 0;
187//##protect##"Java ScpStream::ScpStream.const string&"
188		_iSize = sText.length();
189		_iCacheMemory = _iSize + 1;
190		_tcStream = new char[_iCacheMemory];
191		memcpy(_tcStream, sText.toCharArray());
192//##protect##"Java ScpStream::ScpStream.const string&"
193	}
194
195	public ScpStream(org.codeworker.ScpStream shiftedStream, int iShiftedStreamPosition) {
196		_iReadCursor = 0;
197		_iWriteCursor = 0;
198		_bInsertText = false;
199		_iMode = 0;
200		_pShiftedStream = shiftedStream;
201		_iShiftedStreamPosition = iShiftedStreamPosition;
202		_iLineCounter = 1;
203		_iLinePosition = 0;
204//##protect##"Java ScpStream::ScpStream.ScpStream&.int"
205		throw new java.lang.RuntimeException("ScpStream::ScpStream.ScpStream&.int not implemented yet!");
206//##protect##"Java ScpStream::ScpStream.ScpStream&.int"
207	}
208
209	 ScpStream() {
210		if ((_pShiftedStream == null))
211			_tcStream = null; // delete the object!
212	}
213
214	public static org.codeworker.ScpStream createFile(String sFilename) {
215		if (!existVirtualFile(sFilename))
216			{
217				java.io.InputStream f = new java.io.FileInputStream(sFilename);
218				if ((f == null))
219					{
220						if (createDirectoriesForFile(sFilename))
221							f = new java.io.FileInputStream(sFilename);
222						if ((f == null))
223							return null;
224					}
225				f.close();
226			}
227		org.codeworker.ScpStream pStream = new org.codeworker.ScpStream();
228		pStream.setFilename(sFilename);
229		return pStream;
230	}
231
232	public static boolean existInputFileFromIncludePath(String tcFileName, org.codeworker.StringRef sCompleteFileName) {
233//##protect##"Java ScpStream::existInputFileFromIncludePath.const char*.string&"
234		sCompleteFileName.ref_ = tcFileName;
235		if (existVirtualFile(tcFileName))
236			return true;
237		boolean bFile = existInputFile(sCompleteFileName.ref_);
238		if ((!bFile && ((sCompleteFileName.ref_.charAt(0) == '/') || (sCompleteFileName.ref_.charAt(1) == ':'))))
239			return false;
240		for (String i : org.codeworker.ScpStream._listOfIncludePaths) {
241			if (bFile) break;
242			sCompleteFileName.ref_ = i + tcFileName;
243			bFile = existInputFile(sCompleteFileName.ref_);
244		}
245		return bFile;
246//##protect##"Java ScpStream::existInputFileFromIncludePath.const char*.string&"
247	}
248
249	public static boolean existInputFile(String sFileName) {
250		if (existVirtualFile(sFileName))
251			return true;
252		java.io.FileInputStream pFile = openSTLInputFile(sFileName);
253		if ((pFile == null))
254			return false;
255		pFile.close();
256		pFile = null; // delete the object!
257		return true;
258	}
259
260	public static org.codeworker.ScpStream openInputFileFromIncludePath(String tcFileName, org.codeworker.StringRef sCompleteFileName) {
261//##protect##"Java ScpStream::openInputFileFromIncludePath.const char*.string&"
262		org.codeworker.StringRef sContent = new org.codeworker.StringRef();
263		if (loadVirtualFile(tcFileName, sContent))
264			{
265				org.codeworker.ScpStream pStream = new org.codeworker.ScpStream();
266				pStream.setFilename(tcFileName);
267				pStream.writeBinaryData(sContent.ref_.toCharArray(), sContent.ref_.length());
268				pStream.setOutputLocation(0);
269				sCompleteFileName.ref_ = tcFileName;
270				return pStream;
271			}
272		sCompleteFileName.ref_ = tcFileName;
273		java.io.FileInputStream pFile = openSTLInputFile(sCompleteFileName.ref_);
274		if (((pFile == null) && ((sCompleteFileName.ref_.charAt(0) == '/') || (sCompleteFileName.ref_.charAt(1) == ':'))))
275			return null;
276		for (String i : org.codeworker.ScpStream._listOfIncludePaths) {
277			if (pFile == null) break;
278			sCompleteFileName.ref_ = i + tcFileName;
279			pFile = openSTLInputFile(sCompleteFileName.ref_);
280		}
281		if ((pFile == null))
282			return null;
283		pFile.close();
284		pFile = null; // delete the object!
285		java.io.InputStream f = new java.io.FileInputStream(sCompleteFileName.ref_);
286		if ((f == null))
287			return null;
288		int iFileSize = (int) new java.io.File(sCompleteFileName.ref_).length();
289		return new org.codeworker.ScpStream(sCompleteFileName.ref_, f, iFileSize + 1);
290//##protect##"Java ScpStream::openInputFileFromIncludePath.const char*.string&"
291	}
292
293	public static org.codeworker.ScpStream openInputFile(String sFileName) {
294//##protect##"Java ScpStream::openInputFile.const char*"
295		org.codeworker.StringRef sContent = new org.codeworker.StringRef();
296		if (loadVirtualFile(sFileName, sContent))
297			{
298				org.codeworker.ScpStream pStream = new org.codeworker.ScpStream();
299				pStream.setFilename(sFileName);
300				pStream.writeBinaryData(sContent.ref_.toCharArray(), sContent.ref_.length());
301				pStream.setOutputLocation(0);
302				return pStream;
303			}
304		java.io.FileInputStream pFile = openSTLInputFile(sFileName);
305		if ((pFile == null))
306			return null;
307		pFile.close();
308		pFile = null; // delete the object!
309		java.io.InputStream f = new java.io.FileInputStream(sFileName);
310		if ((f == null))
311			return null;
312		int iFileSize = (int) new java.io.File(sFileName).length();
313		return new org.codeworker.ScpStream(sFileName, f, iFileSize + 1);
314//##protect##"Java ScpStream::openInputFile.const char*"
315	}
316
317	public char[] readBuffer() {
318		_tcStream[_iSize] = '\0';
319		return _tcStream;
320	}
321
322	public void setFilename(String sFilename) {
323		_sFilename = sFilename;
324	}
325
326	public String getFilename() {
327		return _sFilename;
328	}
329
330	public int size() {
331		return _iSize;
332	}
333
334	public boolean empty() {
335		return (_iSize == 0);
336	}
337
338	public boolean insertMode() {
339		return _bInsertText;
340	}
341
342	public void insertMode(boolean bInsertMode) {
343		_bInsertText = bInsertMode;
344	}
345
346	public org.codeworker.ScpStream getParentStream() {
347		return _pParentStream;
348	}
349
350	public void setParentStream(org.codeworker.ScpStream pStream) {
351		_pParentStream = pStream;
352	}
353
354	public org.codeworker.END_STREAM_CALLBACK getStreamReaderCallback() {
355		return _pfStreamReaderCallback;
356	}
357
358	public void setStreamReaderCallback(org.codeworker.END_STREAM_CALLBACK pfCBK, java.lang.Object pData) {
359		_pfStreamReaderCallback = pfCBK;
360		_pStreamReaderCBKData = pData;
361	}
362
363	public org.codeworker.END_STREAM_CALLBACK getStreamWriterCallback() {
364		return _pfStreamWriterCallback;
365	}
366
367	public void setStreamWriterCallback(org.codeworker.END_STREAM_CALLBACK pfCBK, java.lang.Object pData) {
368		_pfStreamWriterCallback = pfCBK;
369		_pStreamWriterCBKData = pData;
370	}
371
372	public String getIndentation() {
373		return _sIndentation;
374	}
375
376	public void incrementIndentation(int iLevel) {
377		while ((iLevel > 0))
378			{
379				_sIndentation += "\t";
380				--iLevel;
381			}
382	}
383
384	public boolean decrementIndentation(int iLevel) {
385//##protect##"Java ScpStream::decrementIndentation.int"
386		if ((_sIndentation.length() < iLevel))
387			{
388				_sIndentation = new String("");
389				return false;
390			}
391		_sIndentation = _sIndentation.substring(iLevel);
392		return true;
393//##protect##"Java ScpStream::decrementIndentation.int"
394	}
395
396	public String getMessagePrefix(boolean bCountCols) {
397//##protect##"Java ScpStream::getMessagePrefix.bool.const"
398		String sFilename = _sFilename;
399		int iIndex = Math.max(sFilename.lastIndexOf("\\"), sFilename.lastIndexOf("\\"));
400		if ((iIndex != -1/*npos*/))
401			sFilename = sFilename.substring(iIndex + 1);
402		String sMessage;
403		if (bCountCols)
404			sMessage = sFilename + "(" + getLineCount() + "): ";
405		else
406			sMessage = sFilename + "(" + getLineCount() + "," + getColCount() + "): ";
407		return sMessage;
408//##protect##"Java ScpStream::getMessagePrefix.bool.const"
409	}
410
411	public int readChar() {
412//##protect##"Java ScpStream::readChar"
413		if ((_iSize <= _iReadCursor))
414		{
415			if ((_pNextStream != null))
416				return _pNextStream.readChar();
417			if ((_pfStreamReaderCallback == null))
418				return -1;
419			_pfStreamReaderCallback.callback(this, _pStreamReaderCBKData);
420			if ((_iSize <= _iReadCursor))
421				return -1;
422		}
423	byte c = (byte) _tcStream[_iReadCursor++];
424	return (int) c;
425//##protect##"Java ScpStream::readChar"
426	}
427
428	public int peekChar() {
429//##protect##"Java ScpStream::peekChar"
430		if ((_iSize <= _iReadCursor))
431		{
432			if ((_pNextStream != null))
433				return _pNextStream.peekChar();
434			return -1;
435		}
436	byte c = (byte) _tcStream[_iReadCursor];
437	return (int) c;
438//##protect##"Java ScpStream::peekChar"
439	}
440
441	public int getInputLocation() {
442		return _iReadCursor;
443	}
444
445	public void setInputLocation(int iLocation) {
446		if ((iLocation <= _iSize))
447			_iReadCursor = iLocation;
448	}
449
450	public int getOutputLocation() {
451		return _iWriteCursor;
452	}
453
454	public void setOutputLocation(int iLocation) {
455		if ((iLocation <= _iSize))
456			_iWriteCursor = iLocation;
457	}
458
459	public SizeAttributes resize(int iNewSize) {
460		SizeAttributes sizeAttrs = new SizeAttributes();
461		if (((iNewSize >= 0) && (iNewSize < _iSize)))
462			{
463				sizeAttrs._iSize = _iSize;
464				sizeAttrs._iWriteCursor = _iWriteCursor;
465				sizeAttrs._iReadCursor = _iReadCursor;
466				sizeAttrs._cEndChar = _tcStream[iNewSize];
467				_iSize = iNewSize;
468				if ((_iWriteCursor > _iSize))
469					_iWriteCursor = _iSize;
470				if ((_iReadCursor > _iSize))
471					_iReadCursor = _iSize;
472				if ((_pShiftedStream != null))
473					{
474						sizeAttrs._pShiftedStream = new SizeAttributes(_pShiftedStream.resize((iNewSize + _iShiftedStreamPosition)));
475					}
476			}
477		return sizeAttrs;
478	}
479
480	public void restoreSize(SizeAttributes sizeAttrs) {
481		if (!sizeAttrs.empty())
482			{
483				_tcStream[_iSize] = sizeAttrs._cEndChar;
484				_iSize = sizeAttrs._iSize;
485				_iWriteCursor = sizeAttrs._iWriteCursor;
486				_iReadCursor = sizeAttrs._iReadCursor;
487				if (((_pShiftedStream != null) && (sizeAttrs._pShiftedStream != null)))
488					{
489						_pShiftedStream.restoreSize(sizeAttrs._pShiftedStream);
490					}
491			}
492	}
493
494	public void setLineDirective(int iLine) {
495		_iLineCounter = iLine;
496		_iLinePosition = _iReadCursor;
497	}
498
499	public int getLineCount() {
500		int iLine = _iLineCounter;
501		int iCursor = _iLinePosition;
502		while ((iCursor < _iReadCursor))
503			{
504				if ((_tcStream[iCursor++] == ((int) '\n')))
505					++iLine;
506			}
507		return iLine;
508	}
509
510	public int getOutputLineCount() {
511		int iLine = 1;
512		int iCursor = 0;
513		while ((iCursor < _iWriteCursor))
514			{
515				if ((_tcStream[iCursor++] == ((int) '\n')))
516					++iLine;
517			}
518		return iLine;
519	}
520
521	public int getColCount() {
522		int iPosition = _iReadCursor;
523		int iCurrent = _iReadCursor;
524		while ((iCurrent > 0))
525			{
526				--iCurrent;
527				if ((_tcStream[iCurrent] == ((int) '\n')))
528					{
529						return (iPosition - iCurrent);
530					}
531			}
532		return (1 + iPosition);
533	}
534
535	public int getOutputColCount() {
536		int iPosition = _iWriteCursor;
537		int iCurrent = _iWriteCursor;
538		while ((iCurrent > 0))
539			{
540				--iCurrent;
541				if ((_tcStream[iCurrent] == ((int) '\n')))
542					{
543						return (iPosition - iCurrent);
544					}
545			}
546		return (1 + iPosition);
547	}
548
549	public boolean goBack() {
550		if ((_iReadCursor <= 0))
551			{
552				if ((_pPrecStream != null))
553					return _pPrecStream.goBack();
554				return false;
555			}
556		--_iReadCursor;
557		return true;
558	}
559
560	public boolean skipBlanks() {
561		int iChar = readChar();
562		while (((iChar >= ((int) '\0')) && (iChar <= ((int) ' '))))
563			iChar = readChar();
564		if ((iChar < 0))
565			return false;
566		goBack();
567		return true;
568	}
569
570	public boolean skipLineBlanks() {
571		int iChar = readChar();
572		while (((((iChar >= ((int) '\0')) && (iChar <= ((int) ' '))) && (iChar != '\r')) && (iChar != '\n')))
573			iChar = readChar();
574		if ((iChar < 0))
575			return false;
576		goBack();
577		return true;
578	}
579
580	public boolean skipCppComments() {
581		int iCursor = getInputLocation();
582		int iChar = readChar();
583		if ((iChar == ((int) '/')))
584			{
585				iChar = readChar();
586				if ((iChar == ((int) '/')))
587					do
588						iChar = readChar();
589					while (((iChar >= 0) && (iChar != ((int) '\n'))));
590				else
591					if ((iChar == ((int) '*')))
592						{
593							iChar = readChar();
594							do
595								{
596									if ((iChar == ((int) '*')))
597										{
598											iChar = readChar();
599											if ((iChar == ((int) '/')))
600												break;
601										}
602									else
603										{
604											iChar = readChar();
605										}
606								}
607							while ((iChar >= 0));
608							if ((iChar < 0))
609								{
610									setInputLocation(iCursor);
611									return false;
612								}
613						}
614					else
615						{
616							setInputLocation(iCursor);
617							return false;
618						}
619			}
620		else
621			{
622				setInputLocation(iCursor);
623				return false;
624			}
625		return true;
626	}
627
628	public boolean skipCppExceptDoxygenComments() {
629		int iCursor = getInputLocation();
630		int iChar = readChar();
631		if ((iChar == ((int) '/')))
632			{
633				iChar = readChar();
634				if ((iChar == ((int) '/')))
635					{
636						iChar = readChar();
637						if ((iChar == ((int) '!')))
638							{
639								setInputLocation(iCursor);
640								return false;
641							}
642						do
643							iChar = readChar();
644						while (((iChar >= 0) && (iChar != ((int) '\n'))));
645					}
646				else
647					if ((iChar == ((int) '*')))
648						{
649							iChar = readChar();
650							if ((iChar == ((int) '!')))
651								{
652									setInputLocation(iCursor);
653									return false;
654								}
655							do
656								{
657									if ((iChar == ((int) '*')))
658										{
659											iChar = readChar();
660											if ((iChar == ((int) '/')))
661												break;
662										}
663									else
664										{
665											iChar = readChar();
666										}
667								}
668							while ((iChar >= 0));
669							if ((iChar < 0))
670								{
671									setInputLocation(iCursor);
672									return false;
673								}
674						}
675					else
676						{
677							setInputLocation(iCursor);
678							return false;
679						}
680			}
681		else
682			{
683				setInputLocation(iCursor);
684				return false;
685			}
686		return true;
687	}
688
689	public boolean skipEmpty() {
690		boolean bSuccess;
691		do
692			bSuccess = skipBlanks();
693		while ((bSuccess && skipCppComments()));
694		return bSuccess;
695	}
696
697	public boolean skipEmptyCppExceptDoxygen() {
698		boolean bSuccess;
699		do
700			bSuccess = skipBlanks();
701		while ((bSuccess && skipCppExceptDoxygenComments()));
702		return bSuccess;
703	}
704
705	public boolean skipEmptyAda() {
706		boolean bSuccess = skipBlanks();
707		while ((bSuccess && isEqualTo("--")))
708			{
709				int iChar;
710				do
711					iChar = readChar();
712				while (((iChar >= 0) && (iChar != ((int) '\n'))));
713				if ((iChar < 0))
714					return false;
715				bSuccess = skipBlanks();
716			}
717		return bSuccess;
718	}
719
720	public boolean skipEmptyHTML() {
721		int iChar;
722		for (;;)
723			{
724				do
725					iChar = readChar();
726				while (((iChar >= ((int) '\0')) && (iChar <= ((int) ' '))));
727				if (((iChar == ((int) '<')) && isEqualTo("!--")))
728					{
729						do
730							{
731								do
732									iChar = readChar();
733								while (((iChar >= 0) && (iChar != ((int) '-'))));
734							}
735						while (((iChar >= 0) && !isEqualTo("->")));
736					}
737				else
738					break;
739			}
740		if ((iChar < 0))
741			return false;
742		goBack();
743		return true;
744	}
745
746	public boolean skipEmptyLaTeX() {
747		int iChar = peekChar();
748		if ((iChar != ((int) '%')))
749			return false;
750		do
751			{
752				++_iReadCursor;
753				do
754					iChar = readChar();
755				while (((iChar >= 0) && (iChar != ((int) '\n'))));
756			}
757		while (((iChar == '\n') && (peekChar() == '%')));
758		return true;
759	}
760
761	public boolean skipLine() {
762		int iChar;
763		int i = 0;
764		for (;;)
765			{
766				iChar = readChar();
767				if (((iChar == '\n') || (iChar < 0)))
768					break;
769				++i;
770			}
771		if ((iChar >= 0))
772			isEqualTo('\r');
773		return ((iChar >= 0) || (i > 0));
774	}
775
776	public boolean readChars(int iLength, org.codeworker.StringRef sText) {
777		if ((_iSize < (_iReadCursor + iLength)))
778			{
779				_tcStream[_iSize] = '\0';
780				sText.ref_ += String.copyValueOf(_tcStream, _iReadCursor, _tcStream.length - _iReadCursor);
781				iLength += (_iReadCursor - _iSize);
782				_iReadCursor = _iSize;
783				if ((_pNextStream != null))
784					return _pNextStream.readChars(iLength, sText);
785				if ((_pfStreamReaderCallback == null))
786					return false;
787				int iOldSize = _iSize;
788				do
789					{
790						_pfStreamReaderCallback.callback(this, _pStreamReaderCBKData);
791						if ((iOldSize == _iSize))
792							return false;
793						iOldSize = _iSize;
794					}
795				while ((_iSize < (_iReadCursor + iLength)));
796			}
797		char c = _tcStream[(_iReadCursor + iLength)];
798		_tcStream[(_iReadCursor + iLength)] = '\0';
799		sText.ref_ += String.copyValueOf(_tcStream, _iReadCursor, _tcStream.length - _iReadCursor);
800		_iReadCursor += iLength;
801		_tcStream[_iReadCursor] = c;
802		return true;
803	}
804
805	public boolean readWord(org.codeworker.StringRef sWord) {
806//##protect##"Java ScpStream::readWord.string&"
807		int iIndex = 0;
808		int iChar;
809		int iPos = _iReadCursor;
810		do
811			{
812				iChar = readChar();
813				++iIndex;
814			}
815		while ((((((((((((((((iChar >= ((int) 'a')) && (iChar <= ((int) 'z'))) || ((iChar >= ((int) 'A')) && (iChar <= ((int) 'Z')))) || ((iChar >= ((int) '0')) && (iChar <= ((int) '9')))) || (iChar == ((int) '_'))) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')) || (iChar == '�')));
816		if ((iChar >= 0))
817			goBack();
818		--iIndex;
819		if ((iIndex == 0))
820			sWord.ref_ = new String("");
821		else
822			sWord.ref_ = String.copyValueOf(_tcStream, iPos, iIndex);
823		return (iIndex > 0);
824//##protect##"Java ScpStream::readWord.string&"
825	}
826
827	public boolean readIdentifier(org.codeworker.StringRef sIdentifier) {
828		byte[] tcText = new byte[1000];
829		int iIndex = 0;
830		int iChar;
831		iChar = readChar();
832		if (((((iChar >= ((int) 'a')) && (iChar <= ((int) 'z'))) || ((iChar >= ((int) 'A')) && (iChar <= ((int) 'Z')))) || (iChar == ((int) '_'))))
833			{
834				tcText[iIndex++] = ((byte) iChar);
835				do
836					{
837						iChar = readChar();
838						tcText[iIndex++] = ((byte) iChar);
839					}
840				while ((((((iChar >= ((int) 'a')) && (iChar <= ((int) 'z'))) || ((iChar >= ((int) 'A')) && (iChar <= ((int) 'Z')))) || ((iChar >= ((int) '0')) && (iChar <= ((int) '9')))) || (iChar == ((int) '_'))));
841				--iIndex;
842				tcText[iIndex] = '\0';
843				sIdentifier.ref_ = new String(tcText);
844			}
845		if ((iChar >= 0))
846			goBack();
847		return (iIndex >= 1);
848	}
849
850	public boolean readInt(int iResult) {
851		byte[] tcReadInt = new byte[32];
852		int iIndex = 0;
853		int iChar = readChar();
854		if ((iChar == ((int) '-')))
855			{
856				tcReadInt[iIndex++] = '-';
857				iChar = readChar();
858			}
859		if (((iChar < ((int) '0')) || (iChar > ((int) '9'))))
860			{
861				if ((iChar >= 0))
862					goBack();
863				if ((iIndex != 0))
864					goBack();
865				return false;
866			}
867		tcReadInt[iIndex++] = ((byte) iChar);
868		iChar = readChar();
869		while (((iChar >= ((int) '0')) && (iChar <= ((int) '9'))))
870			{
871				tcReadInt[iIndex++] = ((byte) iChar);
872				iChar = readChar();
873			}
874		if ((iChar >= 0))
875			setInputLocation((getInputLocation() - 1));
876		tcReadInt[iIndex] = '\0';
877		iResult = java.lang.Integer.parseInt(new String(new String(tcReadInt)));
878		return true;
879	}
880
881	public boolean readHexadecimal(int iResult) {
882		int iChar = readChar();
883		if (((((iChar < ((int) '0')) || (iChar > ((int) '9'))) && ((iChar < ((int) 'A')) || (iChar > ((int) 'F')))) && ((iChar < ((int) 'a')) || (iChar > ((int) 'f')))))
884			{
885				if ((iChar >= 0))
886					goBack();
887				return false;
888			}
889		iResult = 0;
890		for (;;)
891			{
892				int iDigit;
893				if (((iChar >= ((int) '0')) && (iChar <= ((int) '9'))))
894					iDigit = (iChar - ((int) '0'));
895				else
896					if (((iChar >= ((int) 'A')) && (iChar <= ((int) 'F'))))
897						iDigit = ((10 + iChar) - ((int) 'A'));
898					else
899						if (((iChar >= ((int) 'a')) && (iChar <= ((int) 'f'))))
900							iDigit = ((10 + iChar) - ((int) 'a'));
901						else
902							break;
903				iResult = ((16 * iResult) + iDigit);
904				iChar = readChar();
905			}
906		if ((iChar >= 0))
907			goBack();
908		return true;
909	}
910
911	public boolean readDouble(double dValue) {
912		byte[] tcReadDouble = new byte[32];
913		int iIndex = 0;
914		int iPosition = getInputLocation();
915		int iChar = readChar();
916		if ((iChar == ((int) '-')))
917			{
918				tcReadDouble[iIndex++] = '-';
919				iChar = readChar();
920			}
921		else
922			if ((iChar == ((int) '+')))
923				{
924					iChar = readChar();
925				}
926		if (((iChar < ((int) '0')) || (iChar > ((int) '9'))))
927			{
928				setInputLocation(iPosition);
929				return false;
930			}
931		tcReadDouble[iIndex++] = ((byte) iChar);
932		iChar = readChar();
933		while (((iChar >= ((int) '0')) && (iChar <= ((int) '9'))))
934			{
935				tcReadDouble[iIndex++] = ((byte) iChar);
936				iChar = readChar();
937			}
938		if (((iChar == ((int) '.')) && (peekChar() != ((int) '.'))))
939			{
940				tcReadDouble[iIndex++] = '.';
941				iChar = readChar();
942				while (((iChar >= ((int) '0')) && (iChar <= ((int) '9'))))
943					{
944						tcReadDouble[iIndex++] = ((byte) iChar);
945						iChar = readChar();
946					}
947			}
948		if (((iChar == ((int) 'e')) || (iChar == ((int) 'E'))))
949			{
950				int iCursor = getInputLocation();
951				int iMarkedIndex = iIndex;
952				tcReadDouble[iIndex++] = 'E';
953				iChar = readChar();
954				if ((iChar == ((int) '-')))
955					{
956						tcReadDouble[iIndex++] = ((byte) iChar);
957						iChar = readChar();
958					}
959				else
960					if ((iChar == ((int) '+')))
961						{
962							iChar = readChar();
963						}
964				if (((iChar < ((int) '0')) || (iChar > ((int) '9'))))
965					{
966						iIndex = iMarkedIndex;
967						setInputLocation(iCursor);
968					}
969				else
970					{
971						tcReadDouble[iIndex++] = ((byte) iChar);
972						iChar = readChar();
973						while (((iChar >= ((int) '0')) && (iChar <= ((int) '9'))))
974							{
975								tcReadDouble[iIndex++] = ((byte) iChar);
976								iChar = readChar();
977							}
978					}
979			}
980		if ((iChar >= 0))
981			goBack();
982		tcReadDouble[iIndex] = '\0';
983		dValue = java.lang.Double.parseDouble(new String(new String(tcReadDouble)));
984		return true;
985	}
986
987	public boolean readStringOrCharLiteral(org.codeworker.StringRef sText) {
988//##protect##"Java ScpStream::readStringOrCharLiteral.string&"
989		if (readString(sText))
990			return true;
991		int iChar;
992		if (!readCharLiteral(iChar))
993			return false;
994		sText.ref_ = String.valueOf((char) iChar);
995		return true;
996//##protect##"Java ScpStream::readStringOrCharLiteral.string&"
997	}
998
999	public boolean readCharLiteral(int iChar) {
1000		int iPosition = getInputLocation();
1001		if (!isEqualTo('\''))
1002			return false;
1003		iChar = readChar();
1004		if ((iChar == '\\'))
1005			{
1006				iChar = readChar();
1007				switch(iChar) {
1008					case 'a':
1009						iChar = '\007';
1010						break;
1011					case 'b':
1012						iChar = '\b';
1013						break;
1014					case 'f':
1015						iChar = '\f';
1016						break;
1017					case 'n':
1018						iChar = '\n';
1019						break;
1020					case 'r':
1021						iChar = '\r';
1022						break;
1023					case 't':
1024						iChar = '\t';
1025						break;
1026					case 'v':
1027						iChar = '\013';
1028						break;
1029					case 'u':
1030						readHexadecimal(iChar);
1031						break;
1032					case '0':
1033						{
1034							iChar = 0;
1035							int iCurrentChar = readChar();
1036							if ((iCurrentChar == ((int) 'x')))
1037								{
1038									do
1039										{
1040											iCurrentChar = readChar();
1041											if (((iCurrentChar >= '0') && (iCurrentChar <= '9')))
1042												{
1043													iChar *= 16;
1044													iChar += (iCurrentChar - ((int) '0'));
1045												}
1046											else
1047												if (((iCurrentChar >= 'a') && (iCurrentChar <= 'f')))
1048													{
1049														iChar *= 16;
1050														iChar += ((iCurrentChar - ((int) 'a')) + 10);
1051													}
1052												else
1053													if (((iCurrentChar >= 'A') && (iCurrentChar <= 'F')))
1054														{
1055															iChar *= 16;
1056															iChar += ((iCurrentChar - ((int) 'A')) + 10);
1057														}
1058													else
1059														break;
1060										}
1061									while (true);
1062								}
1063							else
1064								if (((iCurrentChar >= ((int) '0')) && (iCurrentChar <= ((int) '7'))))
1065									{
1066										iChar = (iCurrentChar - ((int) '0'));
1067										do
1068											{
1069												iCurrentChar = readChar();
1070												if (((iCurrentChar >= '0') && (iCurrentChar <= '7')))
1071													{
1072														iChar *= 8;
1073														iChar += (iCurrentChar - ((int) '0'));
1074													}
1075												else
1076													break;
1077											}
1078										while (true);
1079									}
1080							goBack();
1081						}
1082						break;
1083					case '1':
1084					case '2':
1085					case '3':
1086						{
1087							iChar -= '0';
1088							int iCurrentChar;
1089							do
1090								{
1091									iCurrentChar = readChar();
1092									if (((iCurrentChar >= '0') && (iCurrentChar <= '7')))
1093										{
1094											iChar *= 8;
1095											iChar += (iCurrentChar - ((int) '0'));
1096										}
1097									else
1098										break;
1099								}
1100							while (true);
1101						}
1102						break;
1103				}
1104			}
1105		if (!isEqualTo('\''))
1106			{
1107				setInputLocation(iPosition);
1108				return false;
1109			}
1110		return true;
1111	}
1112
1113	public boolean readString(org.codeworker.StringRef sText) {
1114		byte[] tcReadString = new byte[32000];
1115		int iIndex = 0;
1116		int iLocation = _iReadCursor;
1117		int iChar = readChar();
1118		if ((iChar != ((int) '\"')))
1119			{
1120				if ((iChar >= 0))
1121					goBack();
1122				return false;
1123			}
1124		iChar = readChar();
1125		while (((iChar >= 0) && (iChar != ((int) '\"'))))
1126			{
1127				if ((iChar == '\\'))
1128					{
1129						iChar = readChar();
1130						switch(iChar) {
1131							case 'a':
1132								iChar = '\007';
1133								break;
1134							case 'b':
1135								iChar = '\b';
1136								break;
1137							case 'f':
1138								iChar = '\f';
1139								break;
1140							case 'n':
1141								iChar = '\n';
1142								break;
1143							case 'r':
1144								iChar = '\r';
1145								break;
1146							case 't':
1147								iChar = '\t';
1148								break;
1149							case 'v':
1150								iChar = '\013';
1151								break;
1152							case 'u':
1153								if (!readHexadecimal(iChar))
1154									{
1155										_iReadCursor = iLocation;
1156										return false;
1157									}
1158								break;
1159							case '0':
1160								{
1161									iChar = 0;
1162									int iCurrentChar = readChar();
1163									if ((iCurrentChar == ((int) 'x')))
1164										{
1165											do
1166												{
1167													iCurrentChar = readChar();
1168													if (((iCurrentChar >= '0') && (iCurrentChar <= '9')))
1169														{
1170															iChar *= 16;
1171															iChar += (iCurrentChar - ((int) '0'));
1172														}
1173													else
1174														if (((iCurrentChar >= 'a') && (iCurrentChar <= 'f')))
1175															{
1176																iChar *= 16;
1177																iChar += ((iCurrentChar - ((int) 'a')) + 10);
1178															}
1179														else
1180															if (((iCurrentChar >= 'A') && (iCurrentChar <= 'F')))
1181																{
1182																	iChar *= 16;
1183																	iChar += ((iCurrentChar - ((int) 'A')) + 10);
1184																}
1185															else
1186																break;
1187												}
1188											while (true);
1189										}
1190									else
1191										if (((iCurrentChar >= ((int) '0')) && (iCurrentChar <= ((int) '7'))))
1192											{
1193												iChar = (iCurrentChar - ((int) '0'));
1194												do
1195													{
1196														iCurrentChar = readChar();
1197														if (((iCurrentChar >= '0') && (iCurrentChar <= '7')))
1198															{
1199																iChar *= 8;
1200																iChar += (iCurrentChar - ((int) '0'));
1201															}
1202														else
1203															break;
1204													}
1205												while (true);
1206											}
1207									goBack();
1208								}
1209								break;
1210							case '1':
1211							case '2':
1212							case '3':
1213								{
1214									iChar -= '0';
1215									int iCurrentChar;
1216									do
1217										{
1218											iCurrentChar = readChar();
1219											if (((iCurrentChar >= '0') && (iCurrentChar <= '7')))
1220												{
1221													iChar *= 8;
1222													iChar += (iCurrentChar - ((int) '0'));
1223												}
1224											else
1225												break;
1226										}
1227									while (true);
1228								}
1229								break;
1230						}
1231					}
1232				else
1233					if ((iChar == ((int) '\n')))
1234						{
1235							break;
1236						}
1237				tcReadString[iIndex++] = ((byte) iChar);
1238				iChar = readChar();
1239			}
1240		if ((iChar != ((int) '\"')))
1241			{
1242				_iReadCursor = iLocation;
1243				return false;
1244			}
1245		tcReadString[iIndex] = '\0';
1246		sText.ref_ = new String(tcReadString);
1247		return true;
1248	}
1249
1250	public boolean readAdaString(org.codeworker.StringRef sText) {
1251		byte[] tcReadAdaString = new byte[32000];
1252		int iIndex = 0;
1253		int iLocation = _iReadCursor;
1254		int iChar = readChar();
1255		if ((iChar != ((int) '\"')))
1256			{
1257				if ((iChar >= 0))
1258					goBack();
1259				return false;
1260			}
1261		iChar = readChar();
1262		while ((iChar >= 0))
1263			{
1264				if ((iChar == '\"'))
1265					{
1266						if ((peekChar() != '\"'))
1267							break;
1268						iChar = readChar();
1269					}
1270				tcReadAdaString[iIndex++] = ((byte) iChar);
1271				iChar = readChar();
1272			}
1273		if ((iChar != ((int) '\"')))
1274			{
1275				_iReadCursor = iLocation;
1276				return false;
1277			}
1278		tcReadAdaString[iIndex] = '\0';
1279		sText.ref_ = new String(tcReadAdaString);
1280		return true;
1281	}
1282
1283	public boolean readLine(org.codeworker.StringRef sLine) {
1284		char[] tcReadLine = new char[10000];
1285		int i = 0;
1286		int iChar;
1287		do
1288			{
1289				iChar = readChar();
1290				if (((iChar == '\n') || (iChar < 0)))
1291					break;
1292				tcReadLine[i++] = ((char) iChar);
1293			}
1294		while (true);
1295		if ((iChar >= 0))
1296			isEqualTo('\r');
1297		if (((i > 0) && (tcReadLine[(i - 1)] == '\r')))
1298			--i;
1299		tcReadLine[i] = '\0';
1300		sLine.ref_ = new String(tcReadLine);
1301		return ((iChar >= 0) || (i > 0));
1302	}
1303
1304	public boolean readLastChars(int iLength, org.codeworker.StringRef sLastChars) {
1305		if ((iLength < 0))
1306			return false;
1307		char a = (((_iSize > _iReadCursor)) ? _tcStream[_iReadCursor] : '\0');
1308		_tcStream[_iReadCursor] = '\0';
1309		if (((_iReadCursor - iLength) > 0))
1310			sLastChars.ref_ = String.copyValueOf(_tcStream, (_iReadCursor - iLength), _tcStream.length - (_iReadCursor - iLength));
1311		else
1312			sLastChars.ref_ = new String(_tcStream);
1313		_tcStream[_iReadCursor] = a;
1314		return true;
1315	}
1316
1317	public boolean readUptoChar(char cEnd, org.codeworker.StringRef sText) {
1318		int iLocation = getInputLocation();
1319		String sLocalText = new String();
1320		int iChar = readChar();
1321		while (((iChar > 0) && (iChar != ((int) cEnd))))
1322			{
1323				sLocalText += ((char) iChar);
1324				iChar = readChar();
1325			}
1326		if ((iChar < 0))
1327			{
1328				setInputLocation(iLocation);
1329				return false;
1330			}
1331		sText.ref_ = sLocalText;
1332		goBack();
1333		return true;
1334	}
1335
1336	public boolean readUptoChar(String sEnd, org.codeworker.StringRef sText) {
1337//##protect##"Java ScpStream::readUptoChar.const string&.string&"
1338		int iLocation = getInputLocation();
1339		String sLocalText = new String();
1340		int iChar = readChar();
1341		while ((iChar > 0) && !sEnd.contains(String.valueOf((char) iChar)))
1342			{
1343				sLocalText += ((char) iChar);
1344				iChar = readChar();
1345			}
1346		if ((iChar < 0))
1347			{
1348				setInputLocation(iLocation);
1349				return false;
1350			}
1351		sText.ref_ = sLocalText;
1352		goBack();
1353		return true;
1354//##protect##"Java ScpStream::readUptoChar.const string&.string&"
1355	}
1356
1357	public boolean isEqualTo(byte ch) {
1358		int iChar = readChar();
1359		if ((iChar == ((int) ch)))
1360			return true;
1361		if ((iChar >= 0))
1362			goBack();
1363		return false;
1364	}
1365
1366	public boolean isEqualTo(char[] sText) {
1367		int iChar;
1368		int iPosition = getInputLocation();
1369		for (int i = 0;(sText[i] != '\0');++i)
1370			{
1371				iChar = readChar();
1372				if (((iChar < 0) || (((char) iChar) != sText[i])))
1373					{
1374						setInputLocation(iPosition);
1375						return false;
1376					}
1377			}
1378		return true;
1379	}
1380
1381	public boolean isEqualTo(String sText) {
1382		return isEqualTo(sText.toCharArray());
1383	}
1384
1385	public boolean isEqualToIgnoreCase(byte ch) {
1386		int iChar = readChar();
1387		if (((ch >= 'A') && (ch <= 'Z')))
1388			ch += ' ';
1389		if (((iChar >= 'A') && (iChar <= 'Z')))
1390			iChar += 32;
1391		if ((iChar == ((int) ch)))
1392			return true;
1393		if ((iChar >= 0))
1394			goBack();
1395		return false;
1396	}
1397
1398	public boolean isEqualToIgnoreCase(char[] sText) {
1399		int iChar;
1400		int iPosition = getInputLocation();
1401		for (int i = 0;(sText[i] != '\0');++i)
1402			{
1403				iChar = readChar();
1404				if (((iChar >= 'A') && (iChar <= 'Z')))
1405					iChar += 32;
1406				char a = sText[i];
1407				if (((a >= 'A') && (a <= 'Z')))
1408					a += ' ';
1409				if (((iChar < 0) || (((char) iChar) != a)))
1410					{
1411						setInputLocation(iPosition);
1412						return false;
1413					}
1414			}
1415		return true;
1416	}
1417
1418	public boolean isEqualToIgnoreCase(String sText) {
1419		return isEqualToIgnoreCase(sText.toCharArray());
1420	}
1421
1422	public boolean isEqualToIdentifier(String sText) {
1423		int iPosition = getInputLocation();
1424		org.codeworker.StringRef sIdentifier = new org.codeworker.StringRef();
1425		if (!readIdentifier(sIdentifier))
1426			return false;
1427		if (!sIdentifier.ref_.equals(sText))
1428			{
1429				setInputLocation(iPosition);
1430				return false;
1431			}
1432		return true;
1433	}
1434
1435	public boolean findString(char[] sText) {
1436		int iChar = -1;
1437		int iPosition = getInputLocation();
1438		int iCurrent = iPosition;
1439		int i;
1440		do
1441			{
1442				setInputLocation(iCurrent);
1443				for ( i = 0;(sText[i] != '\0');++i)
1444					{
1445						iChar = readChar();
1446						if ((iChar < 0))
1447							break;
1448						if ((((char) iChar) != sText[i]))
1449							break;
1450					}
1451				++iCurrent;
1452			}
1453		while (((iChar >= 0) && (sText[i] != '\0')));
1454		if ((sText[i] == '\0'))
1455			return true;
1456		setInputLocation(iPosition);
1457		return false;
1458	}
1459
1460	public boolean findString(char[] sText, int iBoundary) {
1461		int iChar = -1;
1462		int iPosition = getInputLocation();
1463		int iCurrent = iPosition;
1464		int i;
1465		do
1466			{
1467				setInputLocation(iCurrent);
1468				for ( i = 0;(sText[i] != '\0');++i)
1469					{
1470						iChar = readChar();
1471						if ((iChar < 0))
1472							break;
1473						if ((((char) iChar) != sText[i]))
1474							break;
1475					}
1476				++iCurrent;
1477			}
1478		while ((((iChar >= 0) && (sText[i] != '\0')) && (iCurrent < iBoundary)));
1479		if ((sText[i] == '\0'))
1480			return true;
1481		setInputLocation(iPosition);
1482		return false;
1483	}
1484
1485	public boolean findString(String sText) {
1486		return findString(sText.toCharArray());
1487	}
1488
1489	public boolean findString(String sText, int iBoundary) {
1490		return findString(sText.toCharArray(), iBoundary);
1491	}
1492
1493	public java.util.Map<String,java.lang.Integer> allFloatingLocations() {
1494		return _mapOfFloatingLocations;
1495	}
1496
1497	public boolean newFloatingLocation(String sKey) {
1498		_mapOfFloatingLocations.put(sKey, getOutputLocation());
1499		return true;
1500	}
1501
1502	public void setFloatingLocation(String sKey, int iLocation) {
1503		_mapOfFloatingLocations.put(sKey, iLocation);
1504	}
1505
1506	public int getFloatingLocation(String sKey, org.codeworker.ScpStream pOwner) {
1507		java.util.MapIterator<String,java.lang.Integer> cursor = _mapOfFloatingLocations.find(sKey);
1508		if ((cursor == _mapOfFloatingLocations.end()))
1509			{
1510				if ((_pParentStream != null))
1511					return _pParentStream.getFloatingLocation(sKey, pOwner);
1512				pOwner = null;
1513				return -1;
1514			}
1515		pOwner = this;
1516		return cursor.second;
1517	}
1518
1519	public int removeFloatingLocation(String sKey, org.codeworker.ScpStream pOwner) {
1520		java.util.MapIterator<String,java.lang.Integer> cursor = _mapOfFloatingLocations.find(sKey);
1521		if ((cursor == _mapOfFloatingLocations.end()))
1522			{
1523				if ((_pParentStream != null))
1524					return _pParentStream.removeFloatingLocation(sKey, pOwner);
1525				pOwner = null;
1526				return -1;
1527			}
1528		pOwner = this;
1529		int iPosition = cursor.second;
1530		_mapOfFloatingLocations.erase(cursor);
1531		return iPosition;
1532	}
1533
1534	public org.codeworker.ScpStream writeOperator(char cValue) {
1535		WRITECHAR(cValue);
1536		if ((_iWriteCursor > _iSize))
1537			_iSize = _iWriteCursor;
1538		return this;
1539	}
1540
1541	public org.codeworker.ScpStream writeOperator(byte cValue) {
1542		WRITECHAR(cValue);
1543		if ((_iWriteCursor > _iSize))
1544			_iSize = _iWriteCursor;
1545		return this;
1546	}
1547
1548	public org.codeworker.ScpStream writeOperator(int iValue) {
1549//##protect##"Java ScpStream::operator<<.double"
1550		writeText(String.valueOf(iValue));
1551		return this;
1552//##protect##"Java ScpStream::operator<<.double"
1553	}
1554
1555	public org.codeworker.ScpStream writeOperator(long lValue) {
1556//##protect##"Java ScpStream::operator<<.double"
1557		writeText(String.valueOf(lValue));
1558		return this;
1559//##protect##"Java ScpStream::operator<<.double"
1560	}
1561
1562	public org.codeworker.ScpStream writeOperator(/*unsigned*/ long lValue) {
1563		char[] tcNumber = new char[32];
1564		sprintf(tcNumber, "%lu", lValue);
1565		writeText(tcNumber);
1566		return this;
1567	}
1568
1569	public org.codeworker.ScpStream writeOperator(double dValue) {
1570//##protect##"Java ScpStream::operator<<.double"
1571		writeText(String.valueOf(dValue));
1572		return this;
1573//##protect##"Java ScpStream::operator<<.double"
1574	}
1575
1576	public org.codeworker.ScpStream writeOperator(char[] tcValue) {
1577		if ((tcValue == null))
1578			writeText("(null)");
1579		else
1580			writeText(tcValue);
1581		return this;
1582	}
1583
1584	public org.codeworker.ScpStream writeOperator(String sValue) {
1585		writeBinaryData(sValue.toCharArray(), sValue.length());
1586		return this;
1587	}
1588
1589	public org.codeworker.ScpStream writeOperator(org.codeworker.ScpStream theStream) {
1590//##protect##"Java ScpStream::operator<<.const ScpStream&"
1591		for (java.util.Map.Entry<String, Integer> i : theStream._mapOfFloatingLocations.entrySet()) {
1592				i.setValue(new Integer(i.getValue().intValue() + _iWriteCursor));
1593			}
1594		theStream._mapOfFloatingLocations.clear();
1595		theStream._pParentStream = this;
1596		writeText(theStream.readBuffer());
1597		return this;
1598//##protect##"Java ScpStream::operator<<.const ScpStream&"
1599	}
1600
1601	public void writeString(String sString) {
1602		int iRequiredSpace = (sString.length() + 2);
1603		char[] tcEscape = sString.toCharArray();
1604		while ((tcEscape != '\0'))
1605			{
1606				switch(tcEscape) {
1607					case '\\':
1608					case '\"':
1609					case '\007':
1610					case '\b':
1611					case '\f':
1612					case '\n':
1613					case '\r':
1614					case '\t':
1615					case '\013':
1616						++iRequiredSpace;
1617				}
1618				++tcEscape;
1619			}
1620		int iNeededSize = (_iWriteCursor + iRequiredSpace);
1621		int iTotalSize = ((_bInsertText) ? (_iSize + iRequiredSpace) : iNeededSize);
1622		if ((_iSize < iTotalSize))
1623			{
1624				_iSize = iTotalSize;
1625				if ((iTotalSize >= _iCacheMemory))
1626					{
1627						int iOldSize = _iCacheMemory;
1628						do
1629							_iCacheMemory *= 2;
1630						while ((_iSize >= _iCacheMemory));
1631						char[] tcStream = new char[_iCacheMemory];
1632						memcpy(tcStream, _tcStream, iOldSize);
1633						_tcStream = null; // delete the object!
1634						_tcStream = new String(tcStream);
1635					}
1636			}
1637		if (_bInsertText)
1638			{
1639				memmove(String.copyValueOf(_tcStream, iNeededSize, _tcStream.length - iNeededSize), String.copyValueOf(_tcStream, _iWriteCursor, _tcStream.length - _iWriteCursor), (_iSize - iNeededSize));
1640				for (java.util.MapIterator<String,java.lang.Integer> i = _mapOfFloatingLocations.begin();(i != _mapOfFloatingLocations.end());++i)
1641					{
1642						if ((i.second >= _iWriteCursor))
1643							_mapOfFloatingLocations.put(i.first, += iRequiredSpace;
1644					}
1645			}
1646		char[] u = sString.toCharArray();
1647		_tcStream[_iWriteCursor++] = '\"';
1648		if ((iRequiredSpace == (sString.length() + 2)))
1649			{
1650				memcpy(String.copyValueOf(_tcStream, _iWriteCursor, _tcStream.length - _iWriteCursor), sString.toCharArray(), sString.length());
1651				_iWriteCursor += sString.length();
1652			}
1653		else
1654			{
1655				while ((u != '\0'))
1656					{
1657						switch(u) {
1658							case '\\':
1659								_tcStream[_iWriteCursor++] = '\\';
1660								_tcStream[_iWriteCursor++] = '\\';
1661								break;
1662							case '\"':
1663								_tcStream[_iWriteCursor++] = '\\';
1664								_tcStream[_iWriteCursor++] = '\"';
1665								break;
1666							case '\007':
1667								_tcStream[_iWriteCursor++] = '\\';
1668								_tcStream[_iWriteCursor++] = 'a';
1669								break;
1670							case '\b':
1671								_tcStream[_iWriteCursor++] = '\\';
1672								_tcStream[_iWriteCursor++] = 'b';
1673								break;
1674							case '\f':
1675								_tcStream[_iWriteCursor++] = '\\';
1676								_tcStream[_iWriteCursor++] = 'f';
1677								break;
1678							case '\n':
1679								_tcStream[_iWriteCursor++] = '\\';
1680								_tcStream[_iWriteCursor++] = 'n';
1681								break;
1682							case '\r':
1683								_tcStream[_iWriteCursor++] = '\\';
1684								_tcStream[_iWriteCursor++] = 'r';
1685								break;
1686							case '\t':
1687								_tcStream[_iWriteCursor++] = '\\';
1688								_tcStream[_iWriteCursor++] = 't';
1689								break;
1690							case '\013':
1691								_tcStream[_iWriteCursor++] = '\\';
1692								_tcStream[_iWriteCursor++] = 'v';
1693								break;
1694							default:
1695								_tcStream[_iWriteCursor++] = u;
1696						}
1697						++u;
1698					}
1699			}
1700		_tcStream[_iWriteCursor++] = '\"';
1701	}
1702
1703	public void writeQuotedChar(char c) {
1704		WRITECHAR('\'');
1705		switch(c) {
1706			case '\\':
1707				WRITECHAR('\\');
1708				WRITECHAR('\\');
1709				break;
1710			case '\"':
1711				WRITECHAR('\\');
1712				WRITECHAR('\"');
1713				break;
1714			case '\'':
1715				WRITECHAR('\\');
1716				WRITECHAR('\'');
1717				break;
1718			case '\007':
1719				WRITECHAR('\\');
1720				WRITECHAR('a');
1721				break;
1722			case '\b':
1723				WRITECHAR('\\');
1724				WRITECHAR('b');
1725				break;
1726			case '\f':
1727				WRITECHAR('\\');
1728				WRITECHAR('f');
1729				break;
1730			case '\n':
1731				WRITECHAR('\\');
1732				WRITECHAR('n');
1733				break;
1734			case '\r':
1735				WRITECHAR('\\');
1736				WRITECHAR('r');
1737				break;
1738			case '\t':
1739				WRITECHAR('\\');
1740				WRITECHAR('t');
1741				break;
1742			case '\013':
1743				WRITECHAR('\\');
1744				WRITECHAR('v');
1745				break;
1746			default:
1747				WRITECHAR(c);
1748		}
1749		WRITECHAR('\'');
1750		if ((_iWriteCursor > _iSize))
1751			_iSize = _iWriteCursor;
1752	}
1753
1754	public void writeBinaryData(char[] tcBinary, int iLength) {
1755		int iFinalLength = iLength;
1756		boolean bStartIndents = false;
1757		if (!_sIndentation.equals(""))
1758			{
1759				int iStartCursor = (_iWriteCursor - 1);
1760				while ((iStartCursor >= 0))
1761					{
1762						if ((_tcStream[iStartCursor] != '\t'))
1763							break;
1764						--iStartCursor;
1765					}
1766				if (((iStartCursor < 0) || (_tcStream[iStartCursor] == '\n')))
1767					{
1768						int iStartIndents = ((_iWriteCursor - iStartCursor) - 1);
1769						int iExtraStartingTabs = (_sIndentation.length() - iStartIndents);
1770						if ((iExtraStartingTabs > 0))
1771							{
1772								bStartIndents = true;
1773								_iWriteCursor -= iStartIndents;
1774								iFinalLength += iExtraStartingTabs;
1775							}
1776					}
1777				char[] u = tcBinary;
1778				for (int i = (iLength - 1);(i > 0);--i)
1779					{
1780						if ((u++ == '\n'))
1781							iFinalLength += _sIndentation.length();
1782					}
1783			}
1784		int iNeededSize = (_iWriteCursor + iFinalLength);
1785		int iTotalSize = ((_bInsertText) ? (_iSize + iFinalLength) : iNeededSize);
1786		if ((_iSize < iTotalSize))
1787			{
1788				_iSize = iTotalSize;
1789				if ((iTotalSize >= _iCacheMemory))
1790					{
1791						int iOldSize = _iCacheMemory;
1792						do
1793							_iCacheMemory *= 2;
1794						while ((_iSize >= _iCacheMemory));
1795						char[] tcStream = new char[_iCacheMemory];
1796						memcpy(tcStream, _tcStream, iOldSize);
1797						_tcStream = null; // delete the object!
1798						_tcStream = new String(tcStream);
1799					}
1800			}
1801		if (_bInsertText)
1802			{
1803				memmove(String.copyValueOf(_tcStream, iNeededSize, _tcStream.length - iNeededSize), String.copyValueOf(_tcStream, _iWriteCursor, _tcStream.length - _iWriteCursor), (_iSize - iNeededSize));
1804				for (java.util.MapIterator<String,java.lang.Integer> i = _mapOfFloatingLocations.begin();(i != _mapOfFloatingLocations.end());++i)
1805					{
1806						if ((i.second >= _iWriteCursor))
1807							_mapOfFloatingLocations.put(i.first, += iFinalLength;
1808					}
1809			}
1810		if (_sIndentation.equals(""))
1811			{
1812				memcpy(String.copyValueOf(_tcStream, _iWriteCursor, _tcStream.length - _iWriteCursor), tcBinary, iLength);
1813			}
1814		else
1815			{
1816				char[] tcIndentStart = String.copyValueOf(_tcStream, _iWriteCursor, _tcStream.length - _iWriteCursor);
1817				if (bStartIndents)
1818					{
1819						char[] v = _sIndentation.toCharArray();
1820						do
1821							{
1822								++tcIndentStart = v++;
1823							}
1824						while ((v != '\0'));
1825					}
1826				char[] u = tcBinary;
1827				for (int i = (iLength - 1);(i > 0);--i)
1828					{
1829						++tcIndentStart = u;
1830						if ((u++ == '\n'))
1831							{
1832								char[] v = _sIndentation.toCharArray();
1833								do
1834									{
1835										++tcIndentStart = v++;
1836									}
1837								while ((v != '\0'));
1838							}
1839					}
1840				tcIndentStart = u;
1841			}
1842		_iWriteCursor += iFinalLength;
1843	}
1844
1845	public String getLastWrittenChars(int iNbChars) {
1846//##protect##"Java ScpStream::writeTextOnce.const string&"
1847		if (iNbChars > _iWriteCursor)
1848			iNbChars = _iWriteCursor;
1849		if ((iNbChars == 0))
1850			return "";
1851		int iBegin = _iWriteCursor - iNbChars;
1852		return new String(_tcStream, iBegin, iNbChars);
1853//##protect##"Java ScpStream::writeTextOnce.const string&"
1854	}
1855
1856	public boolean writeTextOnce(String sText) {
1857//##protect##"Java ScpStream::writeTextOnce.const string&"
1858		if (_setOfTextsToInsertOnce.contains(sText))
1859			{
1860				writeBinaryData(sText.toCharArray(), sText.length());
1861				_setOfTextsToInsertOnce.add(sText);
1862				return true;
1863			}
1864		return false;
1865//##protect##"Java ScpStream::writeTextOnce.const string&"
1866	}
1867
1868	public org.codeworker.ScpStream flush() {
1869		return this;
1870	}
1871
1872	public org.codeworker.ScpStream endl() {
1873		writeText(ENDL.toCharArray());
1874		return this;
1875	}
1876
1877	public boolean close() {
1878		if ((_pfStreamWriterCallback == null))
1879			return true;
1880		return _pfStreamWriterCallback.callback(this, _pStreamWriterCBKData);
1881	}
1882
1883	public boolean equals(org.codeworker.ScpStream theStream, int iPosition) {
1884		if ((_iSize != theStream._iSize))
1885			{
1886				iPosition = -1;
1887				return false;
1888			}
1889		int i = _iSize;
1890		char[] u = _tcStream;
1891		char[] v = theStream._tcStream;
1892		while ((i > 0))
1893			{
1894				if ((u++ != v++))
1895					{
1896						iPosition = (_iSize - i);
1897						return false;
1898					}
1899				--i;
1900			}
1901		iPosition = _iSize;
1902		return true;
1903	}
1904
1905	public boolean equalsFromInputLocations(org.codeworker.ScpStream theStream, int iPosition) {
1906		if (((_iSize - _iReadCursor) != (theStream._iSize - theStream._iReadCursor)))
1907			{
1908				iPosition = -1;
1909				return false;
1910			}
1911		int i = (_iSize - _iReadCursor);
1912		char[] u = String.copyValueOf(_tcStream, _iReadCursor, _tcStream.length - _iReadCursor);
1913		char[] v = String.copyValueOf(theStream._tcStream, theStream._iReadCursor, theStream._tcStream.length - theStream._iReadCursor);
1914		while ((i > 0))
1915			{
1916				if ((u++ != v++))
1917					{
1918						iPosition = (_iSize - i);
1919						return false;
1920					}
1921				--i;
1922			}
1923		iPosition = _iSize;
1924		return true;
1925	}
1926
1927	public boolean insertText(String sText, int iLocation, int iAreaToRecover) {
1928		if ((iLocation < 0))
1929			return false;
1930		int iEndPortion = (iLocation + iAreaToRecover);
1931		if ((iEndPortion > _iSize))
1932			{
1933				iAreaToRecover = (_iSize - iLocation);
1934				if ((iAreaToRecover < 0))
1935					return false;
1936				iEndPortion = (iLocation + iAreaToRecover);
1937			}
1938		int iBytesToAdd = (sText.length() - iAreaToRecover);
1939		if (((_iSize + iBytesToAdd) >= _iCacheMemory))
1940			{
1941				int iOldSize = _iCacheMemory;
1942				do
1943					_iCacheMemory *= 2;
1944				while (((_iSize + iBytesToAdd) >= _iCacheMemory));
1945				char[] tcStream = new char[_iCacheMemory];
1946				memcpy(tcStream, _tcStream, iOldSize);
1947				_tcStream = null; // delete the object!
1948				_tcStream = new String(tcStream);
1949			}
1950		if ((iBytesToAdd != 0))
1951			{
1952				memmove(String.copyValueOf(_tcStream, (iLocation + sText.length()), _tcStream.length - (iLocation + sText.length())), String.copyValueOf(_tcStream, iEndPortion, _tcStream.length - iEndPortion), (_iSize - iEndPortion));
1953				_iSize += iBytesToAdd;
1954				if ((iEndPortion < _iWriteCursor))
1955					_iWriteCursor += iBytesToAdd;
1956				for (java.util.MapIterator<String,java.lang.Integer> i = _mapOfFloatingLocations.begin();(i != _mapOfFloatingLocations.end());++i)
1957					{
1958						if ((i.second >= iEndPortion))
1959							_mapOfFloatingLocations.put(i.first, += iBytesToAdd;
1960					}
1961			}
1962		memcpy(String.copyValueOf(_tcStream, iLocation, _tcStream.length - iLocation), sText.toCharArray(), sText.length());
1963		return true;
1964	}
1965
1966	public boolean insertTextOnce(String sText, int iLocation, int iAreaToRecover) {
1967//##protect##"Java ScpStream::insertTextOnce.const string&.int.int"
1968		if (_setOfTextsToInsertOnce.contains(sText))
1969			return false;
1970		if (!insertText(sText, iLocation, iAreaToRecover))
1971			return false;
1972		_setOfTextsToInsertOnce.add(sText);
1973		return true;
1974//##protect##"Java ScpStream::insertTextOnce.const string&.int.int"
1975	}
1976
1977	public boolean insertStream(org.codeworker.ScpStream theStream, int iLocation, int iAreaToRecover) {
1978		if ((iLocation < 0))
1979			return false;
1980		int iEndPortion = (iLocation + iAreaToRecover);
1981		if ((iEndPortion > _iSize))
1982			{
1983				iAreaToRecover = (_iSize - iLocation);
1984				if ((iAreaToRecover < 0))
1985					return false;
1986				iEndPortion = (iLocation + iAreaToRecover);
1987			}
1988		int iBytesToAdd = (theStream.size() - iAreaToRecover);
1989		if (((_iSize + iBytesToAdd) >= _iCacheMemory))
1990			{
1991				int iOldSize = _iCacheMemory;
1992				do
1993					_iCacheMemory *= 2;
1994				while (((_iSize + iBytesToAdd) >= _iCacheMemory));
1995				char[] tcStream = new char[_iCacheMemory];
1996				memcpy(tcStream, _tcStream, iOldSize);
1997				_tcStream = null; // delete the object!
1998				_tcStream = new String(tcStream);
1999			}
2000		if ((iBytesToAdd != 0))
2001			{
2002				memmove(String.copyValueOf(_tcStream, (iLocation + theStream.size()), _tcStream.length - (iLocation + theStream.size())), String.copyValueOf(_tcStream, iEndPortion, _tcStream.length - iEndPortion), (_iSize - iEndPortion));
2003				_iSize += iBytesToAdd;
2004				if ((iEndPortion < _iWriteCursor))
2005					_iWriteCursor += iBytesToAdd;
2006				for (java.util.MapIterator<String,java.lang.Integer> i = _mapOfFloatingLocations.begin();(i != _mapOfFloatingLocations.end());++i)
2007					{
2008						if ((i.second >= iEndPortion))
2009							_mapOfFloatingLocations.put(i.first, += iBytesToAdd;
2010					}
2011			}
2012		memcpy(String.copyValueOf(_tcStream, iLocation, _tcStream.length - iLocation), theStream.readBuffer(), theStream.size());
2013		return true;
2014	}
2015
2016	public boolean copy(org.codeworker.ScpStream theStream, int iLocation, int iLength) {
2017//##protect##"Java ScpStream::copy.const ScpStream&.int.int"
2018		if ((iLength < 0))
2019			iLength = theStream.size() - iLocation;
2020		else
2021			if (iLength + iLocation > theStream.size())
2022				return false;
2023		if (_iWriteCursor + iLength >= _iCacheMemory)
2024			{
2025				int iOldSize = _iCacheMemory;
2026				do
2027					_iCacheMemory *= 2;
2028				while (_iWriteCursor + iLength >= _iCacheMemory);
2029				char[] tcStream = new char[_iCacheMemory];
2030				memcpy(tcStream, _tcStream, iOldSize);
2031				_tcStream = tcStream;
2032			}
2033		copy(_tcStream, _iWriteCursor, theStream._tcStream, iLocation, iLength);
2034		_iWriteCursor += iLength;
2035		if ((_iWriteCursor > _iSize))
2036			_iSize = _iWriteCursor;
2037		return true;
2038//##protect##"Java ScpStream::copy.const ScpStream&.int.int"
2039	}
2040
2041	public void saveIntoFile(String sFilename, boolean bCreateFileIfUnknown) {
2042		if (existVirtualFile(sFilename))
2043			{
2044				createVirtualFile(sFilename, readBuffer());
2045			}
2046		else
2047			{
2048				java.io.InputStream f = new java.io.FileInputStream(sFilename);
2049				if ((f == null))
2050					{
2051						if (bCreateFileIfUnknown)
2052							{
2053								if (createDirectoriesForFile(sFilename))
2054									f = new java.io.FileInputStream(sFilename);
2055							}
2056						if ((f == null))
2057							throw new org.codeworker.Exception((("unable to copy a stream into file '" + sFilename) + "'"));
2058					}
2059				int iCursor = 0;
2060				int iBlock = (((_iSize >= 32000)) ? 32000 : _iSize);
2061				do
2062					{
2063						int iWritten = fwrite(String.copyValueOf(_tcStream, iCursor, _tcStream.length - iCursor), 1, iBlock, f);
2064						if ((iWritten != iBlock))
2065							{
2066								char[] tcNumber = new char[32];
2067								sprintf(tcNumber, "%d", ferror(f));
2068								throw new org.codeworker.Exception((((("error [" + tcNumber) + "] has occurred while saving bytes into file \"") + sFilename) + "\""));
2069							}
2070						iCursor += iBlock;
2071						iBlock = ((((iCursor + 32000) <= _iSize)) ? 32000 : (_iSize - iCursor));
2072					}
2073				while ((iBlock != 0));
2074				f.close();
2075			}
2076	}
2077
2078	public void appendFile(String sFilename, boolean bCreateFileIfUnknown) {
2079		if (existVirtualFile(sFilename))
2080			{
2081				org.codeworker.StringRef sContent = new org.codeworker.StringRef();
2082				loadVirtualFile(sFilename, sContent.ref_);
2083				createVirtualFile(sFilename, (sContent.ref_ + readBuffer()));
2084			}
2085		else
2086			{
2087				java.io.InputStream f = new java.io.FileInputStream(sFilename);
2088				if ((f == null))
2089					{
2090						if (bCreateFileIfUnknown)
2091							{
2092								if (createDirectoriesForFile(sFilename))
2093									f = new java.io.FileInputStream(sFilename);
2094							}
2095						if ((f == null))
2096							throw new org.codeworker.Exception((("unable to append a stream into file '" + sFilename) + "'"));
2097					}
2098				int iCursor = 0;
2099				int iBlock = (((_iSize >= 32000)) ? 32000 : _iSize);
2100				do
2101					{
2102						int iWritten = fwrite(String.copyValueOf(_tcStream, iCursor, _tcStream.length - iCursor), 1, iBlock, f);
2103						if ((iWritten != iBlock))
2104							{
2105								char[] tcNumber = new char[32];
2106								sprintf(tcNumber, "%d", ferror(f));
2107								throw new org.codeworker.Exception((((("error [" + tcNumber) + "] has occurred while appending bytes into file \"") + sFilename) + "\""));
2108							}
2109						iCursor += iBlock;
2110						iBlock = ((((iCursor + 32000) <= _iSize)) ? 32000 : (_iSize - iCursor));
2111					}
2112				while ((iBlock != 0));
2113				f.close();
2114			}
2115	}
2116
2117	public boolean indentAsCpp() {
2118		org.codeworker.ScpStream currentStream = new org.codeworker.ScpStream();
2119		String sIndentation = new String();
2120		String sSequence = new String();
2121		org.codeworker.StringRef sLastIdentifier = new org.codeworker.StringRef();
2122		int iChar = readChar();
2123		while ((iChar >= 0))
2124			{
2125				int iStartLocation = (_iReadCursor - 1);
2126				while (((iChar == '\t') || (iChar == ((int) ' '))))
2127					iChar = readChar();
2128				if ((iChar < 0))
2129					break;
2130				if ((iChar == ((int) '\r')))
2131					currentStream.writeOperator('\r');
2132				else
2133					if ((iChar == ((int) '\n')))
2134						currentStream.writeOperator('\n');
2135					else
2136						if ((iChar == ((int) '#')))
2137							{
2138								do
2139									{
2140										currentStream.writeOperator(((byte) iChar));
2141										iChar = readChar();
2142									}
2143								while (((iChar >= 0) && (iChar != '\n')));
2144								if ((iChar >= 0))
2145									currentStream.writeOperator('\n');
2146							}
2147						else
2148							if (((iChar == '/') && isEqualTo("/##")))
2149								{
2150									_iReadCursor = iStartLocation;
2151									iChar = readChar();
2152									while (((iChar >= 0) && (iChar != '\n')))
2153										{
2154											currentStream.writeOperator(((byte) iChar));
2155											iChar = readChar();
2156										}
2157									if ((iChar >= 0))
2158										currentStream.writeOperator('\n');
2159								}
2160							else
2161								{
2162									String sLocalIndentation = sIndentation;
2163									String sLine = new String();
2164									int iPreviousChar = -1;
2165									int iPreviousNotEmptyChar = -1;
2166									int iBeginningOfLine = iStartLocation;
2167									do
2168										{
2169											switch(iChar) {
2170												case ':':
2171													if ((((iPreviousChar != ((int) ':')) && (peekChar() != ':')) && (iPreviousNotEmptyChar != ((int) ')'))))
2172														{
2173															if ((((sLastIdentifier.ref_.equals("public") || sLastIdentifier.ref_.equals("protected")) || sLastIdentifier.ref_.equals("private")) || sLastIdentifier.ref_.equals("case")))
2174																{
2175																	if ((sSequence.equals("") || (sSequence.charAt((sSequence.length() - 1)) != ':')))
2176																		{
2177																			sSequence += ':';
2178																			sIndentation += '\t';
2179																		}
2180																	else
2181																		{
2182																			--_iWriteCursor;
2183																			if ((sLocalIndentation.length() == sIndentation.length()))
2184																				sLocalIndentation = sLocalIndentation.substring(0, (sLocalIndentation.length() - 1));
2185																		}
2186																}
2187														}
2188													sLine += ':';
2189													iPreviousNotEmptyChar = iChar;
2190													break;
2191												case '{':
2192													sSequence += '{';
2193													sIndentation += '\t';
2194													sLine += '{';
2195													iPreviousNotEmptyChar = iChar;
2196													break;
2197												case '}':
2198													int iOffset;
2199													if ((!sSequence.equals("") && (sSequence.charAt((sSequence.length() - 1)) == ':')))
2200														iOffset = 2;
2201													else
2202														iOffset = 1;
2203													if ((sIndentation.length() <= iOffset))
2204														{
2205															if ((iPreviousChar < 0))
2206																sLocalIndentation = new String("");
2207															sSequence = new String("");
2208															sIndentation = new String("");
2209														}
2210													else
2211														{
2212															if ((iPreviousChar < 0))
2213																sLocalIndentation = sLocalIndentation.substring(0, (sLocalIndentation.length() - iOffset));
2214															sSequence = sSequence.substring(0, (sSequence.length() - iOffset));
2215															sIndentation = sIndentation.substring(0, (sIndentation.length() - iOffset));
2216														}
2217													sLine += '}';
2218													iPreviousNotEmptyChar = iChar;
2219													break;
2220												case '\\':
2221													sLine += '\\';
2222													iPreviousNotEmptyChar = iChar;
2223													iChar = readChar();
2224													if ((iChar >= 0))
2225														sLine += ((byte) iChar);
2226													break;
2227												case '\'':
2228												case '\"':
2229													{
2230														int iQuote = iChar;
2231														do
2232															{
2233																if ((iChar == ((int) '\\')))
2234																	{
2235																		sLine += '\\';
2236																		iChar = readChar();
2237																	}
2238																sLine += ((byte) iChar);
2239																iChar = readChar();
2240															}
2241														while (((iChar >= 0) && (iChar != iQuote)));
2242														if ((iChar >= 0))
2243															sLine += ((byte) iChar);
2244														iPreviousNotEmptyChar = iChar;
2245													}
2246													break;
2247												case '/':
2248													if (isEqualTo('/'))
2249														{
2250															sLine += "//";
2251															iChar = readChar();
2252															while (((iChar >= 0) && (iChar != '\n')))
2253																{
2254																	sLine += ((byte) iChar);
2255																	iChar = readChar();
2256																}
2257															if ((iChar >= 0))
2258																--_iReadCursor;
2259														}
2260													else
2261														if (isEqualTo('*'))
2262															{
2263																int iCommentDistance = ((getInputLocation() - iBeginningOfLine) - 2);
2264																sLine += "/*";
2265																iChar = readChar();
2266																while (((iChar >= 0) && ((iChar != '*') || !isEqualTo('/'))))
2267																	{
2268																		sLine += ((byte) iChar);
2269																		if ((iChar == '\n'))
2270																			{
2271																				int i;
2272																				String sBeginning = new String();
2273																				for ( i = 0;(i < iCommentDistance);++i)
2274																					{
2275																						iChar = readChar();
2276																						if (((iChar < 0) || (iChar == '\n')))
2277																							break;
2278																						sBeginning += ((byte) iChar);
2279																						if ((iChar > ' '))
2280																							break;
2281																					}
2282																				if ((i >= iCommentDistance))
2283																					{
2284																						sLine += sLocalIndentation;
2285																						iChar = readChar();
2286																					}
2287																				else
2288																					if (((iChar != '\n') && (iChar >= 0)))
2289																						{
2290																							sLine += sBeginning;
2291																						}
2292																			}
2293																		else
2294																			{
2295																				iChar = readChar();
2296																			}
2297																	}
2298																if ((iChar >= 0))
2299																	sLine += "*/";
2300															}
2301														else
2302															{
2303																sLine += '/';
2304																iPreviousNotEmptyChar = iChar;
2305															}
2306													break;
2307												default:
2308													if ((((iChar == '_') || ((iChar >= 'a') && (iChar <= 'z'))) || ((iChar >= 'A') && (iChar <= 'Z'))))
2309														{
2310															goBack();
2311															readIdentifier(sLastIdentifier.ref_);
2312															sLine += sLastIdentifier.ref_;
2313															iPreviousNotEmptyChar = iChar;
2314														}
2315													else
2316														{
2317															sLine += ((byte) iChar);
2318															if ((iChar > ' '))
2319																iPreviousNotEmptyChar = iChar;
2320														}
2321											}
2322											iPreviousChar = iChar;
2323											iChar = readChar();
2324										}
2325									while (((iChar >= 0) && (iChar != '\n')));
2326									if ((iChar >= 0))
2327										sLine += '\n';
2328									currentStream.writeOperator(sLocalIndentation);
2329									currentStream.writeOperator(sLine);
2330								}
2331				iChar = readChar();
2332			}
2333		int iPosition;
2334		if (equals(currentStream, iPosition))
2335			return false;
2336		_iWriteCursor = 0;
2337		_iSize = 0;
2338		copy(currentStream, 0);
2339		return true;
2340	}
2341
2342	public static java.util.List<String> getListOfIncludePaths() {
2343		return _listOfIncludePaths;
2344	}
2345
2346	public static void setListOfIncludePaths(java.util.List<String> listOfIncludePaths) {
2347		_listOfIncludePaths = listOfIncludePaths;
2348	}
2349
2350	public static boolean createVirtualFile(String sHandle, String sContent) {
2351		_listOfVirtualFiles.put(sHandle, sContent);
2352		return true;
2353	}
2354
2355	public static String createVirtualTemporaryFile(String sContent) {
2356//##protect##"Java ScpStream::createVirtualTemporaryFile.const string&"
2357		String sHandle;
2358		int iHandle = 0;
2359		do {
2360			sHandle = ".~#%d" + iHandle;
2361		} while (_listOfVirtualFiles.containsKey(sHandle));
2362		createVirtualFile(sHandle, sContent);
2363		return sHandle;
2364//##protect##"Java ScpStream::createVirtualTemporaryFile.const string&"
2365	}
2366
2367	public static boolean existVirtualFile(String sHandle) {
2368//##protect##"Java ScpStream::existVirtualFile.const string&"
2369		return _listOfVirtualFiles.containsKey(sHandle);
2370//##protect##"Java ScpStream::existVirtualFile.const string&"
2371	}
2372
2373	public static boolean loadVirtualFile(String sHandle, org.codeworker.StringRef sContent) {
2374//##protect##"Java ScpStream::loadVirtualFile.const string&.string&"
2375		sContent.ref_ = _listOfVirtualFiles.get(sHandle);
2376		return sContent.ref_ != null;
2377//##protect##"Java ScpStream::loadVirtualFile.const string&.string&"
2378	}
2379
2380	public static boolean appendVirtualFile(String sHandle, String sContent) {
2381//##protect##"Java ScpStream::appendVirtualFile.const string&.const string&"
2382		String sOld = _listOfVirtualFiles.get(sHandle);
2383		if (sOld == null) return false;
2384		_listOfVirtualFiles.put(sHandle, sOld + sContent);
2385		return true;
2386//##protect##"Java ScpStream::appendVirtualFile.const string&.const string&"
2387	}
2388
2389	public static boolean deleteVirtualFile(String sHandle) {
2390//##protect##"Java ScpStream::deleteVirtualFile.const string&"
2391		return (_listOfVirtualFiles.remove(sHandle) != null);
2392//##protect##"Java ScpStream::deleteVirtualFile.const string&"
2393	}
2394
2395	public static java.io.FileInputStream openSTLInputFile(String sInputFile) {
2396//##protect##"Java ScpStream::openSTLInputFile.const char*"
2397		throw new java.lang.RuntimeException("ScpStream::openSTLInputFile(String sInputFile) not implemented yet!");
2398//##protect##"Java ScpStream::openSTLInputFile.const char*"
2399	}
2400
2401	private void writeText(char[] tcText) {
2402		writeBinaryData(tcText, tcText.length);
2403	}
2404
2405}
2406