39template<
typename TAllocator= lang::HeapAllocator>
87 constexpr int initialBufferSize = 4096;
88 constexpr int readSize = 1024 - 1;
93 FILE* pipe= popen(cmd,
"r");
94 #elif defined (_WIN32)
95 FILE* pipe= _popen(cmd,
"r");
97 #pragma message ("Unknown Platform in file: " __FILE__ )
105 if (!fgets(readBuffer.
VBuffer()+readBuffer.
Length(), readSize, pipe))
110 if ( readBuffer.
Length() < len )
115 int resultCode = pclose(pipe);
116 if (resultCode != -1) {
118 if (WIFEXITED(resultCode)) resultCode= WEXITSTATUS(resultCode);
121 else if (WIFSIGNALED(resultCode)) resultCode= 128 + WTERMSIG(resultCode);
123 #elif defined (_WIN32)
124 int resultCode = _pclose(pipe);
126 #pragma message ("Unknown Platform in file: " __FILE__ )
140 readBuffer.
Length() - origBufferLen ) ,
'\n');
integer DetectLength(integer offset=0)
void EnsureRemainingCapacity(integer spaceNeeded)
TAString & Append(const TCharSrc *src, integer srcLength)
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())
ALIB_DLL 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::util::TTokenizer< nchar > TokenizerN
Type alias in namespace alib.
system::TShellCommand< MonoAllocator > ShellCommandMA
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TString< nchar > NString
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::TCString< nchar > NCString
Type alias in namespace alib.