• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setstate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: nurand

int
nurand (int A, int x, int y, int C, char *estado1, char *estado2)
{
/* ------------------------------------------------------- *\
|* Función que genera un número aleatório con distribución *|
|* no uniforme, según el método definifido en la cláusula  *|
|* 2.1.6 del TPC-C.                                        *|
|* ------------------------------------------------------- *|
|* Parámetro A: entero que determina el intervalo [0, A]   *|
|* para determinar un núero aleatório necesário la         *|
|* generación del núemro buscado.                          *|
|* Parámetro x: inicio del itervalo de selección.          *|
|* Parámetro y: fin del itervalo de selección.             *|
|* Parámetro C: constante seleccionada para cada atributo. *|
|* Parámetro estado1: estado para la generación de un      *|
|* número aleatorio seleccionado entre x e y               *|
|* Parámetro estado2: estado para la generación de un      *|
|* número aleatorio seleccionado 0 y A                     *|
|* ------------------------------------------------------- *|
|* Retorna el número generado.                             *|
\* ------------------------------------------------------- */

  int lon1, lon2;


  setstate (estado1);
  lon1 = aleat_int (x, y);
  setstate (estado2);
  lon2 = aleat_int (0, A);

  /*Se obtienen el número según la cláusula 2.1.6 */
  return (((lon2 | lon1) + C) % (y - x + 1)) + x;
};
开发者ID:joaobertacchi,项目名称:tpccuva-dist,代码行数:33,代码来源:extra.c


示例2: ioctl_command_play

/* play CD audio */
static int ioctl_command_play (int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc)
{
	struct dev_info_ioctl *ciw = unitisopen (unitnum);
	if (!ciw)
		return 0;

	ciw->cdda_play_finished = 0;
	ciw->cdda_subfunc = subfunc;
	ciw->cdda_statusfunc = statusfunc;
	ciw->cdda_scan = scan > 0 ? 10 : (scan < 0 ? 10 : 0);
	ciw->cdda_delay = setstate (ciw, -1);
	ciw->cdda_delay_frames = setstate (ciw, -2);
	setstate (ciw, AUDIO_STATUS_NOT_SUPPORTED);

	if (!open_createfile (ciw, 0)) {
		setstate (ciw, AUDIO_STATUS_PLAY_ERROR);
		return 0;
	}
	if (!isaudiotrack (&ciw->di.toc, startlsn)) {
		setstate (ciw, AUDIO_STATUS_PLAY_ERROR);
		return 0;
	}
	if (!ciw->cdda_play) {
		uae_start_thread (_T("ioctl_cdda_play"), cdda_play, ciw, NULL);
	}
	ciw->cdda_start = startlsn;
	ciw->cdda_end = endlsn;
	ciw->cd_last_pos = ciw->cdda_start;
	ciw->cdda_play++;

	return 1;
}
开发者ID:maurizioram,项目名称:WinUAE,代码行数:33,代码来源:blkdev_win32_ioctl.cpp


示例3: while

istream& istream::getline(char *str, streamsize n, char delim) {
  FatPos_t pos;
  int c;
  m_gcount = 0;
  if (n > 0) str[0] = '\0';
  while (1) {
    c = getch(&pos);
    if (c < 0) {
      break;
    }
    if (c == delim) {
      m_gcount++;
      break;
    }
    if ((m_gcount + 1)  >=  n) {
      setpos(&pos);
      setstate(failbit);
      break;
    }
    str[m_gcount++] = c;
    str[m_gcount] = '\0';
  }
  if (m_gcount == 0) setstate(failbit);
  return *this;
}
开发者ID:nauman-naeem,项目名称:SdFat-beta,代码行数:25,代码来源:istream.cpp


示例4: __attribute__

 /// \details
 /// Registers a function as an event callback with an integer parameter to
 /// be passed to the function when invoked.  Multiple copies of the
 /// function are allowed.  If there are multiple callbacks, they are
 /// invoked in the order they were registered.
 void
 ios_base::register_callback(event_callback fn __attribute__((unused)),
     int index __attribute__((unused)))
   {
     size_t req_size = __event_size_ + 1;
     if (req_size > __event_cap_)
       {
         size_t newcap;
         const size_t mx = numeric_limits < size_t > ::max();
         if (req_size < mx / 2)
         newcap = _VSTD::max(2 * __event_cap_, req_size);
         else
         newcap = mx;
         event_callback* fns = (event_callback*) realloc(__fn_,
             newcap * sizeof(event_callback));
         if (fns == 0)
         setstate(badbit);
         __fn_ = fns;
         int* indxs = (int*) realloc(__index_, newcap * sizeof(int));
         if (indxs == 0)
         setstate(badbit);
         __index_ = indxs;
       }
     __fn_[__event_size_] = fn;
     __index_[__event_size_] = index;
     ++__event_size_;
   }
