Extend BVariant to support storing BRects as well.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43080 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2011, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _VARIANT_H
|
||||
#define _VARIANT_H
|
||||
|
||||
|
||||
#include <Rect.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
@@ -36,6 +38,9 @@ public:
|
||||
inline BVariant(uint64 value);
|
||||
inline BVariant(float value);
|
||||
inline BVariant(double value);
|
||||
inline BVariant(const BRect &value);
|
||||
inline BVariant(float left, float top, float right,
|
||||
float bottom);
|
||||
inline BVariant(const void* value);
|
||||
inline BVariant(const char* value,
|
||||
uint32 flags = 0);
|
||||
@@ -56,6 +61,9 @@ public:
|
||||
inline void SetTo(uint64 value);
|
||||
inline void SetTo(float value);
|
||||
inline void SetTo(double value);
|
||||
inline void SetTo(const BRect& value);
|
||||
inline void SetTo(float left, float top, float right,
|
||||
float bottom);
|
||||
inline void SetTo(const void* value);
|
||||
inline void SetTo(const char* value,
|
||||
uint32 flags = 0);
|
||||
@@ -92,6 +100,7 @@ public:
|
||||
double ToDouble() const;
|
||||
void* ToPointer() const;
|
||||
const char* ToString() const;
|
||||
BRect ToRect() const;
|
||||
BReferenceable* ToReferenceable() const;
|
||||
|
||||
void SwapEndianess();
|
||||
@@ -123,6 +132,8 @@ private:
|
||||
void _SetTo(float value);
|
||||
void _SetTo(double value);
|
||||
void _SetTo(const void* value);
|
||||
void _SetTo(float left, float top, float right,
|
||||
float bottom);
|
||||
bool _SetTo(const char* value,
|
||||
uint32 flags);
|
||||
void _SetTo(BReferenceable* value, type_code type);
|
||||
@@ -150,6 +161,11 @@ private:
|
||||
BReferenceable* fReferenceable;
|
||||
uint8 fBytes[8];
|
||||
};
|
||||
|
||||
float fLeft;
|
||||
float fTop;
|
||||
float fRight;
|
||||
float fBottom;
|
||||
};
|
||||
|
||||
|
||||
@@ -227,6 +243,18 @@ BVariant::BVariant(double value)
|
||||
}
|
||||
|
||||
|
||||
BVariant::BVariant(const BRect& value)
|
||||
{
|
||||
_SetTo(value);
|
||||
}
|
||||
|
||||
|
||||
BVariant::BVariant(float left, float top, float right, float bottom)
|
||||
{
|
||||
_SetTo(left, top, right, bottom);
|
||||
}
|
||||
|
||||
|
||||
BVariant::BVariant(const void* value)
|
||||
{
|
||||
_SetTo(value);
|
||||
@@ -363,6 +391,22 @@ BVariant::SetTo(double value)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BVariant::SetTo(const BRect& value)
|
||||
{
|
||||
Unset();
|
||||
_SetTo(value.left, value.top, value.right, value.bottom);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BVariant::SetTo(float left, float top, float right, float bottom)
|
||||
{
|
||||
Unset();
|
||||
_SetTo(left, top, right, bottom);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BVariant::SetTo(const void* value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user