Re: [gtk-list] GScanner::text, private??



On Sun, 9 Jan 2000, Tim Janik wrote:

> On Fri, 7 Jan 2000, Manuel Estrada wrote:
> 
> > 
> > 	Hi all,
> > 
> > 	I need to parse a text which has more information than I want,
> > so I need to know were the scanner is reading to be able to start from
> > there to do something else with the rest.
> > 
> > 	Now I use GScanner->text and it works, but it is suposed to be
> > private :(
> > 	Maybe there is some other "legal" way to find out or maybe
> > GScanner could take some change, a new function or maybe "text" could
> > be considered public. (I am willing to try coding the change if
> > needed) 
> 
> i don't exactly understand what you do, do you use GScanner to skip
> over a text untill you find a certain keyword/phrase and then read
> the text from there with your own routines?

	Not realy, I want to use the GScanner to parse a string (and
actualy find information) which I already have in memory and contains
many pieces which I want to parse with differently, so I need to know
where the GScanner stoped to tell the other routines where to start. 

> the problem with text is that it always contains a small chunk of the
> source text only, so worst case is you just parsed "foo" of "foo bar baz"
> and ->text actually only contains "foo ba" (not including trailing \0,
> iirc).
> gscanner will simply read in more text if it needs to, but for you
> ->text is basically non-reliable.

	That doesn't happen with strings, "text" gets pointed at the
original string and walks along it. Put anyway, I don't want to use
"text" "ilegally" as that may leed to incompatibility with future
glib's.

> what you can do is calling g_scanner_sync_file_offset() after you parsed
> "foo", and then read the rest text with read() from gscanner's input fd,
> this function will reposition the file pointer to match exactly the position
> gscanner is currently parsing at.
> (you can also resume scanning at that position at a later point by lseek()ing
> the file back to that position and continuing with gscanner as normal).

	I am not using a file for input, I am using an string.


	Thanks

		ranty

-------------------------------------------------
	Manuel Estrada

	Ranty@atdot.org
-------------------------------------------------



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]