开发者ID:micro-os-plus,项目名称:micro-os-plus-ii,代码行数:32,代码来源:ios.cpp


示例5: strlen

void ostream::outstr(const char *d, const char *p)
{
    if( opfx() )
        {
        int plen = p ? strlen(p) : 0;
        int dlen = d ? strlen(d) : 0;
        int pad = width(0) - plen - dlen;

        // pad on left (right-adjust) if needed -- the default case
        if( ! (x_flags & (ios::left | ios::internal)) )
            {
            while( --pad >= 0 )
                {
                if( bp->sputc(x_fill) == EOF )
                    {
                    setstate(ios::badbit);
                    break;
                    }
                }
            }

        // output the prefix
        if( ! fail()  &&  plen )
            if( bp->sputn(p, plen) != plen )
                setstate(ios::badbit);

        // internal padding if needed
        if( ! fail()  &&  (x_flags & ios::internal) )
            {
            while( --pad >= 0 )
                {
                if( bp->sputc(x_fill) == EOF )
                    {
                    setstate(ios::badbit);
                    break;
                    }
                }
            }

        // output the data
        if( ! fail()  &&  dlen )
            if( bp->sputn(d, dlen) != dlen )
                setstate(ios::badbit);

        // pad on right (left-adjust) if needed
        if( ! fail()  &&  (x_flags & ios::left) )
            {
            while( --pad >= 0 )
                {
                if( bp->sputc(x_fill) == EOF )
                    {
                    setstate(ios::badbit);
                    break;
                    }
                }
            }
        }
    osfx();
}
开发者ID:LucasvBerkel,项目名称:TweedejaarsProject,代码行数:59,代码来源:OSTOUTST.CPP


示例6: ctrlproc

static void WINAPI ctrlproc(DWORD ctrl) {
    if (ctrl == SERVICE_CONTROL_STOP) {
	    setstate(SERVICE_STOP_PENDING);
        service->stop();
    } else {
	    setstate(sta.dwCurrentState);
    }
}
开发者ID:C-Martha,项目名称:jcsp,代码行数:8,代码来源:svcclasses.cpp


示例7: FcRandom

static int32_t
FcRandom(void)
{
    int32_t result;

#if HAVE_RANDOM_R
    static struct random_data fcrandbuf;
    static char statebuf[256];
    static FcBool initialized = FcFalse;

    if (initialized != FcTrue)
    {
	initstate_r(time(NULL), statebuf, 256, &fcrandbuf);
	initialized = FcTrue;
    }

    random_r(&fcrandbuf, &result);
#elif HAVE_RANDOM
    static char statebuf[256];
    char *state;
    static FcBool initialized = FcFalse;

    if (initialized != FcTrue)
    {
	state = initstate(time(NULL), statebuf, 256);
	initialized = FcTrue;
    }
    else
	state = setstate(statebuf);

    result = random();

    setstate(state);
#elif HAVE_LRAND48
    result = lrand48();
#elif HAVE_RAND_R
    static unsigned int seed = time(NULL);

    result = rand_r(&seed);
#elif HAVE_RAND
    static FcBool initialized = FcFalse;

    if (initialized != FcTrue)
    {
	srand(time(NULL));
	initialized = FcTrue;
    }
    result = rand();
#else
# error no random number generator function available.
#endif

    return result;
}
开发者ID:manuels,项目名称:unix-toolbox.js-fontconfig,代码行数:54,代码来源:fccache.c


示例8: startproc

static void WINAPI startproc(int argc, TCHAR **argv) {
    hsta = RegisterServiceCtrlHandler(service_name, ctrlproc);
    sta.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
    sta.dwServiceSpecificExitCode = 0;
    sta.dwControlsAccepted = SERVICE_ACCEPT_STOP;
    sta.dwWin32ExitCode = 0;
    sta.dwWaitHint = 3000;
    sta.dwCheckPoint = 0;
    setstate(SERVICE_RUNNING);
    service->start(argc, argv);
    setstate(SERVICE_STOPPED);
}
开发者ID:C-Martha,项目名称:jcsp,代码行数:12,代码来源:svcclasses.cpp


示例9: cad_alfa_num

