Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VABase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VABase
Commits
5d397bed
Commit
5d397bed
authored
Mar 15, 2018
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing struct data handling now using std vector of characters
parent
2c0441c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
37 deletions
+51
-37
include/VAStruct.h
include/VAStruct.h
+2
-2
src/VAStruct.cpp
src/VAStruct.cpp
+49
-35
No files found.
include/VAStruct.h
View file @
5d397bed
...
@@ -357,7 +357,7 @@ public:
...
@@ -357,7 +357,7 @@ public:
* @param[in] pData Data pointer
* @param[in] pData Data pointer
* @param[in] iBytes Number of bytes
* @param[in] iBytes Number of bytes
*/
*/
void
SetData
(
void
*
pData
,
const
int
iBytes
);
void
SetData
(
const
void
*
pData
,
const
int
iBytes
);
//! Returns a pointer to the struct value (only for datatype STRUCT)
//! Returns a pointer to the struct value (only for datatype STRUCT)
/**
/**
...
@@ -544,7 +544,7 @@ private:
...
@@ -544,7 +544,7 @@ private:
double
dValue
;
//!< Value if type is double
double
dValue
;
//!< Value if type is double
std
::
string
sValue
;
//!< Value if type is string
std
::
string
sValue
;
//!< Value if type is string
CVAStruct
*
xValue
;
//!< Value if type is struct
CVAStruct
*
xValue
;
//!< Value if type is struct
void
*
p
Data
;
//!< Value if type is data
std
::
vector
<
char
>
vc
Data
;
//!< Value if type is data
int
iDataSize
;
//!< Value byte number if type is data
int
iDataSize
;
//!< Value byte number if type is data
CVASampleBuffer
sbValue
;
//!< Value if type is sample buffer
CVASampleBuffer
sbValue
;
//!< Value if type is sample buffer
...
...
src/VAStruct.cpp
View file @
5d397bed
...
@@ -270,17 +270,16 @@ std::string CVAStruct::ToString( const int iIndent ) const
...
@@ -270,17 +270,16 @@ std::string CVAStruct::ToString( const int iIndent ) const
// ----------------------------------------------------
// ----------------------------------------------------
// Constructors
// Constructors
CVAStructValue
::
CVAStructValue
()
:
iDatatype
(
UNASSIGNED
),
xValue
(
NULL
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
()
:
iDatatype
(
UNASSIGNED
),
xValue
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
bool
value
)
:
iDatatype
(
BOOL
),
bValue
(
value
),
xValue
(
NULL
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
bool
value
)
:
iDatatype
(
BOOL
),
bValue
(
value
),
xValue
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
int
value
)
:
iDatatype
(
INT
),
iValue
(
value
),
xValue
(
NULL
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
int
value
)
:
iDatatype
(
INT
),
iValue
(
value
),
xValue
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
double
value
)
:
iDatatype
(
DOUBLE
),
dValue
(
value
),
xValue
(
NULL
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
double
value
)
:
iDatatype
(
DOUBLE
),
dValue
(
value
),
xValue
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
char
*
value
)
:
iDatatype
(
STRING
),
sValue
(
value
),
xValue
(
NULL
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
char
*
value
)
:
iDatatype
(
STRING
),
sValue
(
value
),
xValue
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
std
::
string
&
value
)
:
iDatatype
(
STRING
),
sValue
(
value
),
xValue
(
NULL
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
std
::
string
&
value
)
:
iDatatype
(
STRING
),
sValue
(
value
),
xValue
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
CVAStruct
&
value
)
:
iDatatype
(
STRUCT
),
xValue
(
new
CVAStruct
(
value
)
)
,
pData
(
NULL
)
{};
CVAStructValue
::
CVAStructValue
(
const
CVAStruct
&
value
)
:
iDatatype
(
STRUCT
),
xValue
(
new
CVAStruct
(
value
)
)
{};
CVAStructValue
::
CVAStructValue
(
void
*
pData
,
const
int
iBytes
)
CVAStructValue
::
CVAStructValue
(
void
*
pData
,
const
int
iBytes
)
:
iDatatype
(
DATA
)
:
iDatatype
(
DATA
)
,
pData
(
NULL
)
,
xValue
(
NULL
)
,
xValue
(
NULL
)
{
{
SetData
(
pData
,
iBytes
);
SetData
(
pData
,
iBytes
);
...
@@ -291,7 +290,9 @@ CVAStructValue::CVAStructValue( const CVASampleBuffer& oSampleBuffer )
...
@@ -291,7 +290,9 @@ CVAStructValue::CVAStructValue( const CVASampleBuffer& oSampleBuffer )
,
sbValue
(
oSampleBuffer
)
,
sbValue
(
oSampleBuffer
)
{}
{}
CVAStructValue
::
CVAStructValue
(
const
CVAStructValue
&
rhs
)
:
iDatatype
(
UNASSIGNED
),
xValue
(
NULL
),
pData
(
NULL
)
CVAStructValue
::
CVAStructValue
(
const
CVAStructValue
&
rhs
)
:
iDatatype
(
UNASSIGNED
)
,
xValue
(
NULL
)
{
{
*
this
=
rhs
;
*
this
=
rhs
;
}
}
...
@@ -299,56 +300,70 @@ CVAStructValue::CVAStructValue( const CVAStructValue& rhs ) : iDatatype( UNASSIG
...
@@ -299,56 +300,70 @@ CVAStructValue::CVAStructValue( const CVAStructValue& rhs ) : iDatatype( UNASSIG
CVAStructValue
::~
CVAStructValue
()
CVAStructValue
::~
CVAStructValue
()
{
{
delete
xValue
;
delete
xValue
;
delete
[]
pData
;
}
}
int
CVAStructValue
::
GetDatatype
()
const
{
int
CVAStructValue
::
GetDatatype
()
const
{
return
iDatatype
;
return
iDatatype
;
}
}
int
CVAStructValue
::
GetDataSize
()
const
{
int
CVAStructValue
::
GetDataSize
()
const
{
return
iDataSize
;
return
iDataSize
;
}
}
const
void
*
CVAStructValue
::
GetData
()
const
{
const
void
*
CVAStructValue
::
GetData
()
const
if
(
iDatatype
!=
DATA
)
VA_EXCEPT1
(
"Key value is no binary data"
);
{
return
pData
;
if
(
iDatatype
!=
DATA
)
VA_EXCEPT1
(
"Key value is no binary data"
);
return
&
(
vcData
[
0
]
);
}
}
void
*
CVAStructValue
::
GetData
()
{
void
*
CVAStructValue
::
GetData
()
if
(
iDatatype
!=
DATA
)
VA_EXCEPT1
(
"Key value is no binary data"
);
{
return
pData
;
if
(
iDatatype
!=
DATA
)
VA_EXCEPT1
(
"Key value is no binary data"
);
return
&
(
vcData
[
0
]
);
}
}
void
CVAStructValue
::
SetData
(
void
*
pData
,
const
int
iBytes
)
{
void
CVAStructValue
::
SetData
(
const
void
*
pIncomingData
,
const
int
iIncomingBytes
)
{
assert
(
iDatatype
==
DATA
);
assert
(
iDatatype
==
DATA
);
if
(
iDatatype
!=
DATA
)
return
;
if
(
pData
==
NULL
)
if
(
iDatatype
!=
DATA
)
return
;
if
(
pIncomingData
==
NULL
)
{
{
assert
(
iBytes
==
0
);
assert
(
i
Incoming
Bytes
==
0
);
}
}
else
else
{
{
assert
(
iBytes
>
0
);
assert
(
i
Incoming
Bytes
>
0
);
}
}
// Free previous data
// Free previous data
delete
[]
this
->
pData
;
vcData
.
clear
();
this
->
pData
=
NULL
;
// Allocate new buffer and copy the data
// Allocate new buffer and copy the data
if
(
pData
)
if
(
p
Incoming
Data
)
{
{
this
->
pData
=
new
char
[
iBytes
];
if
(
vcData
.
size
()
<
iIncomingBytes
)
iDataSize
=
iBytes
;
vcData
.
resize
(
iIncomingBytes
);
memcpy
(
this
->
pData
,
pData
,
iBytes
);
iDataSize
=
iIncomingBytes
;
//for( size_t i = 0; i < vcData.size(); i++ )
//vcData[ i ] = pData[ i ];
memcpy
(
GetData
(),
pIncomingData
,
iIncomingBytes
);
}
}
}
}
const
CVAStruct
&
CVAStructValue
::
GetStruct
()
const
const
CVAStruct
&
CVAStructValue
::
GetStruct
()
const
{
{
if
(
iDatatype
!=
STRUCT
)
if
(
iDatatype
!=
STRUCT
)
VA_EXCEPT1
(
"Key value is not a structure"
);
VA_EXCEPT1
(
"Key value is not a structure"
);
assert
(
xValue
);
assert
(
xValue
);
return
*
xValue
;
return
*
xValue
;
...
@@ -356,7 +371,7 @@ const CVAStruct& CVAStructValue::GetStruct() const
...
@@ -356,7 +371,7 @@ const CVAStruct& CVAStructValue::GetStruct() const
CVAStruct
&
CVAStructValue
::
GetStruct
()
CVAStruct
&
CVAStructValue
::
GetStruct
()
{
{
if
(
iDatatype
!=
STRUCT
)
if
(
iDatatype
!=
STRUCT
)
VA_EXCEPT1
(
"Key value is not a structure"
);
VA_EXCEPT1
(
"Key value is not a structure"
);
assert
(
xValue
);
assert
(
xValue
);
return
*
xValue
;
return
*
xValue
;
...
@@ -414,7 +429,6 @@ CVAStructValue& CVAStructValue::operator=( const CVAStructValue& rhs )
...
@@ -414,7 +429,6 @@ CVAStructValue& CVAStructValue::operator=( const CVAStructValue& rhs )
return
*
this
;
return
*
this
;
// Free data, if the key was of datatype DATA before
// Free data, if the key was of datatype DATA before
delete
[]
pData
;
delete
xValue
;
delete
xValue
;
iDataSize
=
0
;
iDataSize
=
0
;
...
@@ -445,7 +459,7 @@ CVAStructValue& CVAStructValue::operator=( const CVAStructValue& rhs )
...
@@ -445,7 +459,7 @@ CVAStructValue& CVAStructValue::operator=( const CVAStructValue& rhs )
case
DATA
:
case
DATA
:
// Autonome Kopie des Schssel BLOBs erzeugen
// Autonome Kopie des Schssel BLOBs erzeugen
SetData
(
rhs
.
pData
,
rhs
.
iDataSize
);
SetData
(
rhs
.
GetData
()
,
rhs
.
iDataSize
);
break
;
break
;
case
SAMPLEBUFFER
:
case
SAMPLEBUFFER
:
...
@@ -535,7 +549,7 @@ CVAStructValue::operator bool() const
...
@@ -535,7 +549,7 @@ CVAStructValue::operator bool() const
std
::
transform
(
s
.
begin
(),
s
.
end
(),
s
.
begin
(),
(
int
(
*
)(
int
)
)
::
toupper
);
std
::
transform
(
s
.
begin
(),
s
.
end
(),
s
.
begin
(),
(
int
(
*
)(
int
)
)
::
toupper
);
if
(
(
s
==
"no"
)
||
(
s
==
"false"
)
)
if
(
(
s
==
"no"
)
||
(
s
==
"false"
)
)
return
false
;
return
false
;
if
(
(
s
==
"yes"
)
||
(
s
==
"true"
)
)
if
(
(
s
==
"yes"
)
||
(
s
==
"true"
)
)
return
true
;
return
true
;
}
}
...
@@ -702,7 +716,7 @@ CVAStructValue::operator void*( ) const
...
@@ -702,7 +716,7 @@ CVAStructValue::operator void*( ) const
VA_EXCEPT1
(
"Types cannot be converted"
);
VA_EXCEPT1
(
"Types cannot be converted"
);
}
}
return
pData
;
return
(
void
*
)
GetData
()
;
}
}
CVAStructValue
::
operator
const
CVASampleBuffer
&
(
)
const
CVAStructValue
::
operator
const
CVASampleBuffer
&
(
)
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment