-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cpp-client): Add entry points for SetEnv() and UnsetEnv() (#5987)
- Loading branch information
Showing
6 changed files
with
196 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
cpp-client/deephaven/dhcore/include/public/deephaven/dhcore/interop/utility_interop.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
*/ | ||
#pragma once | ||
|
||
#include "deephaven/dhcore/interop/interop_util.h" | ||
|
||
extern "C" { | ||
void deephaven_dhcore_utility_GetEnv(const char *envname, | ||
deephaven::dhcore::interop::StringHandle *string_handle, | ||
deephaven::dhcore::interop::StringPoolHandle *string_pool_handle, | ||
deephaven::dhcore::interop::ErrorStatus *status); | ||
|
||
void deephaven_dhcore_utility_SetEnv(const char *envname, const char *value, | ||
deephaven::dhcore::interop::ErrorStatus *status); | ||
|
||
void deephaven_dhcore_utility_UnsetEnv(const char *envname, | ||
deephaven::dhcore::interop::ErrorStatus *status); | ||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
cpp-client/deephaven/dhcore/src/interop/utility_interop.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
*/ | ||
#include "deephaven/dhcore/interop/utility_interop.h" | ||
|
||
#include "deephaven/dhcore/interop/interop_util.h" | ||
#include "deephaven/dhcore/utility/utility.h" | ||
|
||
using deephaven::dhcore::interop::ErrorStatus; | ||
using deephaven::dhcore::interop::StringHandle; | ||
using deephaven::dhcore::interop::StringPoolBuilder; | ||
using deephaven::dhcore::interop::StringPoolHandle; | ||
using deephaven::dhcore::utility::GetEnv; | ||
using deephaven::dhcore::utility::SetEnv; | ||
using deephaven::dhcore::utility::UnsetEnv; | ||
|
||
extern "C" { | ||
void deephaven_dhcore_utility_GetEnv(const char *envname, | ||
StringHandle *string_handle, StringPoolHandle *string_pool_handle, ErrorStatus *status) { | ||
status->Run([=]() { | ||
StringPoolBuilder builder; | ||
auto result = GetEnv(envname); | ||
if (result.has_value()) { | ||
*string_handle = builder.Add(*result); | ||
} | ||
// If envname is not found in the environment, caller will see an empty builder | ||
*string_pool_handle = builder.Build(); | ||
}); | ||
} | ||
|
||
void deephaven_dhcore_utility_SetEnv(const char *envname, const char *value, ErrorStatus *status) { | ||
status->Run([=]() { | ||
SetEnv(envname, value); | ||
}); | ||
} | ||
|
||
void deephaven_dhcore_utility_UnsetEnv(const char *envname, ErrorStatus *status) { | ||
status->Run([=]() { | ||
UnsetEnv(envname); | ||
}); | ||
} | ||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters