Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » storing my struct in a Value
storing my struct in a Value [message #807] Fri, 03 February 2006 10:13 Go to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
How do I pass this struct inside a Value? Are there some preprocessor macros or inheritance needed for a type to storable inside a Value? How do I "cast" a Value back to my type?
struct MyType
{
  String s;
  Color bg, fg;
};
I am trying to use this type as the cell data in ArrayCtrl.
Re: storing my struct in a Value [message #808 is a reply to message #807] Fri, 03 February 2006 10:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Value v = RawToValue(x);

const MyType& y = ValueTo<MyType>(v);

- requires MyType to have full-copy (you can assign types with pick using RawPickToValue)

- there are two levels of Value compliance - raw types just get stored and retrieved, while "rich" value types support other operations - test for Null, equality comparison (including casts to similar types like Date<->Time, int<->double), serialization and casts to similar types.

- you can also make your type more compatible by adding operator Value and constructor from Value
Re: storing my struct in a Value [message #809 is a reply to message #807] Fri, 03 February 2006 10:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
...see reference/Value....
Re: storing my struct in a Value [message #811 is a reply to message #809] Fri, 03 February 2006 10:44 Go to previous messageGo to next message
hojtsy is currently offline  hojtsy
Messages: 241
Registered: January 2006
Location: Budapest, Hungary
Experienced Member
How could I ensure that the number I put to AssignValueTypeNo is unique? The numbers used by the library seems just random (9, 34, 39, 40, 50, 70, 150). Is there a range reserved for the library for future use?
Re: storing my struct in a Value [message #813 is a reply to message #811] Fri, 03 February 2006 11:00 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ahh, I see you are several steps further now:)

In debug mode, RichValue::Register() checks whether the value is unique.

We have not set any official ranges yet... But all current assignments for the library itself are say < 256. Make yours >65536 and everything will be ok.

Mirek
Previous Topic: multithread access to the same control
Next Topic: substring find
Goto Forum:
  


Current Time: Thu Apr 25 19:35:38 CEST 2024

Total time taken to generate the page: 0.90620 seconds