[Qt-jambi-interest] Long dictionary class?

Gunnar Sletta gunnar at trolltech.com
Thu Aug 20 06:04:29 CEST 2009


Derek Fountain wrote:
> One of the annoying restrictions of Java, at least to those of us who 
> frequent the worlds of Perl, PHP, etc., is the inability to define very 
> long lines in the source. I have a SQL query that spans about 20 lines 
> (and is growing in complexity by the day) and I want to embed it in my 
> Java. I'm developing it inside a SQL tool and cut-n-pasting it into my 
> Java source as I update it.
> 
> Only that's a pain in Java because I can't just drop it into the source 
> - I have to wrap it up in string concatenations in order to span the 
> multiple lines. I want to keep the multi-line formatting so it's 
> readable in the Java source.
> 
> One way around this is to put the SQL string inside a text file, then 
> access the contents of that text file from Java. Only I have several of 
> these strings (they define reports) so what I really want is something 
> that takes a text file like this:
> 
> [report1]
> select * from
> blah
> blah
> blah
> blah
> 
> [report2]
> select * from
> this
> that
> etc
> 
> and so on. I ask for 'report1' and get the appropriate string.
> 
> I can write such a thing, but I wondered if Qt had something I might be 
> able to use. It has just about everything else. :)

I cannot think of a class in Qt that would do exactly this, unfortunately.

> I just looked at QSettings - does that handle values that span lines? 
> I'd rather not use XML unless I have to, I don't need that level of 
> complexity. Any other options I should look at?

QSettings is more used as an abstraction of a key/value pair used as a 
persistent settings store, where the data format is of less consequence 
to the user. As a result, the data format is not always readable.

If you explicitly use the QSettings.Format.IniFormat you and you put in 
multiline text the .ini file will look like this:

<snip>
[General]
hello=This\nis\na\nmulti\nline\ntext
</snip>

So not as readable as you prefer..

-
Gunnar



More information about the Qt-jambi-interest mailing list