finish linux related code writting. remove all offensive content.
- REMOVE all offensive content in README and etc. This project respect to every contributors. - However, for commercial reason, we limit the contribution from Dassault. - Change license. - Finish linux platform code.
This commit is contained in:
@ -1,24 +1,30 @@
|
||||
#include "StringHelper.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Unvirt {
|
||||
namespace StringHelper {
|
||||
|
||||
void StdstringPrintf(std::string& strl, const char* format, ...) {
|
||||
va_list argptr;
|
||||
va_start(argptr, format);
|
||||
StdstringVPrintf(strl, format, argptr);
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr) {
|
||||
int count = _vsnprintf(NULL, 0, format, argptr);
|
||||
|
||||
strl.resize(count);
|
||||
int write_result = _vsnprintf(strl.data(), count, format, argptr);
|
||||
|
||||
if (write_result < 0 || write_result > count) throw new std::length_error("Invalid write_result in _vsnprintf.");
|
||||
}
|
||||
namespace Unvirt::StringHelper {
|
||||
|
||||
void StdstringPrintf(std::string& strl, const char* format, ...) {
|
||||
va_list argptr;
|
||||
va_start(argptr, format);
|
||||
StdstringVPrintf(strl, format, argptr);
|
||||
va_end(argptr);
|
||||
}
|
||||
|
||||
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr) {
|
||||
va_list args1;
|
||||
va_copy(args1, argptr);
|
||||
va_list args2;
|
||||
va_copy(args2, argptr);
|
||||
|
||||
int count = std::vsnprintf(nullptr, 0, format, args1);
|
||||
if (count < 0) throw new std::length_error("Invalid length returned by vsnprintf.");
|
||||
va_end(args1);
|
||||
|
||||
strl.resize(count + 1);
|
||||
int write_result = std::vsnprintf(strl.data(), strl.size(), format, args2);
|
||||
va_end(args2);
|
||||
|
||||
if (write_result < 0 || write_result > count) throw new std::length_error("Invalid write result in vsnprintf.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,9 @@
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
|
||||
namespace Unvirt {
|
||||
namespace StringHelper {
|
||||
namespace Unvirt::StringHelper {
|
||||
|
||||
void StdstringPrintf(std::string& strl, const char* format, ...);
|
||||
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr);
|
||||
void StdstringPrintf(std::string& strl, const char* format, ...);
|
||||
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user