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


C++ Bytes函数代码示例

本文整理汇总了C++中Bytes函数的典型用法代码示例。如果您正苦于以下问题:C++ Bytes函数的具体用法?C++ Bytes怎么用?C++ Bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Bytes

// ---------------------------------------------------------
// CDownloadDataClient::MarshalDataL()
// ---------------------------------------------------------
//
HBufC8* CDownloadDataClient::MarshalDataL() const
    {
    TInt bufLen = Bytes();      // Size of class including iMediaArray elements.
                                //  Note that this includes actual bytes occupied by
                                //  contents of descriptors and pointers.
                                
    bufLen += sizeof(TInt);  // We include the count of elements in iMediaArray
                                //  while externalizing.
                                
    bufLen += sizeof(TInt) * iMediaArray.Count();
                                // iMediaArray has an array iTypes. We are including
                                //  count of elements in iTypes array while externalizing
                                //  each element of iMediaArray.
    
    // Dynamic data buffer
    CBufFlat* buf = CBufFlat::NewL(bufLen);
    CleanupStack::PushL(buf);
    // Stream over the buffer
    RBufWriteStream stream(*buf);
    CleanupClosePushL(stream);
    
    ExternalizeL(stream);
    CleanupStack::PopAndDestroy(); //stream
    
    // Create a heap descriptor from the buffer
    HBufC8* des = HBufC8::NewL(buf->Size());
    TPtr8 ptr(des->Des());
    buf->Read(0, ptr, buf->Size());
    CleanupStack::PopAndDestroy(); //buf
    
    return des;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:36,代码来源:DownloadDataClient.cpp

示例2: proc_ndel

int proc_ndel(NetworkServer *net, Link *link, const Request &req, Response *resp){
	SSDBServer *serv = (SSDBServer *)net->data;
	CHECK_NUM_PARAMS(3);

	Locking l(&serv->expiration->mutex);
	int ret = serv->ssdb->ndel(req[1], req[2]);
	if(ret == -1){
		resp->push_back("error");
	}else{
		std::string buf;
		buf.append(1, DataType::NSET);
		buf.append(1, (uint8_t)req[1].size());
		buf.append(req[1].data(), req[1].size());

		int64_t s = req[2].Int64();
		if(s < 0){
			buf.append(1, '-');
		}else{
			buf.append(1, '=');
		}
		s = encode_score(s);

		buf.append((char *)&s, sizeof(int64_t));

		serv->expiration->del_ttl(Bytes(buf));

		resp->push_back("ok");
		resp->push_back("1");
	}
	return 0;
}
开发者ID:weizetao,项目名称:ssdb,代码行数:31,代码来源:proc_nset.cpp

示例3: du

  Try<Bytes> du(std::string path)
  {
    // Make sure 'path' starts with a '/'.
    path = path::join("", path);

    Try<std::string> command = strings::format(
        "%s fs -du -h '%s'", hadoop, path);

    CHECK_SOME(command);

    std::ostringstream output;

    Try<int> status = os::shell(&output, command.get() + " 2>&1");

    if (status.isError()) {
      return Error("HDFS du failed: " + status.error());
    }

    const std::vector<std::string>& s = strings::split(output.str(), " ");
    if (s.size() != 2) {
      return Error("HDFS du returned an unexpected number of results: '" +
                   output.str() + "'");
    }

    Result<size_t> size = numify<size_t>(s[0]);
    if (size.isError()) {
      return Error("HDFS du returned unexpected format: " + size.error());
    } else if (size.isNone()) {
      return Error("HDFS du returned unexpected format");
    }

    return Bytes(size.get());
  }
开发者ID:flixster,项目名称:mesos,代码行数:33,代码来源:hdfs.hpp

示例4: strtolower

const std::vector<Bytes>* RedisLink::recv_req(Buffer *input){
	int ret = this->parse_req(input);
	if(ret == -1){
		return NULL;
	}
	if(recv_bytes.empty()){
		return &recv_bytes;
	}

	cmd = recv_bytes[0].String();
	strtolower(&cmd);
	
	recv_string.clear();
	
	this->convert_req();

	// Bytes don't hold memory, so we firstly copy Bytes into string and store
	// in a vector of string, then create Bytes-es prointing to strings
	recv_bytes.clear();
	for(int i=0; i<recv_string.size(); i++){
		std::string *str = &recv_string[i];
		recv_bytes.push_back(Bytes(str->data(), str->size()));
	}
	
	return &recv_bytes;
}
开发者ID:hsg4ok,项目名称:ssdb,代码行数:26,代码来源:link_redis.cpp

示例5: HQWrappedPictureIO

std::ostream& HQWrappedPictureIO(std::ostream& stream, const WrappedPicture& d) {
  std::ostringstream ss;
  ss.copyfmt(stream);

  // Picture Header
  ss << Bytes(4, d.picture_number);

  // Transform Params
  ss << vlc::unbounded
     << UnsignedVLC(d.wavelet_kernel)
     << UnsignedVLC(d.depth)
     << UnsignedVLC(d.slices_x)
     << UnsignedVLC(d.slices_y)
     << UnsignedVLC(d.slice_prefix)
     << UnsignedVLC(d.slice_size_scalar)
     << Boolean(false)
     << vlc::align;

  // Transform Data
  ss << d.slices;

  stream << ParseInfoIO(HQ_PICTURE, ss.str().size());

  return (stream << ss.str());
}
开发者ID:tp-m,项目名称:vc2-reference,代码行数:25,代码来源:DataUnit.cpp

示例6: time_ms

int ExpirationHandler::set_ttl(const Bytes &key, int64_t ttl){
	int64_t expired = time_ms() + ttl * 1000;
	char data[30];
	int size = snprintf(data, sizeof(data), "%" PRId64, expired);
	if(size <= 0){
		log_error("snprintf return error!");
		return -1;
	}

	int ret = ssdb->zset(this->list_name, key, Bytes(data, size));
	if(ret == -1){
		return -1;
	}

	if(!this->enable){
	    return 0;
	}

	if(expired < first_timeout){
		first_timeout = expired;
	}
	std::string s_key = key.String();
	fast_keys.del(s_key);
	if(expired <= fast_keys.max_score()){
		fast_keys.add(s_key, expired);
		if(fast_keys.size() > BATCH_SIZE){
			log_debug("pop_back");
			fast_keys.pop_back();
		}
	}else{
		//log_debug("don't put in fast_keys");
	}
	
	return 0;
}
开发者ID:sunxiaojun2014,项目名称:qssdb,代码行数:35,代码来源:ttl.cpp

示例7: DwTrace

void DwTrace(void) { // Execute one instruction
  DwSetRegs(28, R+28, 4);       // Restore cached registers
  DwSetPC(PC/2);             // Trace start address
  DwSend(Bytes(0x60, 0x31)); // Single step
  DwSync();
  DwReconnect();
}
开发者ID:dcwbrown,项目名称:dwire-debug,代码行数:7,代码来源:DwPort.c

示例8: size

// Returns the size in Bytes of a given file system entry. When
// applied to a symbolic link with `follow` set to
// `DO_NOT_FOLLOW_SYMLINK`, this will return the length of the entry
// name (strlen).
inline Try<Bytes> size(
    const std::string& path,
    const FollowSymlink follow = FOLLOW_SYMLINK)
{
  struct stat s;

  switch (follow) {
    case DO_NOT_FOLLOW_SYMLINK: {
      if (::lstat(path.c_str(), &s) < 0) {
        return ErrnoError("Error invoking lstat for '" + path + "'");
      }
      break;
    }
    case FOLLOW_SYMLINK: {
      if (::stat(path.c_str(), &s) < 0) {
        return ErrnoError("Error invoking stat for '" + path + "'");
      }
      break;
    }
    default: {
      UNREACHABLE();
    }
  }

  return Bytes(s.st_size);
}
开发者ID:fin09pcap,项目名称:mesos,代码行数:30,代码来源:stat.hpp

示例9: TEST

TEST(BytesTest, Stringify)
{
  EXPECT_NE(Megabytes(1023), Gigabytes(1));

  EXPECT_EQ("0B", stringify(Bytes()));

  EXPECT_EQ("1KB", stringify(Kilobytes(1)));
  EXPECT_EQ("1MB", stringify(Megabytes(1)));
  EXPECT_EQ("1GB", stringify(Gigabytes(1)));
  EXPECT_EQ("1TB", stringify(Terabytes(1)));

  EXPECT_EQ("1023B", stringify(Bytes(1023)));
  EXPECT_EQ("1023KB", stringify(Kilobytes(1023)));
  EXPECT_EQ("1023MB", stringify(Megabytes(1023)));
  EXPECT_EQ("1023GB", stringify(Gigabytes(1023)));
}
开发者ID:vanloswang,项目名称:mesos,代码行数:16,代码来源:bytes_tests.cpp

示例10: lime_audio_load

	value lime_audio_load (value data) {
		
		AudioBuffer audioBuffer;
		Resource resource;
		Bytes bytes;
		
		if (val_is_string (data)) {
			
			resource = Resource (val_string (data));
			
		} else {
			
			bytes = Bytes ();
			bytes.Set (data);
			resource = Resource (&bytes);
			
		}
		
		if (WAV::Decode (&resource, &audioBuffer)) {
			
			return audioBuffer.Value ();
			
		}
		
		#ifdef LIME_OGG
		if (OGG::Decode (&resource, &audioBuffer)) {
			
			return audioBuffer.Value ();
			
		}
		#endif
		
		return alloc_null ();
		
	}
开发者ID:Rezmason,项目名称:lime,代码行数:35,代码来源:ExternalInterface.cpp

示例11: DwGo

void DwGo(void) { // Begin executing.
  DwSetRegs(28, R+28, 4);  // Restore cached registers
  DwSetPC(PC/2);        // Execution start address
  if (BP < 0) {         // Prepare to start execution with no breakpoint set
    DwSend(Bytes(TimerEnable ? 0x40 : 0x60)); // Set execution context
  } else {              // Prpare to start execution with breakpoint set
    DwSetBP(BP/2);      // Breakpoint address
    DwSend(Bytes(TimerEnable ? 0x41 : 0x61)); // Set execution context including breakpoint enable
  }
  DwSend(Bytes(0x30)); // Continue execution (go)
  DwWait();

  // Note: We return to UI with the target processor running. The UI go command handles
  // getting control back, either on the debice hitting the hardware breakpoint, or
  // on the user pressing return to trigger a break.
}
开发者ID:dcwbrown,项目名称:dwire-debug,代码行数:16,代码来源:DwPort.c

示例12: OnFull

 // Returns the first string in the list.  Note that the very first string is
 // always discarded.
 Bytes OnFull(Bytes const bytes,
              not_null<std::list<std::string>*> const strings) {
   strings->push_back(
       std::string(reinterpret_cast<const char*>(&bytes.data[0]),
                   static_cast<size_t>(bytes.size)));
   return Bytes(data_, kSmallChunkSize);
 }
开发者ID:Wavechaser,项目名称:Principia,代码行数:9,代码来源:pull_serializer_test.cpp

示例13: GetDeviceType

int GetDeviceType(void) {
  DwSend(Bytes(0xF3));  // Request signature
  int signature = DwReadWord();
  int i=0; while (    Characteristics[i].signature
                  &&  Characteristics[i].signature != signature) {i++;}
  return Characteristics[i].signature ? i : -1;
}
开发者ID:dcwbrown,项目名称:dwire-debug,代码行数:7,代码来源:DwPort.c

示例14: write

Bytes write(const data::Value &data, EncodeFormat fmt) {
	if (fmt.isRaw()) {
		switch (fmt.format) {
		case EncodeFormat::Json: {
			String s = writeJson(data, false);
			Bytes ret; ret.reserve(s.length());
			ret.assign(s.begin(), s.end());
			return ret;
		}
			break;
		case EncodeFormat::Pretty: {
			String s = writeJson(data, true);
			Bytes ret; ret.reserve(s.length());
			ret.assign(s.begin(), s.end());
			return ret;
		}
			break;
		case EncodeFormat::Cbor:
		case EncodeFormat::DefaultFormat:
			return writeCbor(data);
			break;
		}
	}
	return Bytes();
}
开发者ID:SBKarr,项目名称:stappler,代码行数:25,代码来源:SPData.cpp

示例15: openFile

Bytes Info::openFile(const String &file) const {
	auto containerIt = _manifest.find(file);
	if (containerIt != _manifest.end()) {
		return openFile(containerIt->second);
	}
	return Bytes();
}
开发者ID:SBKarr,项目名称:stappler,代码行数:7,代码来源:SPEpubInfo.cpp


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