当前位置: 首页>>代码示例>>C++>>正文


C++ StringBuffer::empty方法代码示例

本文整理汇总了C++中StringBuffer::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::empty方法的具体用法?C++ StringBuffer::empty怎么用?C++ StringBuffer::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuffer的用法示例。


在下文中一共展示了StringBuffer::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static bool
EscapeNakedForwardSlashes(StringBuffer &sb, const CharT *oldChars, size_t oldLen)
{
    for (const CharT *it = oldChars; it < oldChars + oldLen; ++it) {
        if (*it == '/' && (it == oldChars || it[-1] != '\\')) {
            /* There's a forward slash that needs escaping. */
            if (sb.empty()) {
                /* This is the first one we've seen, copy everything up to this point. */
                if (mozilla::IsSame<CharT, jschar>::value && !sb.ensureTwoByteChars())
                    return false;

                if (!sb.reserve(oldLen + 1))
                    return false;

                sb.infallibleAppend(oldChars, size_t(it - oldChars));
            }
            if (!sb.append('\\'))
                return false;
        }

        if (!sb.empty() && !sb.append(*it))
            return false;
    }

    return true;
}
开发者ID:aeddi,项目名称:gecko-dev,代码行数:26,代码来源:RegExp.cpp

示例2: testEmpty

    //////////////////////////////////////////////////////// Test /////
    // Test null() and empty() behavior
    void testEmpty() {
        StringBuffer s;
        CPPUNIT_ASSERT(s.empty());
        CPPUNIT_ASSERT(s.null());

        s = "";

        CPPUNIT_ASSERT( s.empty() );
        CPPUNIT_ASSERT( !s.null() );

    }
开发者ID:ruphy,项目名称:kfunambol,代码行数:13,代码来源:StringBufferTest.cpp

示例3: if

static bool
EscapeRegExpPattern(StringBuffer& sb, const CharT* oldChars, size_t oldLen)
{
    bool inBrackets = false;
    bool previousCharacterWasBackslash = false;

    for (const CharT* it = oldChars; it < oldChars + oldLen; ++it) {
        CharT ch = *it;
        if (!previousCharacterWasBackslash) {
            if (inBrackets) {
                if (ch == ']')
                    inBrackets = false;
            } else if (ch == '/') {
                // There's a forward slash that needs escaping.
                if (sb.empty()) {
                    // This is the first char we've seen that needs escaping,
                    // copy everything up to this point.
                    if (!SetupBuffer(sb, oldChars, oldLen, it))
                        return false;
                }
                if (!sb.append('\\'))
                    return false;
            } else if (ch == '[') {
                inBrackets = true;
            }
        }

        if (IsLineTerminator(ch)) {
            // There's LineTerminator that needs escaping.
            if (sb.empty()) {
                // This is the first char we've seen that needs escaping,
                // copy everything up to this point.
                if (!SetupBuffer(sb, oldChars, oldLen, it))
                    return false;
            }
            if (!previousCharacterWasBackslash) {
                if (!sb.append('\\'))
                    return false;
            }
            if (!AppendEscapedLineTerminator(sb, ch))
                return false;
        } else if (!sb.empty()) {
            if (!sb.append(ch))
                return false;
        }

        if (previousCharacterWasBackslash)
            previousCharacterWasBackslash = false;
        else if (ch == '\\')
            previousCharacterWasBackslash = true;
    }

    return true;
}
开发者ID:lgarner,项目名称:mozilla-central,代码行数:54,代码来源:RegExpObject.cpp

示例4: if

