🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: de.comp.lang.c++
2 messages
2 total messages Started by Alexander Sat, 26 Aug 1995 16:44
Problem mit ISTREAM
#321
Author: Alexander
Date: Sat, 26 Aug 1995 16:44
25 lines
1249 bytes
Hallo,

ich habe dieses Codefragment aus Graphics Gems IV übernommen.
Nur leider versteht mein BC++ 4.02 Compiler die Zeile s.set(_bad)
nicht.
set und _bad sind keine Member von ISTREAM.
Leider weiß ich nicht was diese Funktion macht, ergo kann ich das
ganze auch nicht umprogrammieren.
Hat das vielleicht jemand einen Tip?

Danke
Alexander
alexander.czernay@Hamburg.Netsurf.de


SOURCE:
istream& operator >> (istream& s, vec3& v)  
{{	 vec3	v_tmp;;	 char	c = ' ';;
	 while (isspace(c)))		s >> c;;	 // The vectors can be formatted
either as x y z or | x y z |	 if (c == '|') {{		s >> v_tmp[VX]
>> v_tmp[VY] >> v_tmp[VZ];;	while (s >> c && isspace(c)) ;;	if (c
!= '|'))		 s.set(_bad); 	// set is not a member of ISTREAM 
				// _bad is not a member if ISTREAM
	}	} else {{	s.putback(c);;	s >> v_tmp[VX] >> v_tmp[VY] >>
v_tmp[VZ];;	}}	 if (s))	v = v_tmp;;	 return s;;}
Re: Problem mit ISTREAM
#323
Author: Ralf Muschall
Date: Sun, 27 Aug 1995 18:21
50 lines
1981 bytes
In article <41njbd$l9@trance.isys.net> alexander.czernay@Hamburg.NetSurf.de (Alexander) writes:
>Hallo,
>
>ich habe dieses Codefragment aus Graphics Gems IV übernommen.
>Nur leider versteht mein BC++ 4.02 Compiler die Zeile s.set(_bad)
>nicht.
>set und _bad sind keine Member von ISTREAM.
>Leider weiß ich nicht was diese Funktion macht, ergo kann ich das
>ganze auch nicht umprogrammieren.
>Hat das vielleicht jemand einen Tip?

Ich habe Deinen Code durch cb gejagt und manuell etwas enth"ackselt,
dann stand da:

istream&
operator >> (istream& s, vec3& v)
{{
     vec3   v_tmp;
     char   c = ' ';
     while (isspace(c))) s >> c;
     // The vectors can be formatted either as x y z or | x y z |
         if (c == '|')
         {{
            s >> v_tmp[VX] >> v_tmp[VY] >> v_tmp[VZ];
            while (s >> c && isspace(c)) ;
            if (c != '|'))  s.set(_bad);
[...]

Ich vermute, da will jemand das ios::io_state (d.h. s.io_state)
auf ios::badbit setzen. Das macht man (laut Teale) so
(habe ich selbst nie probiert):

s.clear(ios::badbit);

Die Prosa auf S. 80 im Teale sagt allerdings, da"s badbit
mehr f"ur nichtexisierende Files u."a. unbehebbare Fehler
gedacht ist, nicht f"ur Syntaxfehler im Input - f"ur solche
ist ios::failbit gedacht.

Ralf

PS: Teale = S. Teale, C++ IOStreams Handbook,
ISBN=0-201-59641-5, AW 1993

--
-- 
to get PGP keys: finger prm@cnve.rz.uni-jena.de (or from public key servers)
pgp public key fingerprints:
A3 93 A6 0B E2 8F 04 25  5B 3C 00 F6 55 E5 64 20  [1024 bit]
64 36 31 D8 7A 73 20 F7  CA 6A DA 02 AF 29 46 1C  [2047 bit]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads