Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
cc9af1e5
Commit
cc9af1e5
authored
17 years ago
by
Ruud Overeem
Browse files
Options
Downloads
Patches
Plain Diff
BugID: 1000
Added macros for packung and unpacking vectors of strings.
parent
e94f4d13
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MAC/APL/RTCCommon/include/APL/RTCCommon/Marshalling.h
+42
-0
42 additions, 0 deletions
MAC/APL/RTCCommon/include/APL/RTCCommon/Marshalling.h
MAC/APL/RTCCommon/test/tMarshalling.cc
+38
-0
38 additions, 0 deletions
MAC/APL/RTCCommon/test/tMarshalling.cc
with
80 additions
and
0 deletions
MAC/APL/RTCCommon/include/APL/RTCCommon/Marshalling.h
+
42
−
0
View file @
cc9af1e5
...
...
@@ -209,4 +209,46 @@ do { \
} \
} while (0)
// SIZE vector<string>>
#define MSH_SIZE_VECTOR_STRING(sizevar, thevector) \
do { \
sizevar = sizeof(int32); \
vector<string>::iterator iter = thevector.begin(); \
vector<string>::iterator end = thevector.end(); \
while (iter != end) { \
sizevar += MSH_STRING_SIZE(*iter); \
iter++; \
} \
} while (0)
// PACK vector<string>
#define MSH_PACK_VECTOR_STRING(bufptr, offset, thevector) \
do { \
int32 nrElem = thevector.size(); \
memcpy(((char*)(bufptr)) + (offset), &nrElem, sizeof(int32)); \
offset += sizeof(int32); \
\
vector<string>::iterator iter = thevector.begin(); \
vector<string>::iterator end = thevector.end(); \
while (iter != end) { \
MSH_PACK_STRING(bufptr, offset, *iter); \
iter++; \
} \
} while (0)
// UNPACK vector<string>
#define MSH_UNPACK_VECTOR_STRING(bufptr, offset, thevector) \
do { \
int32 nrElem = 0; \
memcpy(&nrElem, ((char*)(bufptr)) + (offset), sizeof(nrElem)); \
offset += sizeof(nrElem); \
\
for (int elem = 0; elem < nrElem; elem++) { \
string elem1; \
MSH_UNPACK_STRING(bufptr, offset, elem1); \
thevector.push_back(elem1); \
} \
} while (0)
#endif
/* MARSHALLING_H_ */
This diff is collapsed.
Click to expand it.
MAC/APL/RTCCommon/test/tMarshalling.cc
+
38
−
0
View file @
cc9af1e5
...
...
@@ -252,5 +252,43 @@ int main (int argc, char* argv[])
}
// vector<string>
vector
<
string
>
sv1
;
sv1
.
push_back
(
"piet hein"
);
sv1
.
push_back
(
"nelson"
);
sv1
.
push_back
(
"van Swieten"
);
cout
<<
"Testing vector<string>"
<<
endl
;
vector
<
string
>::
iterator
itersv
=
sv1
.
begin
();
vector
<
string
>::
iterator
endsv
=
sv1
.
end
();
int
i
=
0
;
while
(
itersv
!=
endsv
)
{
cout
<<
"vector["
<<
i
<<
"]:"
<<
*
itersv
<<
endl
;
i
++
;
itersv
++
;
}
unsigned
int
svsize
;
MSH_SIZE_VECTOR_STRING
(
svsize
,
sv1
);
cout
<<
"size = "
<<
svsize
<<
endl
;
bzero
(
buf
,
4096
);
offset
=
0
;
MSH_PACK_VECTOR_STRING
(
buf
,
offset
,
sv1
);
cout
<<
"packed:"
<<
endl
;
hexdump
(
buf
,
svsize
);
vector
<
string
>
sv2
;
offset
=
0
;
MSH_UNPACK_VECTOR_STRING
(
buf
,
offset
,
sv2
);
cout
<<
"Unpacked vector<string>"
<<
endl
;
itersv
=
sv2
.
begin
();
endsv
=
sv2
.
end
();
i
=
0
;
while
(
itersv
!=
endsv
)
{
cout
<<
"vector["
<<
i
<<
"]:"
<<
*
itersv
<<
endl
;
i
++
;
itersv
++
;
}
return
(
0
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment