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


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

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


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

示例1: memcpy

void DS::Stream::writeSafeString(const String& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        StringBuffer<chr16_t> buffer = value.toUtf16();
        uint16_t length = value.length() & 0x0FFF;
        chr16_t* data = new chr16_t[length];
        memcpy(data, buffer.data(), length * sizeof(chr16_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(chr16_t));
        write<chr16_t>(0);
        delete[] data;
    } else {
        StringBuffer<chr8_t> buffer = (format == e_StringUTF8) ? value.toUtf8()
                                                               : value.toRaw();
        uint16_t length = value.length() & 0x0FFF;
        chr8_t* data = new chr8_t[length];
        memcpy(data, buffer.data(), length * sizeof(chr8_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(chr8_t));
        delete[] data;
    }
}
开发者ID:Deledrius,项目名称:dirtsand,代码行数:26,代码来源:streams.cpp

示例2: writeBytes

void DS::Stream::writeString(const String& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        StringBuffer<chr16_t> buffer = value.toUtf16();
        writeBytes(buffer.data(), buffer.length());
    } else {
        StringBuffer<chr8_t> buffer = (format == e_StringUTF8) ? value.toUtf8()
                                                               : value.toRaw();
        writeBytes(buffer.data(), buffer.length());
    }
}
开发者ID:Deledrius,项目名称:dirtsand,代码行数:11,代码来源:streams.cpp

示例3: BuggyHashPassword

DS::ShaHash DS::BuggyHashPassword(const String& username, const String& password)
{
    StringBuffer<chr16_t> wuser = username.toUtf16();
    StringBuffer<chr16_t> wpass = password.toUtf16();
    chr16_t* buffer = new chr16_t[wuser.length() + wpass.length()];
    memcpy(buffer, wpass.data(), wpass.length() * sizeof(chr16_t));
    memcpy(buffer + wpass.length(), wuser.data(), wuser.length() * sizeof(chr16_t));
    buffer[wpass.length() - 1] = 0;
    buffer[wpass.length() + wuser.length() - 1] = 0;
    ShaHash hash = ShaHash::Sha0(buffer, (wuser.length() + wpass.length()) * sizeof(chr16_t));
    delete[] buffer;
    return hash;
}
开发者ID:Hoikas,项目名称:dirtsand,代码行数:13,代码来源:CryptIO.cpp

示例4:

void serial_helper_func<A,String>::g(SerializerWriter &ar,type &val)
{
	const char *p;
	intarr_t n;

	if(ar.flags.get(Serializer::STRCVT_UTF8))
	{
		StringBuffer<char> sb;
		if(!IConv::ansi_to_utf8(sb,val.c_str(),val.size()))
		{
			ar.errstr("invalid string");
			return;
		}
		p=sb.data();
		n=(intarr_t)sb.size();
	}
	else
	{
		p=val.c_str();
		n=(intarr_t)val.size();
	}

	serial_pod<A,intarr_t>::g(ar,n);
	if(n>0)
	{
		ar.send((char *)p,n);
	}

}
开发者ID:xiongqiangcs,项目名称:vhwd_base,代码行数:29,代码来源:serializer.cpp

示例5: _do_assign

inline void String::_do_assign(const wchar_t* p1,uintptr_t n)
{
	StringBuffer<char> sb;
	IConv::unicode_to_utf8(sb,p1,n);

	_do_assign(sb.data(),sb.size());
}
开发者ID:xuanya4202,项目名称:ew_base,代码行数:7,代码来源:string.cpp

示例6: FormatUserAltitude

gcc_const
static inline StringBuffer<TCHAR, 32>
FormatUserAltitude(double value)
{
  StringBuffer<TCHAR, 32> buffer;
  FormatUserAltitude(value, buffer.data());
  return buffer;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:UserUnits.hpp

示例7: FormatUserTaskSpeed

gcc_const
static inline StringBuffer<TCHAR, 32>
FormatUserTaskSpeed(double value, bool precision=true)
{
  StringBuffer<TCHAR, 32> buffer;
  FormatUserTaskSpeed(value, buffer.data(), true, precision);
  return buffer;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:UserUnits.hpp

示例8: FormatUserDistanceSmart

gcc_const
static inline StringBuffer<TCHAR, 32>
FormatUserDistanceSmart(double value)
{
  StringBuffer<TCHAR, 32> buffer;
  FormatUserDistanceSmart(value, buffer.data());
  return buffer;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:UserUnits.hpp

示例9: FormatLocalTimeHHMM

gcc_const
static inline StringBuffer<TCHAR, 8>
FormatLocalTimeHHMM(int time, RoughTimeDelta utc_offset)
{
  StringBuffer<TCHAR, 8> buffer;
  FormatLocalTimeHHMM(buffer.data(), time, utc_offset);
  return buffer;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:LocalTimeFormatter.hpp

示例10: FormatAngleDelta

gcc_const
static inline StringBuffer<TCHAR, 16>
FormatAngleDelta(Angle value)
{
  StringBuffer<TCHAR, 16> buffer;
  FormatAngleDelta(buffer.data(), buffer.capacity(), value);
  return buffer;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:AngleFormatter.hpp

示例11: FormatBearing

gcc_const
static inline StringBuffer<TCHAR, 16>
FormatBearing(unsigned degrees_value)
{
  StringBuffer<TCHAR, 16> buffer;
  FormatBearing(buffer.data(), buffer.capacity(), degrees_value);
  return buffer;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:8,代码来源:AngleFormatter.hpp

示例12: FormatSignedTimeHHMM

gcc_const
static inline StringBuffer<TCHAR, 8>
FormatSignedTimeHHMM(int time)
{
  StringBuffer<TCHAR, 8> buffer;
  FormatSignedTimeHHMM(buffer.data(), time);
  return buffer;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:8,代码来源:TimeFormatter.hpp

示例13: ProxyRequest

bool HttpProtocol::ProxyRequest(Transport *transport, bool force,
                                const std::string &url,
                                int &code, std::string &error,
                                StringBuffer &response,
                                HeaderMap *extraHeaders /* = NULL */) {
  assert(transport);
  if (transport->headersSent()) {
    raise_warning("Cannot proxy request - headers already sent");
    return false;
  }

  HeaderMap requestHeaders;
  transport->getHeaders(requestHeaders);
  if (extraHeaders) {
    for (HeaderMap::const_iterator iter = extraHeaders->begin();
         iter != extraHeaders->end(); ++iter) {
      std::vector<std::string> &values = requestHeaders[iter->first];
      values.insert(values.end(), iter->second.begin(), iter->second.end());
    }
  }

  int size = 0;
  const char *data = nullptr;
  if (transport->getMethod() == Transport::Method::POST) {
    data = (const char *)transport->getPostData(size);
  }

  std::vector<String> responseHeaders;
  HttpClient http;
  code = http.request(transport->getMethodName(),
                      url.c_str(), data, size, response, &requestHeaders,
                      &responseHeaders);

  if (code == 0) {
    if (!force) return false; // so we can retry
    Logger::Error("Unable to proxy %s: %s", url.c_str(),
                  http.getLastError().c_str());
    error = http.getLastError();
    return true;
  }

  for (unsigned int i = 0; i < responseHeaders.size(); i++) {
    String &header = responseHeaders[i];
    if (header.find(":") != String::npos &&
        header.find("Content-Length: ") != 0 &&
        header.find("Client-Transfer-Encoding: ") != 0 &&
        header.find("Transfer-Encoding: ") != 0 &&
        header.find("Connection: ") != 0) {
      transport->addHeader(header.data());
    }
  }
  const char* respData = response.data();
  if (!respData) {
    respData = "";
  }
  Logger::Verbose("Response code was %d when proxying %s", code, url.c_str());
  return true;
}
开发者ID:Dream-Seeker,项目名称:hhvm,代码行数:58,代码来源:http-protocol.cpp

示例14: TextEntryDialog

static inline bool
TextEntryDialog(StringBuffer<TCHAR, N> &text,
                const TCHAR *caption,
                bool default_shift_state)
{
  AllowedCharacters accb=AllowedCharacters();
  return TextEntryDialog(text.data(), text.capacity(),
                         caption, accb, default_shift_state);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:9,代码来源:TextEntry.hpp

示例15: FormatTimespanSmart

gcc_const
static inline StringBuffer<TCHAR, 64>
FormatTimespanSmart(int timespan, unsigned max_tokens = 1,
                    const TCHAR *separator = _T(" "))
{
  StringBuffer<TCHAR, 64> buffer;
  FormatTimespanSmart(buffer.data(), timespan, max_tokens, separator);
  return buffer;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:9,代码来源:TimeFormatter.hpp


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