| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | ProcessSettings.h |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains the definition of the WinRT wrapper for the WSLC SDK ProcessSettings class. |
| 12 | --*/ |
| 13 | |
| 14 | #pragma once |
| 15 | #include "Microsoft.WSL.Containers.ProcessSettings.g.h" |
| 16 | #include "Helpers.h" |
| 17 | #include "Process.h" |
| 18 | |
| 19 | namespace winrt::Microsoft::WSL::Containers::implementation { |
| 20 | |
| 21 | struct StringArray |
| 22 | { |
| 23 | StringArray() = default; |
| 24 | StringArray(size_t capacity); |
| 25 | void Add(std::string&& s); |
| 26 | PCSTR* GetRawPointer(); |
| 27 | |
| 28 | private: |
| 29 | std::vector<std::string> m_strings; |
| 30 | std::vector<PCSTR> m_rawStrings; |
| 31 | }; |
| 32 | |
| 33 | struct ProcessSettings : ProcessSettingsT<ProcessSettings> |
| 34 | { |
| 35 | ProcessSettings() = default; |
| 36 | |
| 37 | hstring WorkingDirectory(); |
| 38 | void WorkingDirectory(hstring const& value); |
| 39 | winrt::Windows::Foundation::Collections::IVector<hstring> CommandLine(); |
| 40 | void CommandLine(winrt::Windows::Foundation::Collections::IVector<hstring> const& value); |
| 41 | winrt::Windows::Foundation::Collections::IMap<hstring, hstring> EnvironmentVariables(); |
| 42 | void EnvironmentVariables(winrt::Windows::Foundation::Collections::IMap<hstring, hstring> const& value); |
| 43 | winrt::Microsoft::WSL::Containers::ProcessOutputMode OutputMode(); |
| 44 | void OutputMode(winrt::Microsoft::WSL::Containers::ProcessOutputMode const& value); |
| 45 | |
| 46 | WslcProcessSettings* ToStructPointer(); |
| 47 | |
| 48 | private: |
| 49 | std::string m_workingDirectory; |
| 50 | winrt::Windows::Foundation::Collections::IVector<hstring> m_commandLine{winrt::single_threaded_vector<hstring>()}; |
| 51 | winrt::Windows::Foundation::Collections::IMap<hstring, hstring> m_environmentVariables{winrt::single_threaded_map<hstring, hstring>()}; |
| 52 | winrt::Microsoft::WSL::Containers::ProcessOutputMode m_outputMode{winrt::Microsoft::WSL::Containers::ProcessOutputMode::Discard}; |
| 53 | |
| 54 | std::unique_ptr<WslcProcessSettings> m_processSettings; |
| 55 | StringArray m_commandLineStrings; |
| 56 | StringArray m_envStrings; |
| 57 | }; |
| 58 | } // namespace winrt::Microsoft::WSL::Containers::implementation |
| 59 | |
| 60 | namespace winrt::Microsoft::WSL::Containers::factory_implementation { |
| 61 | struct ProcessSettings : ProcessSettingsT<ProcessSettings, implementation::ProcessSettings> |
| 62 | { |
| 63 | }; |
| 64 | } // namespace winrt::Microsoft::WSL::Containers::factory_implementation |
| 65 | |
| 66 | DEFINE_TYPE_HELPERS(ProcessSettings); |