aboutsummaryrefslogtreecommitdiff
path: root/Src/nde/osx/Binary32Field.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/nde/osx/Binary32Field.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/nde/osx/Binary32Field.cpp')
-rw-r--r--Src/nde/osx/Binary32Field.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/Src/nde/osx/Binary32Field.cpp b/Src/nde/osx/Binary32Field.cpp
new file mode 100644
index 00000000..dce7c8cc
--- /dev/null
+++ b/Src/nde/osx/Binary32Field.cpp
@@ -0,0 +1,78 @@
+/* ---------------------------------------------------------------------------
+ Nullsoft Database Engine
+ --------------------
+ codename: Near Death Experience
+--------------------------------------------------------------------------- */
+
+/* ---------------------------------------------------------------------------
+
+ Binary32Field Class
+
+--------------------------------------------------------------------------- */
+
+#include "nde.h"
+#include "Binary32Field.h"
+#include "ndestring.h"
+//---------------------------------------------------------------------------
+Binary32Field::Binary32Field(const uint8_t *_Data, size_t len) : BinaryField(_Data, len)
+{
+ InitField();
+}
+
+//---------------------------------------------------------------------------
+void Binary32Field::InitField(void)
+{
+ Type = FIELD_BINARY32;
+}
+
+//---------------------------------------------------------------------------
+Binary32Field::Binary32Field()
+{
+ InitField();
+}
+
+//---------------------------------------------------------------------------
+void Binary32Field::ReadTypedData(const uint8_t *data, size_t len)
+{
+ uint32_t c;
+ size_t pos = 0;
+
+ CHECK_INT(len); //len-=4;
+ c = GET_INT(); pos += 4;
+ if (c && c<=len)
+ {
+ size_t size = c;
+ uint8_t *buf = (uint8_t *)malloc(size);
+ GET_BINARY(buf, data, c, pos);
+ Data = CFDataCreateWithBytesNoCopy(NULL, buf, size, kCFAllocatorMalloc);
+ }
+}
+
+//---------------------------------------------------------------------------
+void Binary32Field::WriteTypedData(uint8_t *data, size_t len)
+{
+ uint32_t c;
+ size_t pos = 0;
+
+ CHECK_INT(len); //len-=4;
+
+ size_t Size = CFDataGetLength(Data);
+ if (Data && Size<=len)
+ {
+ c = CFDataGetLength(Data);
+ PUT_INT(c); pos += 4;
+ CFDataGetBytes(Data, CFRangeMake(0, Size), data+pos);
+ }
+ else
+ {
+ PUT_INT(0);
+ }
+}
+
+//---------------------------------------------------------------------------
+size_t Binary32Field::GetDataSize(void)
+{
+ if (!Data)
+ return 4;
+ return CFDataGetLength(Data) + 4;
+}