本文整理汇总了C++中StringBuffer::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::c_str方法的具体用法?C++ StringBuffer::c_str怎么用?C++ StringBuffer::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatExportedServices
StringBuffer MHSyncItemInfo::formatExportedServices()
{
StringBuffer formattedExportedServices("");
KeyValuePair kvp = exportedServices.front();
while (kvp.null() == false) {
StringBuffer serviceName = kvp.getKey();
StringBuffer serviceExportTime = kvp.getValue();
if (serviceName.empty() == false) {
StringBuffer formattedService;
formattedService.sprintf("%s:%s", serviceName.c_str(),
serviceExportTime.c_str());
if (formattedExportedServices.empty() == false) {
formattedExportedServices.append(",");
}
formattedExportedServices.append(formattedService.c_str());
}
kvp = exportedServices.next();
}
return formattedExportedServices;
}
示例2: build_run
void build_run(const char* name, CommandListener& listener)
{
for(Tools::iterator i = g_build_tools.begin(); i != g_build_tools.end(); ++i)
{
StringBuffer output;
(*i).second.evaluate(output);
build_set_variable((*i).first.c_str(), output.c_str());
}
{
Project::iterator i = Project_find(g_build_project, name);
if(i != g_build_project.end())
{
Build& build = (*i).second;
for(Build::iterator j = build.begin(); j != build.end(); ++j)
{
StringBuffer output;
(*j).evaluate(output);
listener.execute(output.c_str());
}
}
else
{
globalErrorStream() << "build " << makeQuoted(name) << " not defined";
}
}
}
示例3: setExportedServicesFromString
void MHSyncItemInfo::setExportedServicesFromString(const char* servicesList)
{
StringBuffer services(servicesList);
if (services.empty() == false) {
ArrayList servicesParam;
int servicesNum = 0;
services.split(servicesParam, ",");
servicesNum = servicesParam.size();
for (int i = 0; i < servicesNum; i++) {
StringBuffer* serviceParamStr = static_cast<StringBuffer *>(servicesParam.get(i));
if ((serviceParamStr) && (serviceParamStr->empty() == false)) {
ArrayList serviceParam;
serviceParamStr->split(serviceParam, ":");
if (serviceParam.size() == 2) {
StringBuffer* serviceName = static_cast<StringBuffer *>(serviceParam.get(0));
StringBuffer* serviceExportTime = static_cast<StringBuffer *>(serviceParam.get(1));
exportedServices.put(serviceName->c_str(), serviceExportTime->c_str());
}
}
}
}
}
示例4: leadHQHandle
void leadHQHandle(void) {
int rsize;
unsigned short index[32]; // <10 keypairs in the incoming json
// only continue if new data to read
if (!Scout.wifi.client.available()) {
return;
}
// Read a block of data and look for packets
while ((rsize = hqIncoming.readClient(Scout.wifi.client, 128))) {
int nl;
while((nl = hqIncoming.indexOf('\n')) >= 0) {
// look for a packet
if (hqVerboseOutput) {
Serial.print(F("looking for packet in: "));
Serial.println(hqIncoming);
}
// Parse JSON up to the first newline
if (!js0n((const unsigned char*)hqIncoming.c_str(), nl, index, 32)) {
leadIncoming(hqIncoming.c_str(), nl, index);
} else {
if (hqVerboseOutput) {
Serial.println(F("JSON parse failed"));
}
}
// Remove up to and including the newline
hqIncoming.remove(0, nl + 1);
}
}
}
示例5: setLogPath
winLog::winLog(bool resetLog, const char* path, const char* name) {
setLogPath(path);
setLogName(name);
// MUST use a wchar_t* logDir to manage correctly international chars.
// If using char* logDir and UTF-8, fopen() is not working correctly and
// will fail to open the log file. (with UTF-8... why?)
// So we use _wfopen() and a wchar_t* logDir.
StringBuffer logDir;
logDir.sprintf("%s\\%s", logPath.c_str(), logName.c_str());
WCHAR* tmp = toWideChar(logDir.c_str());
wlogDir = tmp;
delete [] tmp;
//
// Test to ensure the log file is writable (only if path is set)
//
if (path) {
logFile = _wfopen(wlogDir.c_str(), TEXT("a+"));
if (logFile == NULL) {
WCHAR tmp[512];
wsprintf(tmp, TEXT("Unable to write log file: \"%s\".\nPlease check your user's permissions."), wlogDir.c_str());
MessageBox(NULL, tmp, TEXT("Funambol"), MB_SETFOREGROUND | MB_OK);
}
else {
fclose(logFile);
if (resetLog) {
reset(FUNAMBOL_HEADER);
}
}
}
}
示例6: d
END_TEST
/**
* Removed the STATUS from the winevent parser
*/
BEGIN_TEST(WinEventNoSTATUS)
{
int ret = 0;
SyncItem* item = NULL;
WCHAR* internalKey = NULL;
wstring propValue;
WindowsSyncSource* ss = createAppointmentWindowsSyncSource();
WIN_ASSERT_NOT_NULL(ss, TEXT("The syncSource is null."));
StringBuffer VCal;
VCal.append("BEGIN:VCALENDAR\r\n");
VCal.append("VERSION:1.0\r\n");
VCal.append("BEGIN:VEVENT\r\n");
VCal.append("X-FUNAMBOL-FOLDER:DEFAULT_FOLDER\r\n");
VCal.append("X-FUNAMBOL-ALLDAY:1\r\n");
VCal.append("DTSTART:20110407\r\n");
VCal.append("DTEND:20110408\r\n");
VCal.append("X-MICROSOFT-CDO-BUSYSTATUS:FREE\r\n");
VCal.append("CATEGORIES:\r\n");
VCal.append("DESCRIPTION:\r\n");
VCal.append("LOCATION:Roma\r\n");
VCal.append("PRIORITY:1\r\n");
VCal.append("STATUS:NEED ACTION\r\n");
VCal.append("X-MICROSOFT-CDO-REPLYTIME:\r\n");
VCal.append("SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:Da test\r\n");
VCal.append("CLASS:PUBLIC\r\n");
VCal.append("AALARM:20110406T060000Z;;0;\r\n");
VCal.append("RRULE:\r\n");
VCal.append("X-FUNAMBOL-BILLINGINFO:\r\n");
VCal.append("X-FUNAMBOL-COMPANIES:\r\n");
VCal.append("X-FUNAMBOL-MILEAGE:\r\n");
VCal.append("X-FUNAMBOL-NOAGING:0 \r\n");
VCal.append("END:VEVENT\r\n");
VCal.append("END:VCALENDAR");
item = new SyncItem(TEXT("GUID"));
item->setData(VCal.c_str(), VCal.length());
WCHAR* tt = toWideChar(VCal.c_str());
WinEvent d(tt);
printf("%S", d.toString().c_str());
// insert test item
ret = ss->addItem(*item);
WIN_ASSERT_EQUAL(ret, 201, TEXT("Adding item is not correct"));
internalKey = (WCHAR*)item->getKey();
delete item;
delete ss;
}
示例7: ConfigurationException
void
SchemaTypeTuple::checkRule(
const SchemaValidator * sv,
const Configuration * cfg,
const char * typeName,
const StringVector & typeArgs,
const char * rule) const throw(ConfigurationException)
{
(void) cfg;
StringBuffer msg;
int i;
int len;
const char * elemType;
SchemaType * typeDef;
//--------
// Check there is at least one pair of type and name arguments.
//--------
len = typeArgs.length();
if ((len == 0) || (len % 2 != 0)) {
msg << "the '" << typeName << "' type requires pairs of type and "
<< "name arguments in rule '" << rule << "'";
throw ConfigurationException(msg.c_str());
}
//--------
// Check that all the type arguments are valid types.
//--------
for (i = 0; i < len; i+=2) {
elemType = typeArgs[i+0];
typeDef = findType(sv, elemType);
if (typeDef == 0) {
msg << "unknown type '" << elemType << "' in rule '" << rule << "'";
throw ConfigurationException(msg.c_str());
}
switch (typeDef->cfgType()) {
case Configuration::CFG_STRING:
break;
case Configuration::CFG_LIST:
msg << "you cannot embed a list type ('" << elemType
<< "') inside a " << "tuple in rule '" << rule << "'";
throw ConfigurationException(msg.c_str());
case Configuration::CFG_SCOPE:
msg << "you cannot embed a scope type ('" << elemType
<< "') inside a " << "tuple in rule '" << rule << "'";
throw ConfigurationException(msg.c_str());
default:
assert(0); // Bug!
}
}
}
示例8: readResponseHeaders
void HttpConnection::readResponseHeaders()
{
WCHAR *wbuffer = new WCHAR[1024];
DWORD ddsize = 1024;
StringBuffer headerString;
responseHeaders.clear();
BOOL reqDone = HttpQueryInfo(req, HTTP_QUERY_RAW_HEADERS_CRLF ,(LPVOID)wbuffer, &ddsize, NULL);
if (reqDone == false) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
// Allocate the necessary buffer.
delete [] wbuffer;
wbuffer = new WCHAR[ddsize];
reqDone = HttpQueryInfo(req, HTTP_QUERY_RAW_HEADERS_CRLF ,(LPVOID)wbuffer, &ddsize, NULL);
}
}
if (reqDone) {
headerString.convert(wbuffer);
LOG.debug("Response Headers:", headerString.c_str());
ArrayList headers;
headerString.split(headers, "\r\n");
StringBuffer *prop;
for(ArrayElement* e=headers.front(); e; e=headers.next()) {
prop = dynamic_cast<StringBuffer *>(e);
if(prop->empty()) continue;
size_t colon = prop->find(":");
if (colon != StringBuffer::npos) {
StringBuffer key = prop->substr(0, colon);
StringBuffer value = prop->substr(colon+1);
responseHeaders.put(key.trim(),value.trim());
if (canBeLogged(key)) {
LOG.debug("\t%s : %s", key.c_str(), value.c_str());
} else {
LOG.debug("\t%s : *****", key.c_str());
}
}
else {
LOG.debug("\t%s", prop->c_str());
}
}
} else {
DWORD err = GetLastError();
const char* msg = createHttpErrorMessage(err);
LOG.error("[HttpConnection] Error reading response headers - code %d: %s", err, msg);
delete [] msg;
}
}
示例9: ConfigurationException
LexBase::LexBase(
Configuration::SourceType sourceType,
const char * source,
UidIdentifierProcessor * uidIdentifierProcessor)
throw(ConfigurationException)
{
StringBuffer msg;
//--------
// Initialize state for the multi-byte functions in the C library.
//--------
memset(&m_mbtowcState, 0, sizeof(mbstate_t));
m_keywordInfoArray = 0;
m_keywordInfoArraySize = 0;
m_funcInfoArray = 0;
m_funcInfoArraySize = 0;
m_uidIdentifierProcessor = uidIdentifierProcessor;
m_amOwnerOfUidIdentifierProcessor = false;
m_sourceType = sourceType;
m_source = source;
m_lineNum = 1;
m_ptr = 0;
m_atEOF = false;
switch (sourceType) {
case Configuration::INPUT_FILE:
if (!m_file.open(source)) {
msg << "cannot open " << source << ": " << strerror(errno);
throw ConfigurationException(msg.c_str());
}
break;
case Configuration::INPUT_STRING:
m_ptr = m_source;
break;
case Configuration::INPUT_EXEC:
if (!execCmd(source, m_execOutput)) {
msg << "cannot parse 'exec#" << source << "': "
<< m_execOutput.c_str();
throw ConfigurationException(msg.c_str());
}
m_ptr = m_execOutput.c_str();
break;
default:
assert(0); // Bug!
break;
}
nextChar(); // initialize m_ch
}
示例10: leadHQHandle
void leadHQHandle(void) {
int rsize = 0;
int nl;
unsigned short index[32]; // <10 keypairs in the incoming json
if(Scout.handler.isBridged)
{
rsize = (int)Scout.handler.bridge.length();
hqIncoming += Scout.handler.bridge;
Scout.handler.bridge = "";
} else if (WifiModule::instance.bp()) {
if (WifiModule::instance.bp()->client.available()) {
rsize = hqIncoming.readClient(WifiModule::instance.bp()->client, 128);
if(rsize > 0) Scout.handler.seen = SleepHandler::uptime().seconds;
}
}
// only continue if new data to process
if(rsize <= 0) return;
// Read a block of data and look for packets
while((nl = hqIncoming.indexOf('\n')) >= 0) {
// look for a packet
if(nl)
{
if (Scout.handler.isVerbose) {
Serial.print(F("looking for packet in: "));
Serial.println(hqIncoming);
}
// Parse JSON up to the first newline
if (!js0n((const unsigned char*)hqIncoming.c_str(), nl, index, 32)) {
leadIncoming(hqIncoming.c_str(), nl, index);
} else {
if (Scout.handler.isVerbose) {
Serial.println(F("JSON parse failed"));
}
}
}else{
if (Scout.handler.isVerbose) {
Serial.println(F("HQ ack'd"));
}
}
// Remove up to and including the newline
hqIncoming.remove(0, nl + 1);
}
}
示例11: testConvert
void testConvert() {
StringBuffer str(TEST_STRING);
char* toUtf8 = toMultibyte(TEXT(TEST_STRING));
char* toLatin1 = toMultibyte(TEXT(TEST_STRING), "iso_8859-1");
StringBuffer cnv;
cnv.convert(TEXT(TEST_STRING));
fprintf(stderr, "\nConverted string: %s\n", cnv.c_str());
CPPUNIT_ASSERT((strcmp(cnv.c_str(), toUtf8) == 0));
cnv.convert(TEXT(TEST_STRING), "iso_8859-1");
fprintf(stderr, "\nConverted string: %s\n", cnv.c_str());
CPPUNIT_ASSERT((strcmp(cnv.c_str(), toLatin1) == 0));
}
示例12: evaluate
void evaluate(StringBuffer& output)
{
StringBuffer variable;
bool in_variable = false;
for(const char* i = m_string.c_str(); *i != '\0'; ++i)
{
if(!in_variable)
{
switch(*i)
{
case '[':
in_variable = true;
break;
default:
output.push_back(*i);
break;
}
}
else
{
switch(*i)
{
case ']':
in_variable = false;
output.push_string(build_get_variable(variable.c_str()));
variable.clear();
break;
default:
variable.push_back(*i);
break;
}
}
}
}
示例13: spit
void spit (string const& filename, StringBuffer const& content) {
int fd = TRI_CREATE(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP);
if (fd == -1) {
LOG_TRACE("open failed for '%s' with %s", filename.c_str(), strerror(errno));
THROW_FILE_OPEN_ERROR("open", filename, "O_WRONLY | O_CREAT | O_TRUNC", errno);
}
char const* ptr = content.c_str();
size_t len = content.length();
while (0 < len) {
ssize_t n = TRI_WRITE(fd, ptr, len);
if (n < 1) {
TRI_CLOSE(fd);
LOG_TRACE("write failed for '%s' with %s and result %d on %d",
filename.c_str(),
strerror(errno),
(int) n,
fd);
THROW_FILE_FUNC_ERROR("write", "", errno);
}
ptr += n;
len -= n;
}
TRI_CLOSE(fd);
return;
}
示例14: leadCommandChunk
// called to send the first/next chunk of a command to another scout
static void leadCommandChunk() {
int len = leadCommandChunks.length() - leadCommandChunksAt;
if (len > 100) {
len = 100;
} else {
len++; // null terminator at end
}
leadCommandReq.dstAddr = leadCommandTo;
leadCommandReq.dstEndpoint = 2;
leadCommandReq.srcEndpoint = 3;
leadCommandReq.options = NWK_OPT_ENABLE_SECURITY;
leadCommandReq.data = (uint8_t*)leadCommandChunks.c_str() + leadCommandChunksAt;
leadCommandReq.size = len;
leadCommandReq.confirm = leadCommandChunkConfirm;
NWK_DataReq(&leadCommandReq);
//RgbLed.blinkCyan(200);
if (hqVerboseOutput) {
Serial.print(leadCommandTo);
Serial.print(F(" len "));
Serial.print(len);
Serial.println(F("->chunk"));
}
}
示例15: setRequestHeaders
void HttpUploader::setRequestHeaders(const StringBuffer& luid, HttpConnection& httpConnection, InputStream& inputStream) {
StringBuffer dataSize;
int totalSize = inputStream.getTotalSize();
LOG.debug("[%s]: input stream size is %i", __FUNCTION__, totalSize);
LOG.debug("[%s]: totalDataToUpload size is %i", __FUNCTION__, totalDataToUpload);
if (totalDataToUpload > 0) {
totalSize = totalDataToUpload;
}
dataSize.sprintf("%d", totalSize);
httpConnection.setRequestHeader(HTTP_HEADER_ACCEPT, "*/*");
httpConnection.setRequestHeader(HTTP_HEADER_CONTENT_TYPE, "application/octet-stream");
// set transfer enconding to chunked
//httpConnection.setRequestHeader(HTTP_HEADER_TRANSFER_ENCODING, "chunked");
// set Funambol mandatory custom headers
httpConnection.setRequestHeader(HTTP_HEADER_X_FUNAMBOL_FILE_SIZE, dataSize);
httpConnection.setRequestHeader(HTTP_HEADER_X_FUNAMBOL_DEVICE_ID, deviceID);
httpConnection.setRequestHeader(HTTP_HEADER_X_FUNAMBOL_LUID, luid);
if (partialUploadedData > 0) {
StringBuffer s;
s.sprintf("bytes %d-%d/%d", partialUploadedData, totalSize-1, totalSize);
httpConnection.setRequestHeader(HTTP_HEADER_CONTENT_RANGE, s.c_str());
}
}