void
calculateRuleForName(
	const Configuration *		cfg,
	const char *				name,
	const char *				uName,
	const StringVector &		wildcardedNamesAndTypes,
	StringBuffer &				rule)
{
	int							i;
	int							len;
	const char *				str;
	const char *				keyword;
	const char *				wildcardedName;
	const char *				type;

	rule.empty();
	len = wildcardedNamesAndTypes.length();
	for (i = 0; i < len; i+=3) {
		keyword        = wildcardedNamesAndTypes[i+0]; // @optional or @required
		wildcardedName = wildcardedNamesAndTypes[i+1];
		type           = wildcardedNamesAndTypes[i+2];
		if (Configuration::patternMatch(uName, wildcardedName)) {
			rule << keyword << " " << uName << " = " << type;
			return;
		}
	}

	//--------
	// We couldn's determine the type from the wildcarded_names_and_types 
	// table. So we fall back to using heuristics to guess a good type.
	//--------
	if (cfg->type("", name) == Configuration::CFG_SCOPE) {
		rule << uName << " = scope";
	} else if (cfg->type("", name) == Configuration::CFG_LIST) {
		rule << uName << " = list[string]";
	} else {
		str = cfg->lookupString("", name);
		if (cfg->isBoolean(str)) {
			rule << uName << " = boolean";
		} else if (cfg->isInt(str)) {
			rule << uName << " = int";
		} else if (cfg->isFloat(str)) {
			rule << uName << " = float";
		} else if (cfg->isDurationSeconds(str)) {
			rule << uName << " = durationSeconds";
		} else if (cfg->isDurationMilliseconds(str)) {
			rule << uName << " = durationMilliseconds";
		} else if (cfg->isDurationMicroseconds(str)) {
			rule << uName << " = durationMicroseconds";
		} else if (cfg->isMemorySizeBytes(str)) {
			rule << uName << " = memorySizeBytes";
		} else if (cfg->isMemorySizeKB(str)) {
			rule << uName << " = memorySizeKB";
		} else if (cfg->isMemorySizeMB(str)) {
			rule << uName << " = memorySizeMB";
		} else {
			rule << uName << " = string";
		}
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:60,代码来源:config2cpp-main.cpp

示例5: 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());
                }
            }
        }
    }
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:30,代码来源:MHSyncItemInfo.cpp

示例6: 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;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:27,代码来源:MHSyncItemInfo.cpp

示例7: testRemoveProperty

    void testRemoveProperty() {
        // Write a value into the property file
        propFile->setPropertyValue("property4", "value4");
        propFile->setPropertyValue("  space  ", "  val space ");
        propFile->close();
        // Remove it
        int success = propFile->removeProperty("property4");
        CPPUNIT_ASSERT(success == 0);
        // Now read back
        StringBuffer value = propFile->readPropertyValue("property4");
        CPPUNIT_ASSERT(value.empty());
        
        StringBuffer valueS = propFile->readPropertyValue("space");
        CPPUNIT_ASSERT(value.empty());

    }
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:16,代码来源:PropertyFileTest.cpp

示例8: url_encode_array

static void url_encode_array(StringBuffer &ret, CVarRef varr,
                             std::set<void*> &seen_arrs,
                             CStrRef num_prefix, CStrRef key_prefix,
                             CStrRef key_suffix, CStrRef arg_sep) {
  void *id = varr.is(KindOfArray) ?
    (void*)varr.getArrayData() : (void*)varr.getObjectData();
  if (!seen_arrs.insert(id).second) {
    return; // recursive
  }

  Array arr = varr.toArray();

  for (ArrayIter iter(arr); iter; ++iter) {
    Variant data = iter.second();
    if (data.isNull() || data.isResource()) continue;

    String key = iter.first();
    bool numeric = key.isNumeric();

    if (data.is(KindOfArray) || data.is(KindOfObject)) {
      String encoded;
      if (numeric) {
        encoded = key;
      } else {
        encoded = StringUtil::UrlEncode(key);
      }
      StringBuffer new_prefix(key_prefix.size() + num_prefix.size() +
                              encoded.size() + key_suffix.size() + 4);
      new_prefix += key_prefix;
      if (numeric) new_prefix += num_prefix;
      new_prefix += encoded;
      new_prefix += key_suffix;
      new_prefix += "%5B";
      url_encode_array(ret, data, seen_arrs, String(),
                       new_prefix.detach(), String("%5D", AttachLiteral),
                       arg_sep);
    } else {
      if (!ret.empty()) {
        ret += arg_sep;
      }
      ret += key_prefix;
      if (numeric) {
        ret += num_prefix;
        ret += key;
      } else {
        ret += StringUtil::UrlEncode(key);
      }
      ret += key_suffix;
      ret += "=";
      if (data.isInteger() || data.is(KindOfBoolean)) {
        ret += String(data.toInt64());
      } else if (data.is(KindOfDouble)) {
        ret += String(data.toDouble());
      } else {
        ret += StringUtil::UrlEncode(data.toString());
      }
    }
  }
}
开发者ID:kodypeterson,项目名称:hiphop-php,代码行数:59,代码来源:ext_url.cpp

