當前位置: 首頁>>代碼示例>>C++>>正文


C++ Byte函數代碼示例

本文整理匯總了C++中Byte函數的典型用法代碼示例。如果您正苦於以下問題:C++ Byte函數的具體用法?C++ Byte怎麽用?C++ Byte使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Byte函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: setGlyphPixel

void Font::setGlyphPixel(char key, int x, int y, bool value)
{
    int offset = glyphOffsets_[Byte(key)];
    int width = glyphWidths_[Byte(key)];
    int index = offset + y * width + x;
    glyphData_[index] = value;
}
開發者ID:elemel,項目名稱:crust,代碼行數:7,代碼來源:font.cpp

示例2: lwt_unix_read

CAMLprim value lwt_unix_read(value fd, value buf, value vofs, value vlen)
{
  intnat ofs, len, written;
  DWORD numbytes, numwritten;
  DWORD err = 0;

  Begin_root (buf);
    ofs = Long_val(vofs);
    len = Long_val(vlen);
    written = 0;
    if (len > 0) {
      numbytes = len;
      if (Descr_kind_val(fd) == KIND_SOCKET) {
        int ret;
        SOCKET s = Socket_val(fd);
        ret = recv(s, &Byte(buf, ofs), numbytes, 0);
        if (ret == SOCKET_ERROR) err = WSAGetLastError();
        numwritten = ret;
      } else {
        HANDLE h = Handle_val(fd);
        if (! ReadFile(h, &Byte(buf, ofs), numbytes, &numwritten, NULL))
          err = GetLastError();
      }
      if (err) {
        win32_maperr(err);
        uerror("write", Nothing);
      }
      written = numwritten;
    }
  End_roots();
  return Val_long(written);
}
開發者ID:Drup,項目名稱:lwt,代碼行數:32,代碼來源:lwt_unix_windows.c

示例3: caml_ml_input

CAMLprim value caml_ml_input(value vchannel, value buff, value vstart,
                             value vlength)
{
  CAMLparam4 (vchannel, buff, vstart, vlength);
  struct channel * channel = Channel(vchannel);
  intnat start, len;
  int n, avail, nread;

  Lock(channel);
  /* We cannot call caml_getblock here because buff may move during
     caml_do_read */
  start = Long_val(vstart);
  len = Long_val(vlength);
  n = len >= INT_MAX ? INT_MAX : (int) len;
  avail = channel->max - channel->curr;
  if (n <= avail) {
    memmove(&Byte(buff, start), channel->curr, n);
    channel->curr += n;
  } else if (avail > 0) {
    memmove(&Byte(buff, start), channel->curr, avail);
    channel->curr += avail;
    n = avail;
  } else {
    nread = caml_do_read(channel->fd, channel->buff,
                         channel->end - channel->buff);
    channel->offset += nread;
    channel->max = channel->buff + nread;
    if (n > nread) n = nread;
    memmove(&Byte(buff, start), channel->buff, n);
    channel->curr = channel->buff + n;
  }
  Unlock(channel);
  CAMLreturn (Val_long(n));
}
開發者ID:OCamlPro,項目名稱:OCamlPro-OCaml-Branch,代碼行數:34,代碼來源:io.c

示例4: caml_string_length_based_compare

CAMLprim value caml_string_length_based_compare(value s1, value s2)
{
  mlsize_t len1, len2;
  mlsize_t temp;
  int res;
  if (s1 == s2) return Val_int(0);
  
  len1 = Wosize_val(s1);
  temp = Bsize_wsize(len1) - 1 ;
  len1 = temp - Byte(s1,temp);

  len2 = Wosize_val(s2);
  temp = Bsize_wsize(len2) - 1 ; 
  len2 = temp - Byte(s2,temp);

  if (len1 != len2) 
  { 
    if (len1 < len2 ) {
      return Val_long_clang(-1);
    } else {
      return Val_long_clang(1);
    }
  }
  else {
    
    res = memcmp(String_val(s1), String_val(s2), len1);
    if(res < 0) return Val_long_clang(-1); 
    if(res > 0) return Val_long_clang(1);
    return Val_long_clang(0);
    
  }
}
開發者ID:chenglou,項目名稱:bucklescript,代碼行數:32,代碼來源:ext_basic_hash_stubs.c

示例5: getGlyphPixel

bool Font::getGlyphPixel(char key, int x, int y)
{
    int offset = glyphOffsets_[Byte(key)];
    int width = glyphWidths_[Byte(key)];
    int index = offset + y * width + x;
    return glyphData_[index];
}
開發者ID:elemel,項目名稱:crust,代碼行數:7,代碼來源:font.cpp

示例6: caml_ml_string_length

CAMLprim value caml_ml_string_length(value s)
{
  mlsize_t temp;
  temp = Bosize_val(s) - 1;
  Assert (Byte (s, temp - Byte (s, temp)) == 0);
  return Val_long(temp - Byte (s, temp));
}
開發者ID:avsm,項目名稱:ocaml-community,代碼行數:7,代碼來源:str.c

示例7: caml_string_length

CAMLexport mlsize_t caml_string_length(value s)
{
  mlsize_t temp;
  temp = Bosize_val(s) - 1;
  Assert (Byte (s, temp - Byte (s, temp)) == 0);
  return temp - Byte (s, temp);
}
開發者ID:avsm,項目名稱:ocaml-community,代碼行數:7,代碼來源:str.c

示例8: camlzip_bzDecompress

value camlzip_bzDecompress(value vzs, value srcbuf, value srcpos, value srclen,
			   value dstbuf, value dstpos, value dstlen)
{
#ifdef USE_BZIP2
  bz_stream * zs = BZStream_val(vzs);
  int retcode;
  long used_in, used_out;
  value res;

  zs->next_in = &Byte(srcbuf, Long_val(srcpos));
  zs->avail_in = Long_val(srclen);
  zs->next_out = &Byte(dstbuf, Long_val(dstpos));
  zs->avail_out = Long_val(dstlen);
  retcode = BZ2_bzDecompress(zs);
  if (retcode < 0)
    camlzip_bzerror("Bzlib.decompress", retcode);
  used_in = Long_val(srclen) - zs->avail_in;
  used_out = Long_val(dstlen) - zs->avail_out;
  zs->next_in = NULL;           /* not required, but cleaner */
  zs->next_out = NULL;          /* (avoid dangling pointers into Caml heap) */
  res = alloc_small(3, 0);
  Field(res, 0) = Val_bool(retcode == BZ_STREAM_END);
  Field(res, 1) = Val_int(used_in);
  Field(res, 2) = Val_int(used_out);
  return res;
#else
  failwith("Bzip2 compression not supported");
#endif
}
開發者ID:ygrek,項目名稱:mldonkey,代碼行數:29,代碼來源:zlibstubs.c

示例9: caml_des_transform

CAMLprim value caml_des_transform(value ckey, value src, value src_ofs,
                                  value dst, value dst_ofs)
{
  d3des_transform((u32 *) String_val(ckey),
                  (u8 *) &Byte(src, Long_val(src_ofs)),
                  (u8 *) &Byte(dst, Long_val(dst_ofs)));
  return Val_unit;
}
開發者ID:aryx,項目名稱:fork-ocsigen,代碼行數:8,代碼來源:stubs-des.c

示例10: caml_aes_decrypt

CAMLprim value caml_aes_decrypt(value ckey, value src, value src_ofs,
                                value dst, value dst_ofs)
{
  rijndaelDecrypt((const u32 *) String_val(ckey),
                  Byte(ckey, Cooked_key_NR_offset),
                  (const u8 *) &Byte(src, Long_val(src_ofs)),
                  (u8 *) &Byte(dst, Long_val(dst_ofs)));
  return Val_unit;
}
開發者ID:Janardhanan,項目名稱:melange,代碼行數:9,代碼來源:stubs-aes.c

