当前位置: 首页>>代码示例>>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;未经允许,请勿转载。