LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-09-2005, 11:30 PM   #1
rahul_kulkarni
Member
 
Registered: Dec 2004
Posts: 32

Rep: Reputation: 15
C++ preferences


Hello All,

In JAVA we have java.util.prefs.Preferences class which allows applications to store and retrieve user and system preferences and configuration data.

Is anything similar to this also available on C++? I want it particularly on linux platform.

Thanks in advance.
// Rahul
 
Old 05-09-2005, 11:52 PM   #2
devilkin
Member
 
Registered: Jan 2005
Location: Australia
Distribution: LFS 6.0 #15056
Posts: 50

Rep: Reputation: 15
I highly doubt that you will be able to find such an interface in c++ even on a windows machine.

Makes Java sound very nice.
 
Old 05-10-2005, 12:01 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
from the Qt documentation
Detailed Description
The QSettings class provides persistent platform-independent application settings.

On Unix systems, QSettings uses text files to store settings. 
On Windows systems, QSettings uses the system registry. 
On Mac OS X, QSettings uses the Carbon preferences API.

Each setting comprises an identifying key and the data 
associated with the key. A key is a unicode string which 
consists of two or more subkeys. A subkey is a slash, '/', 
followed by one or more unicode characters (excluding 
slashes, newlines, carriage returns and equals, '=', signs). 
The associated data, called the entry or value, may be 
a boolean, an integer, a double, a string or a list of strings. 
Entry strings may contain any unicode characters.

If you want to save and restore the entire desktop's settings, 
i.e. which applications are running, use QSettings to save 
the settings for each individual application and QSessionManager 
to save the desktop's session.
That what you're after?


Cheers,
Tink

Last edited by Tinkster; 05-10-2005 at 12:02 AM.
 
Old 05-10-2005, 12:27 AM   #4
sasho
Member
 
Registered: Jan 2005
Distribution: Arch
Posts: 120

Rep: Reputation: 17
Re: C++ preferences

Quote:
Originally posted by rahul_kulkarni
Hello All,

In JAVA we have java.util.prefs.Preferences class which allows applications to store and retrieve user and system preferences and configuration data.

Is anything similar to this also available on C++? I want it particularly on linux platform.

Thanks in advance.
// Rahul
For constant values is good to have bunch of #define statements in one file, globals.h for example. For saved user configuration you can make a hidden directory in user's home directory and store ihs/her settings there. See how other apps such as Gaim do this.
 
Old 05-10-2005, 02:00 AM   #5
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
Quote:
The QSettings class provides persistent platform-independent application settings.
That QT class (probably) does what you want, but QT is a big library and requires even bigger X libraries. Use it only if your application already uses QT for other things. Otherwise, glib configuration file parser is better solution.

Quote:
Makes Java sound very nice.
The idea is nice, but the implementation is not. Java does not let you specify the path and name of the properties file, which makes it impossible to use standard unix/linux names /etc/appname and ~/.appname.
 
Old 05-10-2005, 03:40 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by Harmaa Kettu
[B]That QT class (probably) does what you want, but QT is a big library and requires even bigger X libraries. Use it only if your application already uses QT for other things.
http://www.uwyn.com/projects/tinyq/

Look again ;)


Quote:
Otherwise, glib configuration file parser is better solution.
Which is C, not C++?
Plus you get the rest of gnome libraries which aren't
any leaner than Qt?


Cheers,
Tink
 
Old 05-10-2005, 04:43 AM   #7
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
I didn't know about that. Unfortunately it seems to be dead project (last update 2002-10-28, QT version 3.0.6).

Quote:
Which is C, not C++?
What is the problem with that? Libraries written in C can be used in C++ code.

Quote:
Plus you get the rest of gnome libraries which aren't
any leaner than Qt?
Gnome programs and libraries use glib, but glib itself does not require any other libraries, except of course the standard C library.
 
Old 05-10-2005, 04:51 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by Harmaa Kettu
What is the problem with that? Libraries written in C can be used in C++ code.
I just assumed that he wants an OO approach since
he was coming from Java and asking for C++
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferences Moose3565 Linux - Distributions 16 09-06-2005 02:35 PM
Gnome Preferences acidblue Fedora 2 02-07-2005 11:11 AM
Remove Preferences jpapa Linux - Software 0 10-22-2004 08:08 AM
Firefox Preferences gbrewste Linux - Software 5 08-10-2004 04:27 AM
Losing Preferences LinuxBlackBox LQ Suggestions & Feedback 1 05-03-2004 07:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration