本文整理汇总了C++中string_type::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ string_type::c_str方法的具体用法?C++ string_type::c_str怎么用?C++ string_type::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string_type
的用法示例。
在下文中一共展示了string_type::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move
filter default_filter_factory< CharT >::parse_argument(attribute_name const& name, string_type const& arg)
{
typedef log::aux::encoding_specific< typename log::aux::encoding< char_type >::type > encoding_specific;
const qi::real_parser< double, qi::strict_real_policies< double > > real_;
filter f;
const on_fp_argument< RelationT > on_fp(name, f);
const on_integral_argument< RelationT > on_int(name, f);
const on_string_argument< RelationT > on_str(name, f);
const bool res = qi::parse
(
arg.c_str(), arg.c_str() + arg.size(),
(
real_[boost::log::as_action(on_fp)] |
qi::long_[boost::log::as_action(on_int)] |
qi::as< string_type >()[ +encoding_specific::print ][boost::log::as_action(on_str)]
) >> qi::eoi
);
if (!res)
BOOST_LOG_THROW_DESCR(parse_error, "Failed to parse relation operand");
return boost::move(f);
}
示例2: SCSAT_SaveSamples
int CCommonFnc::SCSAT_SaveSamples(string_type filePath, SAMPLE_PLOT* pSample, int startOffset, int endOffset) {
int status = STAT_OK;
MoveFile((LPCTSTR) filePath.c_str(), (LPCTSTR) (filePath + _CONV(".bak")).c_str());
DeleteFile((LPCTSTR) filePath.c_str());
// SAVE HEADER
string_type tmp;
pSample->measureInfo.formatToString(&tmp);
CCommonFnc::File_AppendString(filePath, tmp);
int samplesFileOffset = 0;
if ((status = CCommonFnc::SCSAT_GetPowerSamplesFileOffset(filePath, &samplesFileOffset)) == STAT_OK) {
if ((status = CCommonFnc::File_SaveMatrixIntFileOffset(samplesFileOffset, filePath, &(pSample->dataBlob), startOffset, endOffset, pSample->measureInfo.bSaveBinary)) == STAT_OK) {
// store number of written samples
if (endOffset == -1) endOffset = pSample->dataBlob.dwActLen;
pSample->measureInfo.numSamples = endOffset - startOffset + 2;
tmp = string_format(_CONV("%d"), pSample->measureInfo.numSamples);
//tmp.Format("%d", pSample->measureInfo.numSamples);
WritePrivateProfileString(SCSAT_MEASURE_SECTION.c_str(), SCSAT_MEASURE_NUMSAMPLES.c_str(), (LPCTSTR) tmp.c_str(), (LPCTSTR) filePath.c_str());
}
}
if (status == STAT_OK) {
DeleteFile((LPCTSTR) (filePath + _CONV(".bak")).c_str());
}
return status;
}
示例3: out_of_range
inline winini_bundle::string_type winini_bundle::operator [](char_type const *name) const throw(std::out_of_range)
{
static const char_type sentinel[] = FASTFORMAT_LITERAL_STRING("{5DDAADE5-5134-4734-ACB8-A6D0FA3BD0EA}-{D875F19B-8279-4c44-9517-F16366BC13E3}");
::SetLastError(0);
char_type result[1001];
DWORD dw = ::GetPrivateProfileString(
m_iniSection.c_str()
, name
, sentinel
, &result[0]
, STLSOFT_NUM_ELEMENTS(result)
, m_iniFileName.c_str());
if(dw == STLSOFT_NUM_ELEMENTS(sentinel) - 1) /* element not found */
{
if(0 == string_type::traits_type::compare(sentinel, result, stlsoft::minimum(size_t(dw), STLSOFT_NUM_ELEMENTS(sentinel) - 1)))
{
throw std::out_of_range("section/key combination does not exist in the given INI file");
}
}
::GetLastError();
return string_type(result, dw);
}
示例4: DWORD
BOOST_LOG_EXPORT void basic_event_log_backend< CharT >::construct(
boost::log::aux::universal_path const& message_file_name,
string_type const& target,
string_type const& log_name,
string_type const& source_name,
event_log::registration_mode reg_mode)
{
if (reg_mode != event_log::never)
{
aux::registry_params< char_type > reg_params;
string_type file_name;
log::aux::code_convert(message_file_name.string(), file_name);
reg_params.event_message_file = file_name;
reg_params.types_supported = DWORD(
EVENTLOG_SUCCESS |
EVENTLOG_INFORMATION_TYPE |
EVENTLOG_WARNING_TYPE |
EVENTLOG_ERROR_TYPE);
aux::init_event_log_registry(log_name, source_name, reg_mode == event_log::forced, reg_params);
}
std::auto_ptr< implementation > p(new implementation());
const char_type* target_unc = NULL;
if (!target.empty())
target_unc = target.c_str();
HANDLE hSource = register_event_source(target_unc, source_name.c_str());
if (!hSource)
BOOST_LOG_THROW_DESCR(system_error, "Could not register event source");
p->m_SourceHandle = hSource;
m_pImpl = p.release();
}
示例5: set_input_format
void TimestampConverter::set_input_format(string_type const& format)
{
this->InputFormat = format;
typedef boost::posix_time::time_input_facet input_facet_t;
input_facet_t* facet = new input_facet_t(format.c_str());
this->InputBuf.imbue(std::locale(this->InputBuf.getloc(), facet));
}
示例6: connection_error
client::client(const string_type & host, unsigned int port)
{
char err[ANET_ERR_LEN];
socket_ = anetTcpConnect(err, const_cast<char*>(host.c_str()), port);
if (socket_ == ANET_ERR)
throw connection_error(err);
anetTcpNoDelay(NULL, socket_);
}
示例7:
typename default_filter_factory< CharT >::filter_type
default_filter_factory< CharT >::parse_argument(string_type const& name, string_type const& arg)
{
filter_type filter;
const bool full = bsc::parse(arg.c_str(), arg.c_str() + arg.size(),
(
bsc::strict_real_p[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_fp_argument< RelationT >, boost::cref(name), _1, boost::ref(filter))] |
bsc::int_p[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_integral_argument< RelationT >, boost::cref(name), _1, boost::ref(filter))] |
(+bsc::print_p)[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_string_argument< RelationT >, boost::cref(name), _1, _2, boost::ref(filter))]
)
).full;
if (!full || filter.empty())
BOOST_LOG_THROW_DESCR(parse_error, "Failed to parse relation operand");
return filter;
}
示例8: BYTE_ConvertFromHexNumToByte
int CCommonFnc::BYTE_ConvertFromHexNumToByte(string_type hexNum, BYTE* pByte) {
DWORD num = type_to_int((LPCTSTR) hexNum.c_str(), NULL, 16);
if (num == 0xFF) *pByte = 0xFF;
else *pByte = (BYTE) num & 0xFF;
return STAT_OK;
}
示例9: File_AppendString
int CCommonFnc::File_AppendString(string_type filePath, string_type data) {
int status = STAT_OK;
ofstream_type file;
file.open(filePath, std::fstream::out | std::fstream::app);
if (file.is_open()) {
file.write((LPCTSTR)data.c_str(), data.length());
file.close();
}
else status = STAT_FILE_OPEN_FAIL;
return status;
}
示例10: send
//! The method sends the formatted message to the syslog host
void send(syslog::level lev, string_type const& formatted_message)
{
if (!m_pSocket.get())
{
asio::ip::udp::endpoint any_local_address;
m_pSocket.reset(new syslog_udp_socket(m_pService->m_IOService, m_Protocol, any_local_address));
}
m_pSocket->send_message(
this->m_Facility | static_cast< int >(lev),
m_pService->m_LocalHostName.c_str(),
m_TargetHost,
formatted_message.c_str());
}
示例11: to_stream
void to_stream(T const& value)
{
std::locale loc = m_Stream.getloc();
if (!std::has_facet< FacetT >(loc))
{
// Add the formatting facet
std::auto_ptr< FacetT > facet(new FacetT(m_Format.c_str()));
m_Stream.imbue(std::locale(loc, facet.get()));
facet.release();
loc = m_Stream.getloc();
}
// Perform formatting
std::ostreambuf_iterator< char_type > osb_it(m_Stream);
std::use_facet< FacetT >(loc).put(osb_it, m_Stream, m_Stream.fill(), value);
}
示例12: sizeof
thread_callback()
: window_handle_(0)
, atom_(0)
, identity_(sprig::str_cast<string_type>(boost::uuids::random_generator()()))
{
window_class_.cbSize = sizeof(WNDCLASSEX); // 構造体のサイズ
window_class_.style = 0; // クラススタイル
window_class_.lpfnWndProc = static_cast<WNDPROC>(&windowProcedure); // ウィンドウプロシージャ
window_class_.cbClsExtra = 0; // 補足メモリブロックのサイズ
window_class_.cbWndExtra = 0; // 補足メモリブロックのサイズ
window_class_.hInstance = ::GetModuleHandle(0); // インスタンス
window_class_.hIcon = 0; // アイコン
window_class_.hCursor = 0; // カーソル
window_class_.hbrBackground = 0; // 背景色
window_class_.lpszMenuName = 0; // メニュー名
window_class_.lpszClassName = identity_.c_str(); // クラス名
window_class_.hIconSm = 0; // 小さいアイコン
}
示例13: File_GetAvailableFileName
int CCommonFnc::File_GetAvailableFileName(string_type baseFile, string_type* pFreeFileName) {
int status = STAT_OK;
char_type fileName[MAX_PATH];
string_type fileNameStr;
char_type drive[_MAX_DRIVE];
char_type dir[_MAX_DIR];
char_type fname[_MAX_FNAME];
char_type ext[_MAX_EXT];
const char_type* help;
DWORD index = 1;
// FIND FIRST FREE INDEX
type_path_split(baseFile.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);
index = 1;
string_type zeroes = _CONV("0000");
//sprintf_s(fileName, MAX_PATH, "%s%s%s%s%d%s", drive, dir, fname, (LPCTSTR) zeroes.c_str(), index, ext);
fileNameStr = string_format(_CONV("%s%s%s%s%d%s"), drive, dir, fname, (LPCTSTR)zeroes.c_str(), index, ext);
help = fileNameStr.c_str();
type_copy(fileName, help);
while (GetFileAttributes(fileName) != -1) {
index++;
if (index < 10) zeroes = _CONV("0000");
else if (index < 100) zeroes = _CONV("000");
else if (index < 1000) zeroes = _CONV("00");
else if (index < 10000) zeroes = _CONV("0");
else zeroes = _CONV("");
//sprintf_s(fileName, MAX_PATH, "%s%s%s%s%d%s", drive, dir, fname, (LPCTSTR) zeroes.c_str(), index, ext);
fileNameStr = string_format(_CONV("%s%s%s%s%d%s"), drive, dir, fname, (LPCTSTR)zeroes.c_str(), index, ext);
help = fileNameStr.c_str();
type_copy(fileName, help);
}
// INDEX FOUND
//pFreeFileName->Format("%s%s%s%s%d%s", drive, dir, fname, (LPCTSTR) zeroes.c_str(), index, ext);
*pFreeFileName = string_format(_CONV("%s%s%s%s%d%s"), drive, dir, fname, (LPCTSTR)zeroes.c_str(), index, ext);
return status;
}
示例14: do_put_tm
virtual OutItrT do_put_tm(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const tm& tm_value,
string_type a_format) const
{
// update format string with custom names
if (m_weekday_long_names.size()) {
boost::algorithm::replace_all(a_format,
long_weekday_format,
m_weekday_long_names[tm_value.tm_wday]);
}
if (m_weekday_short_names.size()) {
boost::algorithm::replace_all(a_format,
short_weekday_format,
m_weekday_short_names[tm_value.tm_wday]);
}
if (m_month_long_names.size()) {
boost::algorithm::replace_all(a_format,
long_month_format,
m_month_long_names[tm_value.tm_mon]);
}
if (m_month_short_names.size()) {
boost::algorithm::replace_all(a_format,
short_month_format,
m_month_short_names[tm_value.tm_mon]);
}
// use time_put facet to create final string
const char_type* p_format = a_format.c_str();
return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
fill_char,
&tm_value,
p_format,
p_format + a_format.size());
}
示例15: SCSAT_EnsureFileHeader
int CCommonFnc::SCSAT_EnsureFileHeader(string_type filePath, SCSAT_MEASURE_INFO* pInfo) {
int status = STAT_OK;
char_type iniValue[MAX_INI_VALUE_CHAR];
// CHECK IF HEADER EXISTS
BOOL bNewFormat = FALSE;
int fileLength = 0;
fstream_type file;
file.open(filePath, std::fstream::in | std::fstream::out);
if (file.is_open()) {
char_type buffer[100];
memset(buffer, 0, sizeof(buffer));
file.read(buffer, 100);
file.seekg(0, std::ios_base::end);
//fileLength = file.tellg();
file.seekg(0, std::ios_base::beg);
string_type header = buffer; string_type part = header.substr(1, (int)SCSAT_MEASURE_SECTION.length());
if (compareWithNoCase2(SCSAT_MEASURE_SECTION.c_str(), part.c_str()) == 0) bNewFormat = TRUE;
//if (part.compareWithNoCase(SCSAT_MEASURE_SECTION) == 0) bNewFormat = TRUE;
else bNewFormat = FALSE;
// WRITE IF NOT
if (!bNewFormat) {
string_type tmp;
if (pInfo->sampleUniqueID == 0) {
CCommonFnc::Sample_GenerateSampleUniqueID(&(pInfo->sampleUniqueID));
}
pInfo->formatToString(&tmp);
file.seekg(0, std::ios_base::beg);
file.seekp(0, std::ios_base::beg);
file.write(tmp.c_str(), tmp.length());
}
file.close();
// if the sampleUniqueID is not present
if(bNewFormat) {
GetPrivateProfileString(SCSAT_MEASURE_SECTION.c_str(), SCSAT_MEASURE_SAMPLEUNIQUEID.c_str(), _CONV(""), iniValue, MAX_INI_VALUE_CHAR, (LPCTSTR) filePath.c_str());
if (type_length(iniValue) == 0) {
if (pInfo->sampleUniqueID == 0) {
CCommonFnc::Sample_GenerateSampleUniqueID(&(pInfo->sampleUniqueID));
}
string_type tmp;
tmp = string_format(_CONV("%lld"), pInfo->sampleUniqueID);
//tmp.AtlUtil::Format("%lld", pInfo->sampleUniqueID);
WritePrivateProfileString(SCSAT_MEASURE_SECTION.c_str(),SCSAT_MEASURE_SAMPLEUNIQUEID.c_str(), tmp.c_str(), filePath.c_str());
}
}
}
return status;
}