42template<
typename TAllocator= lang::HeapAllocator>
91 constexpr int initialBufferSize = 4096;
92 constexpr int readSize = 1024 - 1;
97 FILE* pipe= popen(cmd,
"r");
98 #elif defined (_WIN32)
99 FILE* pipe= _popen(cmd,
"r");
101 #pragma message ("Unknown Platform in file: " __FILE__ )
109 if (!fgets(readBuffer.
VBuffer()+readBuffer.
Length(), readSize, pipe))
114 if ( readBuffer.
Length() < len )
119 int resultCode = pclose(pipe);
120 if (resultCode != -1) {
122 if (WIFEXITED(resultCode)) resultCode= WEXITSTATUS(resultCode);
125 else if (WIFSIGNALED(resultCode)) resultCode= 128 + WTERMSIG(resultCode);
127 #elif defined (_WIN32)
128 int resultCode = _pclose(pipe);
130 #pragma message ("Unknown Platform in file: " __FILE__ )
144 readBuffer.
Length() - origBufferLen ) ,
'\n');
integer DetectLength(integer offset=0)
TAString & Append(const TCharSrc *src, integer srcLength)
void EnsureRemainingCapacity(integer spaceNeeded)
TAString & TrimEnd(const TCString< TChar > &trimChars=CStringConstantsTraits< TChar >::DefaultWhitespaces())
constexpr integer Length() const
constexpr bool IsEmpty() const
constexpr const TChar * Buffer() const
TSubstring & TrimEnd(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
strings::TAString< nchar, AllocatorType > ReadBuffer
int Run(const NCString &cmd, lang::CurrentData keepData=lang::CurrentData::Clear)
TShellCommand()
Default constructor. Usable with type #"HeapAllocator".
strings::util::TStringVector< nchar, TAllocator > StringVector
The base type of this class.
static int Run(const NCString &cmd, strings::TAString< nchar, AllocatorType > &readBuffer, StringVector *lines=nullptr)
TAllocator AllocatorType
The allocator type that TAllocator specifies.
TShellCommand(AllocatorType &ma)
@ Clear
Chooses to clear existing data.
@ Keep
Keep whitespaces in string.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TCString< nchar > NCString
Type alias in namespace alib.
system::TShellCommand< MonoAllocator > ShellCommandMA
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
system::TShellCommand< lang::HeapAllocator > ShellCommand
Type alias in namespace alib.
constexpr NCString NNEW_LINE
A zero-terminated string containing the new-line character sequence.
strings::util::TTokenizer< nchar > TokenizerN
Type alias in namespace alib.