示例9: flush

 void flush()
 {
   if(!m_buffer.empty())
   {
     m_tool.push_back(new VariableString(m_buffer.c_str()));
     m_buffer.clear();
   }
 }
开发者ID:raynorpat,项目名称:cake,代码行数:8,代码来源:build.cpp

示例10: append_line_no

static void append_line_no(StringBuffer &sb, const char *text,
                           int &line, const char *color, const char *end,
                           int lineFocus0, int charFocus0, int lineFocus1,
                           int charFocus1, const char **palette =
                           DebuggerClient::DefaultCodeColors) {
  TRACE(7, "debugger_base:append_line_no\n");
  const char *colorLineNo = palette[CodeColorLineNo * 2];
  const char *endLineNo = palette[CodeColorLineNo * 2 + 1];

  // beginning
  if (line && sb.empty()) {
    if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                   colorLineNo);
    sb.printf(DebuggerClient::LineNoFormat, line);
    if (endLineNo) sb.append(endLineNo);
  }

  // ending
  if (text == nullptr) {
    if (line) {
      if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                     colorLineNo);
      sb.append("(END)\n");
      if (endLineNo) sb.append(endLineNo);
    }
    return;
  }

  if (color) sb.append(color);

  if (line == 0) {
    sb.append(text);
  } else {
    const char *begin = text;
    const char *p = begin;
    for (; *p; p++) {
      if (*p == '\n') {
        ++line;
        sb.append(begin, p - begin);
        if (color) sb.append(ANSI_COLOR_END);
        sb.append('\n');
        if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                       colorLineNo);
        sb.printf(DebuggerClient::LineNoFormat, line);
        if (endLineNo) sb.append(endLineNo);
        if (color) sb.append(color);
        begin = p + 1;
      }
    }
    if (p - begin > 0) {
      sb.append(begin, p - begin);
    }
  }

  if (end) sb.append(end);
}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:56,代码来源:debugger_base.cpp

示例11: upload

int HttpUploader::upload(const StringBuffer& luid, InputStream* inputStream) 
{
    int status = 0;

    // safe checks
    if (!inputStream || !inputStream->getTotalSize()) {
        LOG.error("upload error: no data to transfer");
        return 1;
    }
    if (luid.empty() || syncUrl.empty()  || sourceURI.empty()) {
        LOG.error("upload error: some params are not set");
        return 2;
    }
    
    StringBuffer fullUrl = composeURL();
    URL url(fullUrl.c_str());
    HttpConnection* httpConnection = getHttpConnection();
   
    httpConnection->setCompression(false);
    status = httpConnection->open(url, HttpConnection::MethodPost);
    
    if (status) { 
        delete httpConnection;

        return status;
    }

    httpConnection->setKeepAlive(keepalive);
    httpConnection->setRequestChunkSize(maxRequestChunkSize);
   
    // Set headers (use basic auth)
    HttpAuthentication* auth = new BasicAuthentication(username, password);
    httpConnection->setAuthentication(auth);
    setRequestHeaders(luid, *httpConnection, *inputStream);
    
    // Send the HTTP request
    StringOutputStream response;
    status = httpConnection->request(*inputStream, response);
    LOG.debug("response returned = %s", response.getString().c_str());
    
    // Manage response headers
    if (useSessionID) {
        // Server returns the jsessionId in the Set-Cookie header, can be used for 
        // the subsequent calls of upload().
        StringBuffer hdr = httpConnection->getResponseHeader(HTTP_HEADER_SET_COOKIE);
        sessionID = httpConnection->parseJSessionId(hdr);
    }
    
    httpConnection->close();
    
    delete auth;
    delete httpConnection;
    return status;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:54,代码来源:HttpUploader.cpp

示例12: 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;
    }
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:52,代码来源:HttpConnection.cpp

示例13: getExportTimeForService

time_t MHSyncItemInfo::getExportTimeForService(const char* serviceName)
{
    time_t serviceExportTime = -1;
    
    if (serviceName) {
        StringBuffer exportTimeStr = exportedServices.get(serviceName);
        
        if (exportTimeStr.empty() == false) {
            serviceExportTime = atol(exportTimeStr.c_str());
        }
    }

    return serviceExportTime;
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:14,代码来源:MHSyncItemInfo.cpp

示例14: format

char* FolderData::format() {

    StringBuffer out;

    out.reserve(150);

    out = "<Folder>\n";
    if (name.length() > 0)
        out += XMLProcessor::makeElement(FOLDER_NAME, name);
    if (created.length() > 0)
        out += XMLProcessor::makeElement(FOLDER_CREATED, created);
    if (modified.length() > 0)
        out += XMLProcessor::makeElement(FOLDER_MODIFIED, modified);
    if (accessed.length() > 0)
        out += XMLProcessor::makeElement(FOLDER_ACCESSED, accessed);

    StringBuffer attributes;

    if (isHiddenPresent)
        attributes += XMLProcessor::makeElement(FOLDER_HIDDEN, hidden);
    if (isSystemPresent)
        attributes += XMLProcessor::makeElement(FOLDER_SYSTEM, system);
    if (isArchivedPresent)
        attributes += XMLProcessor::makeElement(FOLDER_ARCHIVED, archived);
    if (isDeletedPresent)
        attributes += XMLProcessor::makeElement(FOLDER_DELETE, deleted);
    if (isWritablePresent)
        attributes += XMLProcessor::makeElement(FOLDER_WRITABLE, writable);
    if (isReadablePresent)
        attributes += XMLProcessor::makeElement(FOLDER_READABLE, readable);
    if (isExecutablePresent)
        attributes += XMLProcessor::makeElement(FOLDER_EXECUTABLE, executable);

    if (!attributes.empty())
        out += XMLProcessor::makeElement(FOLDER_ATTRIBUTES, attributes);

    if (role.length() > 0)
        out += XMLProcessor::makeElement(FOLDER_ROLE, role);

    if (!(extended.isEmpty())){
        for(int i=0; i < extended.size(); i++){
            const char* temp =  ((FolderExt*)extended.get(i))->format();
            out += temp;
            delete [] temp;
        }
    }

    out += "</Folder>\n";
    return stringdup(out.c_str());
}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:50,代码来源:FolderData.cpp

示例15: append_line_no

static void append_line_no(StringBuffer &sb, const char *text,
                           int &line, const char *color, const char *end,
                           const char **palette =
                           DebuggerClient::DefaultCodeColors) {
  const char *colorLineNo = palette[CodeColorLineNo * 2];
  const char *endLineNo = palette[CodeColorLineNo * 2 + 1];

  // beginning
  if (line && sb.empty()) {
    if (colorLineNo) sb.append(colorLineNo);
    sb.printf(DebuggerClient::LineNoFormat, line);
    if (endLineNo) sb.append(endLineNo);
  }

  // ending
  if (text == NULL) {
    if (line) {
      if (colorLineNo) sb.append(colorLineNo);
      sb.append("(END)\n");
      if (endLineNo) sb.append(endLineNo);
    }
    return;
  }

  if (color) sb.append(color);

  if (line == 0) {
    sb.append(text);
  } else {
    const char *begin = text;
    const char *p = begin;
    for (; *p; p++) {
      if (*p == '\n') {
        sb.append(begin, p - begin);
        if (end) sb.append(end);
        sb.append('\n');
        if (colorLineNo) sb.append(colorLineNo);
        sb.printf(DebuggerClient::LineNoFormat, ++line);
        if (endLineNo) sb.append(endLineNo);
        if (color) sb.append(color);
        begin = p + 1;
      }
    }
    if (p - begin > 0) {
      sb.append(begin, p - begin);
    }
  }

  if (end) sb.append(end);
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:50,代码来源:debugger_base.cpp


注:本文中的StringBuffer::empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。