int
cad_alfa_num (int ini, int fin, char *cadena, char *estado1, char *estado2)
{
/* ------------------------------------------------------ *\
|* Función que genera una cadena de caracteres            *|
|* alfanuméricos de tamaño comfrendido entre              *|
|* 'ini' y 'fin'                                          *|
|* ------------------------------------------------------ *|
|* Parámetro ini: inicio del entervalo de selección del   *|
|* tamaño                                                 *|
|* Parámetro fin: fin del entervalo de selección del tamaño*|
|* Parámetro cadena: cadena donde se almacenan los        *|
|* caractero aleatorios                                   *|
|* Parámetro estado1: estado para la generación del       *|
|* tamaño de la cadena aleatoria                          *|
|* Parámetro estado2: estado para la generación del       *|
|* de los caracteres aleatorios                           *|
|* ------------------------------------------------------ *|
|* Retorna el tamaño de la cadena generada                *|
\* ------------------------------------------------------ */
  int tam, i;
  char ch;

  /* utilizamos estado1 para el tamaño de la cadena */
  setstate (estado1);
  tam = (int) aleat_int (ini, fin);
  setstate (estado2);
  /* utilizamos estado2 para los caracteres aleatorios (e_global) */

  /*Se generan cada uno de los caracteres hasta completar el */
  /*el tamaño generado                                      */
  for (i = 0; i < tam; i++)
     {
       ch = (char) aleat_int (32, 125);	/*generamos aleatoriamente caracteres. */
       if ((ch >= 32) && (ch <= 125))
	  {			/*sólo se contemplas caracteres alfanuméricos   */
	    /*ATENCIÖN: si el caracter generado en el 39 (comilla simple ') se escoje el */
	    /*caracter 40. Esto se hace para evitar el error produce postgreSQL al       */
	    /*introducir una comilla simple en un atributo.                              */
	    if (ch == 39)
	      ch++;
	    cadena[i] = ch;
	  }
       else
	  {
	    printf ("ERROR EN LA FUNCION CAD_ALFA_NUM\n");
	    exit (0);
	  }
     }				/* de for */
  cadena[i] = '\0';		/*se termina la cadena con el fin de cadena */
  return tam;			/*se retorna el tamaño de la cadena generada */
}
开发者ID:joaobertacchi,项目名称:tpccuva-dist,代码行数:52,代码来源:extra.c


示例10: __lock_it

  void fstreambase::setbuf( char *buf, int len ) {

    filebuf *fb;

    __lock_it( __i_lock );
    fb = rdbuf();
    if( fb == NULL ) {
        setstate( ios::failbit );
    } else {
        __lock_it( fb->__b_lock );
        if( fb->setbuf( buf, len ) == NULL ) {
            setstate( ios::failbit );
        }
    }
  }
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:15,代码来源:fsbsetbf.cpp


示例11: locale

locale
ios_base::imbue(const locale& loc)
{
    locale result = *loc_;
#ifndef _EWL_NO_EXCEPTIONS
    try
    {
#endif  // _EWL_NO_EXCEPTIONS
        locale* newloc = new locale(loc);
#ifdef _EWL_NO_EXCEPTIONS
        if (newloc == 0)
            __ewl_error("ios_base::imbue out of memory");
#endif  // _EWL_NO_EXCEPTIONS
        delete loc_;
        loc_ = newloc;
#ifndef _EWL_TINY_IO
        do_callbacks(imbue_event);
#endif
#ifndef _EWL_NO_EXCEPTIONS
    }
    catch (...)
    {
        setstate(badbit);
    }
#endif  // _EWL_NO_EXCEPTIONS
    return result;
}
开发者ID:reynoldsbd3,项目名称:robot-d5,代码行数:27,代码来源:ios.cpp


示例12: setstate

void FileIOS::close()
{
	if (!_buf.close())
	{
		setstate(ios_base::badbit);
	}
}
开发者ID:jacklicn,项目名称:macchina.io,代码行数:7,代码来源:FileStream.cpp


示例13: userinit

// Set up first user process.
void
userinit(void)
{
  struct proc *p;
  extern uchar _binary_initcode_start[], _binary_initcode_size[];
  
  p = copyproc(0);
  p->sz = PAGE;
  p->mem = kalloc(p->sz);
  p->cwd = namei("/");
  memset(p->tf, 0, sizeof(*p->tf));
  p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
  p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
  p->tf->es = p->tf->ds;
  p->tf->ss = p->tf->ds;
  p->tf->eflags = FL_IF;
  p->tf->esp = p->sz;
  
  // Make return address readable; needed for some gcc.
  p->tf->esp -= 4;
  *(uint*)(p->mem + p->tf->esp) = 0xefefefef;

  // On entry to user space, start executing at beginning of initcode.S.
  p->tf->eip = 0;
  memmove(p->mem, _binary_initcode_start, (int)_binary_initcode_size);
  safestrcpy(p->name, "initcode", sizeof(p->name));
#ifdef LOTTERY
  p->tickets = INIT_TICKETS;
#endif
  p->state = UNUSED;
  setstate(p, RUNNABLE);

  initproc = p;
}
开发者ID:aaronb,项目名称:CS637,代码行数:35,代码来源:proc.c


示例14: sleep

// Atomically release lock and sleep on chan.
// Reacquires lock when reawakened.
void
sleep(void *chan, struct spinlock *lk)
{
  if(cp == 0)
    panic("sleep");

  if(lk == 0)
    panic("sleep without lk");

  // Must acquire proc_table_lock in order to
  // change p->state and then call sched.
  // Once we hold proc_table_lock, we can be
  // guaranteed that we won't miss any wakeup
  // (wakeup runs with proc_table_lock locked),
  // so it's okay to release lk.
  if(lk != &proc_table_lock){
    acquire(&proc_table_lock);
    release(lk);
  }

  // Go to sleep.
  cp->chan = chan;
//  cp->state = SLEEPING;
  setstate(cp, SLEEPING);
  sched();

  // Tidy up.
  cp->chan = 0;

  // Reacquire original lock.
  if(lk != &proc_table_lock){
    release(&proc_table_lock);
    acquire(lk);
  }
}
开发者ID:aaronb,项目名称:CS637,代码行数:37,代码来源:proc.c


示例15: setstate

// read the put pointer's position
streampos ostream::tellp()
{
    streampos p = EOF;
    if( bad()  ||  (p = bp->seekoff(0, ios::cur, ios::out)) == EOF )
        setstate(ios::failbit);
    return p;
}
开发者ID:LucasvBerkel,项目名称:TweedejaarsProject,代码行数:8,代码来源:OSTTELLP.CPP


示例16: getNumber

//------------------------------------------------------------------------------
void istream::getBool(bool *b) {
  if ((flags() & boolalpha) == 0) {
    getNumber(b);
    return;
  }
  PGM_P truePtr = PSTR("true");
  PGM_P falsePtr = PSTR("false");
  const uint8_t true_len = 4;
  const uint8_t false_len = 5;
  bool trueOk = true;
  bool falseOk = true;
  uint8_t i = 0;
  int c = readSkip();
  while (1) {
    falseOk = falseOk && c == pgm_read_byte(falsePtr + i);
    trueOk = trueOk && c == pgm_read_byte(truePtr + i);
    if (trueOk == false && falseOk == false) break;
    i++;
    if (trueOk && i == true_len) {
      *b = true;
      return;
    }
    if (falseOk && i == false_len) {
      *b = false;
      return;
    }
    c = getch();
  }
  setstate(failbit);
}
开发者ID:nauman-naeem,项目名称:SdFat-beta,代码行数:31,代码来源:istream.cpp


示例17: __lock_it

  istream &istream::do_read( char *buf, streamsize len ) {

    __lock_it( __i_lock );
    streamsize offset = rdbuf()->sgetn( buf, len );
    if( offset < len ) {
#if 0
        setstate( ios::failbit );
#else
        setstate( ( rdbuf()->underflow() == EOF )
                ? ios::failbit | ios::eofbit
                : ios::failbit );
#endif
    }
    __last_read_length = offset;
    return( *this );
  }
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:16,代码来源:istdread.cpp


示例18: setstate

/*-------------------------------------------------------------ostream::seekp-+
|                                                                             |
+----------------------------------------------------------------------------*/
ostream & ostream::seekp(streampos pos)
{
   if (!fail() && (rdbuf()->pubseekpos(pos, ios::out) == EOF)) {
       setstate(failbit);
   }
   return *this;
}
开发者ID:Jaxo,项目名称:yaxx,代码行数:10,代码来源:iostream.cpp


示例19: setstate

/*******************************************************************************
 raw_imemstream
*******************************************************************************/
raw_ios::pos_type raw_imemstream::seekoff(off_type offs, seekdir dir)
{
   setstate(eofbit, false) ;
   const pos_type from =
      dir == cur ? _pos : (dir == beg ? pos_type() : (pos_type)_size) ;
   return _pos = midval<pos_type>(0, _size, from + offs) ;
}
开发者ID:ymarkovitch,项目名称:libpcomn,代码行数:10,代码来源:pcomn_rawstream.cpp


示例20: clear

void rpcstream::verify(int ok) {
    if (ok) {
	clear();
    } else {
	setstate(ios::failbit);
    }
}
开发者ID:neurodebian,项目名称:iv-hines,代码行数:7,代码来源:rpcstream.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setstatus函数代码示例发布时间:2022-05-30
下一篇:
C++ setstack_manager函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap