Skip to content

Commit f7c3f60

Browse files
Add std::string to RMI with cleanups.
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent eb10e79 commit f7c3f60

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/qvi-bbuff-rmi.h

+34-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2021-2023 Triad National Security, LLC
3+
* Copyright (c) 2021-2024 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* This file is part of the quo-vadis project. See the LICENSE file at the
@@ -19,6 +19,7 @@
1919
* h = qvi_line_hwpool_t *
2020
* i = int
2121
* s = char *
22+
* s = std::string
2223
* t = qvi_task_id_t
2324
* z = qvi_bbuff_rmi_zero_msg_t
2425
*/
@@ -30,10 +31,8 @@
3031
#include "qvi-hwloc.h"
3132
#include "qvi-hwpool.h"
3233

33-
#include <string>
34-
3534
// 'Null' cpuset representation as a string.
36-
#define QV_BUFF_RMI_NULL_CPUSET ""
35+
static const cstr_t QV_BUFF_RMI_NULL_CPUSET = "";
3736

3837
// Byte containers
3938
using qvi_bbuff_rmi_bytes_in_t = std::pair<void *, size_t>;
@@ -227,6 +226,15 @@ qvi_bbuff_rmi_pack_type_picture(
227226
picture += "s";
228227
}
229228

229+
template<>
230+
inline void
231+
qvi_bbuff_rmi_pack_type_picture(
232+
std::string &picture,
233+
std::string &
234+
) {
235+
picture += "s";
236+
}
237+
230238
template<>
231239
inline void
232240
qvi_bbuff_rmi_pack_type_picture(
@@ -361,6 +369,17 @@ qvi_bbuff_rmi_pack_item_impl(
361369
return qvi_bbuff_append(buff, data, strlen(data) + 1);
362370
}
363371

372+
/**
373+
* Packs std::string
374+
*/
375+
inline int
376+
qvi_bbuff_rmi_pack_item(
377+
qvi_bbuff_t *buff,
378+
const std::string &data
379+
) {
380+
return qvi_bbuff_rmi_pack_item_impl(buff, data.c_str());
381+
}
382+
364383
/**
365384
* Packs const char *
366385
*/
@@ -660,6 +679,17 @@ qvi_bbuff_rmi_unpack_item(
660679
return QV_SUCCESS;
661680
}
662681

682+
inline int
683+
qvi_bbuff_rmi_unpack_item(
684+
std::string &str,
685+
byte_t *buffpos,
686+
size_t *bytes_written
687+
) {
688+
str = std::string((const char *)buffpos);
689+
*bytes_written = strlen((char *)buffpos) + 1;
690+
return QV_SUCCESS;
691+
}
692+
663693
inline int
664694
qvi_bbuff_rmi_unpack_item(
665695
qv_scope_intrinsic_t *o,
@@ -798,7 +828,6 @@ qvi_bbuff_rmi_unpack_item(
798828
);
799829
if (rc != QV_SUCCESS) goto out;
800830
total_bw += bw;
801-
buffpos += bw;
802831
out:
803832
if (rc != QV_SUCCESS) {
804833
total_bw = 0;
@@ -901,7 +930,6 @@ qvi_bbuff_rmi_unpack_item(
901930
);
902931
if (rc != QV_SUCCESS) goto out;
903932
total_bw += bw;
904-
buffpos += bw;
905933
out:
906934
if (rc != QV_SUCCESS) {
907935
total_bw = 0;

0 commit comments

Comments
 (0)