示例11: concat_strings

static value concat_strings(const char *s1, const char *s2)
{
  int l1 = strlen(s1) ;
  int l2 = strlen(s2) ;
  value res = alloc_string(l1+l2+2);
  memcpy(String_val(res), s1, l1) ;
  Byte(res, l1)   = ':' ;
  Byte(res, l1+1) = ' ' ;
  memcpy(String_val(res)+l1+2, s2, l2) ;
  return res ;
}
開發者ID:amnh,項目名稱:poy5,代碼行數:11,代碼來源:c_gz.c

示例12: largeint_set_str

value largeint_set_str(value dest, value str, value base)	
{ 
  long changesign = (Byte(str, 0) == '~');
  long res;
  if (changesign) { Byte(str, 0) = '-'; }
  res = mpz_set_str(Large_val(dest), String_val(str), Long_val(base));
  if (changesign) { Byte(str, 0) = '~'; }
  if (0 == res)
    { return Val_unit; }
  else
    { failwith("Ill-formed number string"); }
}
開發者ID:Munksgaard,項目名稱:mosml,代碼行數:12,代碼來源:intinf.c

示例13: largeint_get_str

value largeint_get_str(value src, value base)		
{ 
  long len = 3 + mpz_sizeinbase(Large_val(src), Long_val(base));
  char *buffer = (char*)(malloc(len));
  value res;
  mpz_get_str(buffer, Long_val(base), Large_val(src));  
  res = copy_string(buffer);
  free(buffer);

  /* Use the SML sign character: */
  if (Byte(res, 0) == '-')
    { Byte(res, 0) = '~'; }
  
  return res;
}
開發者ID:Munksgaard,項目名稱:mosml,代碼行數:15,代碼來源:intinf.c

示例14: string_mlval

value string_mlval(value val)
{
  value s;
  byteoffset_t res;

  extern_size = INITIAL_EXTERN_SIZE;
  extern_block =
    (byteoffset_t *) stat_alloc(extern_size * sizeof(unsigned long));
  extern_pos = 0;
  extern_table_size = INITIAL_EXTERN_TABLE_SIZE;
  alloc_extern_table();
  extern_table_used = 0;
  res = emit_all(val);
  stat_free((char *) extern_table);

  /* We can allocate a string in the heap since the argument value is
     not used from now on. */
  if (extern_pos == 0)
    {
      s = alloc_string(8);
      ((size_t *)s)[0] = (size_t)extern_pos;
      ((size_t *)s)[1] = (size_t)res;
    }
  else
    {
      s = alloc_string(4 + extern_pos * sizeof(unsigned long));
      ((size_t *)s)[0] = (size_t)extern_pos;
      memmove(&Byte(s, 4), (char *)extern_block, extern_pos * sizeof(unsigned long));
    }
  stat_free((char *) extern_block);
  return s;
}
開發者ID:alepharchives,項目名稱:exsml,代碼行數:32,代碼來源:mosml.c

示例15: unix_write

CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
{
  long ofs, len, written;
  int numbytes, ret;
  char iobuf[UNIX_BUFFER_SIZE];

  Begin_root (buf);
    ofs = Long_val(vofs);
    len = Long_val(vlen);
    written = 0;
    while (len > 0) {
      numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len;
      memmove (iobuf, &Byte(buf, ofs), numbytes);
      enter_blocking_section();
      ret = write(Int_val(fd), iobuf, numbytes);
      leave_blocking_section();
      if (ret == -1) {
        if ((errno == EAGAIN || errno == EWOULDBLOCK) && written > 0) break;
        uerror("write", Nothing);
      }
      written += ret;
      ofs += ret;
      len -= ret;
    }
  End_roots();
  return Val_long(written);
}
開發者ID:BrianMulhall,項目名稱:ocaml,代碼行數:27,代碼來源:write.c


注:本文中的Byte函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。