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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-09-2005, 11:30 PM
|
#1
|
Member
Registered: Dec 2004
Posts: 32
Rep:
|
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
|
|
|
05-09-2005, 11:52 PM
|
#2
|
Member
Registered: Jan 2005
Location: Australia
Distribution: LFS 6.0 #15056
Posts: 50
Rep:
|
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.
|
|
|
05-10-2005, 12:01 AM
|
#3
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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.
|
|
|
05-10-2005, 12:27 AM
|
#4
|
Member
Registered: Jan 2005
Distribution: Arch
Posts: 120
Rep:
|
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.
|
|
|
05-10-2005, 02:00 AM
|
#5
|
Member
Registered: Apr 2005
Location: Finland
Posts: 196
Rep:
|
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.
|
|
|
05-10-2005, 03:40 AM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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 ;)
Which is C, not C++?
Plus you get the rest of gnome libraries which aren't
any leaner than Qt?
Cheers,
Tink
|
|
|
05-10-2005, 04:43 AM
|
#7
|
Member
Registered: Apr 2005
Location: Finland
Posts: 196
Rep:
|
I didn't know about that. Unfortunately it seems to be dead project (last update 2002-10-28, QT version 3.0.6).
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.
|
|
|
05-10-2005, 04:51 AM
|
#8
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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++
|
|
|
All times are GMT -5. The time now is 09:14 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|