Hi all .
Where can i find documentation about the Settings class in the Haiku/BeOS API?, if doesn’t exist, is there any tutorial that talks about how to save app settings to a file and which envolves other classes (if any)?
Hi all .
that kind of file do you want to generate? I often use attributes, writing to a empty text file.
No that’s not what i’m looking for, i need the Haiku API which is responsible of saving the app’s settings into a file in the “~/config/settings” directory.
I am writting a new app but i don’t know much about Be/Haiku API.
Have you looked here?
Yes i have all the lessons of darkwyrm and he bebook+haikubook, but i coudn’t find what i’m looking for.
Ok, i like attributes and i does not know anything other using yab ;). Good luck.
If you does not find a API class try addattr and catattr (somthing in ca should do it wihtout bash tool too). It is easy to add to a file and easy to change and read.
I know there is a driver_settings class which can be used for regular applications, too, as I understand. I’ve never used that, however.
Another possibility, which I use in all my apps, is to save to a flattened BMessage. See, e.g. my ClipdingerSettings. You can list such a flattened BMessage with the “message” command in Terminal, but it’s not easily edited externally.
OK, i’ll take a look at those 2 options you mentioned and see what solution i could come up with.
I always see so many different settings implementations, why not just have a universal settings class? I actually was able to get my hands on a copy of Dano and saw an addition of a settings class, maybe we could follow off of their implementation?
You mean like the dirver_settings class?
I found this example of its usage, but haven’t looked any deeper into it: MidiSettings.cpp
Well, I guess a sort of settings method like you mentioned before with your clipdinger application, but more as a general framework for others to use. I also like the idea of using attributes, as we could make an application that could act as a universal settings manager. (But hopefully wouldn’t be like Windows Registry😓)
You can also take a look at my implementation. The idea is similar to Humdinger’s, but the class itself is slightly easier to use in Settings window when you want to revert stuff and such.
I was more hoping to find some universal way/api as codeofevolution put it, but it seems everyone has his own implementation, i gess i have alot fo reading to do, to come up with own or just go the easy way and copycat someone else’s.
Thanks for your input guys.
The easiest way is to use a text file
Actually, a flattened BMessage sounds easier than a text file. No need to write a parser.
As for the lack of a generic class, there are multiple reasons none has emerged yet. Nothing impossible to overcome, of course.
First, it is often useful for a settings class to have specific getters and setters (SetFoo/GetFoo instead of AddInt32(“foo”, …). Of course this is not possible in an universal settings class.
So, a generic class would be quite similar to BMessage, except with “defaults” and “revert” management. And in fact, managing these is actually more easily done outside the class (you just need a copy of the BMessage at the point you want to revert to, and a default message).
As a result, it is simple enough for each app to implementthis on their own, and ashared class would not ma
Well, it’s not so much about a lack of generic a class, but more about a lack a documentation which gives a basic idea (for new devs like me who don’t know anything about the Be API) on how to go about it and have something to start off with, instead of spending alot of time trying to figure out what to do by reading source code with different implimentations.
True, this would be a good idea, in the beos days the, the bebook was an amazing source of documentation and (in my opinion) beats most api documentation today. I’d say we should form a team of people to document the past and new api of haiku, not to mention provide examples like settings implementations. I’d be happy to help document, though some of Haiku’s classes (especially in the support, shared, and package kit) seems foggy in what their classes do.
That would be like a revival of old BeNewsletters’s Developers’ Workshop. I guess it’s far easier now that everyone could push articles on their blog on haiku web site…
Sure it is. You already have a name for the setting “foo”. You just need to create a bunch of overloaded functions:
SetProperty(const char* name, int32 value);
SetProperty(const char* name, int32 value, int32 index);
-These would add data to a BMessage using AddInt32.
SetProperty(const char* name, bool value);
SetProperty(const char* name, bool value, int32 index);
-These would use add data using AddBool.
Etc, etc for all BMessage data types.
And you’d have corresponding
GetProperty(const char* name, int32& data, const int32 default)
GetProperty(const char* name, int32& data, const int32 default, int32 index)
Any form of documentation is valuable, as long as it’s up to date with the current API.
But i guess only experienced devs can write such docs