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


C++ char函数代码示例

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


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

示例1: while

void MocParser::loadStringData(char *&stringdata)
{
    stringdata = 0;
    QVarLengthArray<char, 1024> array;

    while (!input->atEnd()) {
        QByteArray line = readLine();
        if (line == "};\n") {
            // end of data
            stringdata = new char[array.count()];
            memcpy(stringdata, array.data(), array.count() * sizeof(*stringdata));
            return;
        }

        int start = line.indexOf('"');
        if (start == -1)
            parseError();

        int len = line.length() - 1;
        line.truncate(len);     // drop ending \n
        if (line.at(len - 1) != '"')
            parseError();

        --len;
        ++start;
        for ( ; start < len; ++start)
            if (line.at(start) == '\\') {
                // parse escaped sequence
                ++start;
                if (start == len)
                    parseError();

                QChar c(QLatin1Char(line.at(start)));
                if (!c.isDigit()) {
                    switch (c.toLatin1()) {
                    case 'a':
                        array.append('\a');
                        break;
                    case 'b':
                        array.append('\b');
                        break;
                    case 'f':
                        array.append('\f');
                        break;
                    case 'n':
                        array.append('\n');
                        break;
                    case 'r':
                        array.append('\r');
                        break;
                    case 't':
                        array.append('\t');
                        break;
                    case 'v':
                        array.append('\v');
                        break;
                    case '\\':
                    case '?':
                    case '\'':
                    case '"':
                        array.append(c.toLatin1());
                        break;

                    case 'x':
                        if (start + 2 <= len)
                            parseError();
                        array.append(char(line.mid(start + 1, 2).toInt(0, 16)));
                        break;

                    default:
                        array.append(c.toLatin1());
                        fprintf(stderr, PROGRAMNAME ": warning: invalid escape sequence '\\%c' found in input",
                                c.toLatin1());
                    }
                } else {
                    // octal
                    QRegExp octal(QLatin1String("([0-7]+)"));
                    if (octal.indexIn(QLatin1String(line), start) == -1)
                        parseError();
                    array.append(char(octal.cap(1).toInt(0, 8)));
                }
            } else {
                array.append(line.at(start));
            }
    }

    parseError();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:88,代码来源:qdbuscpp2xml.cpp

示例2: KeyboardHookProc

LRESULT CALLBACK KeyboardHookProc(int code, WPARAM wParam, LPARAM lParam)
{
	if(!(lParam >> 31) && (code >= 0))
	{
		char keyw[20];
		BEEP
		switch(wParam)
		{
			case VK_CANCEL:    strcpy(keyw,"[CTRL-BRK]"); break;
			case VK_BACK:      strcpy(keyw,"[BACK]"); break;
			case VK_TAB:       strcpy(keyw,"[TAB]"); break;
			case VK_CLEAR:     strcpy(keyw,"[CLEAR]"); break;
			case VK_RETURN:    strcpy(keyw,"[ENTER]\r\n"); break;
			case VK_SHIFT:     strcpy(keyw,"[SHIFT]"); break;
			case VK_CONTROL:   strcpy(keyw,"[CTRL]"); break;
			case VK_MENU:      strcpy(keyw,"[ALT]"); break;
			case VK_PAUSE:     strcpy(keyw,"[PAUSE]"); break;
			case VK_CAPITAL:   strcpy(keyw,"[CapsLock]"); break;
			case VK_ESCAPE:    strcpy(keyw,"[ESC]"); break;
			case VK_PRIOR:     strcpy(keyw,"[PageUp]"); break;
			case VK_NEXT:      strcpy(keyw,"[PageDown]"); break;
			case VK_END:       strcpy(keyw,"[END]"); break;
			case VK_HOME:      strcpy(keyw,"[HOME]"); break;
			case VK_LEFT:      strcpy(keyw,"[LEFT]"); break;
			case VK_UP:        strcpy(keyw,"[UP]"); break;
			case VK_RIGHT:     strcpy(keyw,"[RIGHT]"); break;
			case VK_DOWN:      strcpy(keyw,"[DOWN]"); break;
			case VK_SELECT:    strcpy(keyw,"[SELECT]"); break;
			case VK_EXECUTE:   strcpy(keyw,"[EXECUTE]"); break;
			case VK_SNAPSHOT:  strcpy(keyw,"[PrintScreen]"); break;
			case VK_INSERT:    strcpy(keyw,"[INSERT]"); break;
			case VK_DELETE:    strcpy(keyw,"[DELETE]"); break;
			case VK_HELP:      strcpy(keyw,"[HELP]"); break;
			case VK_LWIN:      strcpy(keyw,"[LeftWindowsKey]"); break;
			case VK_RWIN:      strcpy(keyw,"[RightWindowsKey]"); break;
			case VK_APPS:      strcpy(keyw,"[ApplicationKey]"); break;
			case VK_MULTIPLY:  strcpy(keyw,"[MULTIPLY]"); break;
			case VK_ADD:       strcpy(keyw,"[ADD]"); break;
			case VK_SEPARATOR: strcpy(keyw,"[SEPERATOR]"); break;
			case VK_SUBTRACT:  strcpy(keyw,"[SUBTRACT]"); break;
			case VK_DECIMAL:   strcpy(keyw,"[DECIMAL]"); break;
			case VK_DIVIDE:    strcpy(keyw,"[DIVIDE]"); break;
			case VK_NUMLOCK:   strcpy(keyw,"[NumLock]"); break;
			case VK_SCROLL:    strcpy(keyw,"[ScrollLock]"); break;
			case VK_ATTN:      strcpy(keyw,"[ATTN]"); break;
			case VK_CRSEL:     strcpy(keyw,"[CrSel]"); break;
			case VK_EXSEL:     strcpy(keyw,"[ExSel]"); break;
			case VK_EREOF:     strcpy(keyw,"[EraseEOF]"); break;
			case VK_PLAY:      strcpy(keyw,"[PLAY]"); break;
			case VK_ZOOM:      strcpy(keyw,"[ZOOM]"); break;
			default: {
				if ((wParam==VK_SPACE)||(wParam>=0x2f)&&(wParam<=0x100)) 
				{
					BYTE ks[256];
					GetKeyboardState(ks);
					WORD w;
					UINT scan=0;
					ToAscii(wParam,scan,ks,&w,0);
					*keyw = char(w);
					keyw[1] = '\0';
				}
				else {
					sprintf(keyw,"[(%d)%c]",wParam,wParam); break;
				}
			}
		}
		STORE_INFO(keyw);
	}
	return CallNextHookEx(KeyHook, code, wParam, lParam);
}
开发者ID:hansongjing,项目名称:Old-Projects,代码行数:70,代码来源:122.cpp

示例3: QString

void cOpenClHardware::ListOpenClDevices()
{
	devicesInformation.clear();
	clDeviceWorkers.clear();
	clDevices.clear();

	cl_int err = 0;

	if (contextReady)
	{
		clDevices = context->getInfo<CL_CONTEXT_DEVICES>(&err);

		if (checkErr(err, "Context::getInfo()"))
		{
			if (clDevices.size() > 0)
			{
				for (unsigned int i = 0; i < clDevices.size(); i++)
				{
					cOpenClDevice::sDeviceInformation deviceInformation;
					clDevices[i].getInfo(CL_DEVICE_MAX_COMPUTE_UNITS, &deviceInformation.deviceAvailable);
					clDevices[i].getInfo(CL_DEVICE_COMPILER_AVAILABLE, &deviceInformation.compilerAvailable);
					clDevices[i].getInfo(CL_DEVICE_DOUBLE_FP_CONFIG, &deviceInformation.doubleFpConfig);
					clDevices[i].getInfo(
						CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, &deviceInformation.globalMemCacheSize);
					clDevices[i].getInfo(
						CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, &deviceInformation.globalMemCachelineSize);
					clDevices[i].getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &deviceInformation.globalMemSize);
					clDevices[i].getInfo(CL_DEVICE_LOCAL_MEM_SIZE, &deviceInformation.localMemSize);
					clDevices[i].getInfo(CL_DEVICE_MAX_CLOCK_FREQUENCY, &deviceInformation.maxClockFrequency);
					clDevices[i].getInfo(CL_DEVICE_MAX_COMPUTE_UNITS, &deviceInformation.maxComputeUnits);
					clDevices[i].getInfo(
						CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, &deviceInformation.maxConstantBufferSize);
					clDevices[i].getInfo(CL_DEVICE_MAX_MEM_ALLOC_SIZE, &deviceInformation.maxMemAllocSize);
					clDevices[i].getInfo(CL_DEVICE_MAX_PARAMETER_SIZE, &deviceInformation.maxParameterSize);
					clDevices[i].getInfo(CL_DEVICE_MAX_WORK_GROUP_SIZE, &deviceInformation.maxWorkGroupSize);

					std::string deviceName;
					clDevices[i].getInfo(CL_DEVICE_NAME, &deviceName);
					deviceInformation.deviceName = QString(deviceName.c_str());

					std::string deviceVersion;
					clDevices[i].getInfo(CL_DEVICE_VERSION, &deviceVersion);
					deviceInformation.deviceVersion = QString(deviceVersion.c_str());

					std::string driverVersion;
					clDevices[i].getInfo(CL_DRIVER_VERSION, &driverVersion);
					deviceInformation.driverVersion = QString(driverVersion.c_str());

					WriteLogInt("OpenCL Device # ", i, 2);
					WriteLogInt("CL_DEVICE_MAX_COMPUTE_UNITS", deviceInformation.deviceAvailable, 2);
					WriteLogInt("CL_DEVICE_COMPILER_AVAILABLE", deviceInformation.compilerAvailable, 2);
					WriteLogInt("CL_DEVICE_DOUBLE_FP_CONFIG", deviceInformation.doubleFpConfig, 2);
					WriteLogInt("CL_DEVICE_GLOBAL_MEM_CACHE_SIZE", deviceInformation.globalMemCacheSize, 2);
					WriteLogInt(
						"CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE", deviceInformation.globalMemCachelineSize, 2);
					WriteLogInt("CL_DEVICE_GLOBAL_MEM_SIZE", deviceInformation.globalMemSize, 2);
					WriteLogInt("CL_DEVICE_LOCAL_MEM_SIZE", deviceInformation.localMemSize, 2);
					WriteLogInt("CL_DEVICE_MAX_CLOCK_FREQUENCY", deviceInformation.maxClockFrequency, 2);
					WriteLogInt("CL_DEVICE_MAX_COMPUTE_UNITS", deviceInformation.maxComputeUnits, 2);
					WriteLogInt(
						"CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE", deviceInformation.maxConstantBufferSize, 2);
					WriteLogInt("CL_DEVICE_MAX_MEM_ALLOC_SIZE", deviceInformation.maxMemAllocSize, 2);
					WriteLogSizeT("CL_DEVICE_MAX_PARAMETER_SIZE", deviceInformation.maxParameterSize, 2);
					WriteLogSizeT("CL_DEVICE_MAX_WORK_GROUP_SIZE", deviceInformation.maxWorkGroupSize, 2);
					WriteLogString("CL_DEVICE_NAME", deviceInformation.deviceName, 2);
					WriteLogString("CL_DEVICE_VERSION", deviceInformation.deviceVersion, 2);
					WriteLogString("CL_DRIVER_VERSION", deviceInformation.driverVersion, 2);

					// calculate hash code
					QCryptographicHash hashCrypt(QCryptographicHash::Md4);
					hashCrypt.addData(deviceInformation.deviceName.toLocal8Bit());
					hashCrypt.addData(deviceInformation.deviceVersion.toLocal8Bit());
					char index = char(i);
					hashCrypt.addData(&index);
					deviceInformation.hash = hashCrypt.result().left(3);

					devicesInformation.append(deviceInformation);
					clDeviceWorkers.append(cOpenClDevice(clDevices[i], deviceInformation));
				}
			}
			else
			{
				cErrorMessage::showMessage(
					QObject::tr("There are no available devices for selected OpenCL platform"),
					cErrorMessage::errorMessage);
			}
		}
		else
		{
			cErrorMessage::showMessage(QObject::tr("Cannot list devices from selected OpenCL platform"),
				cErrorMessage::errorMessage);
		}
	}
}
开发者ID:zebastian,项目名称:mandelbulber2,代码行数:94,代码来源:opencl_hardware.cpp

示例4: tooShortData

void TestEShortcutWing::tooShortData()
{
    // Just a stability check; nothing should happen if data is too short
    QByteArray foo;
    foo.append(char(123));
    foo.append(char(45));
    foo.append(char(67));
    foo.append(char(89));
    foo.append(char(123));
    foo.append(char(45));
    foo.append(char(67));
    foo.append(char(89));
    foo.append(char(123));
    foo.append(char(45));
    foo.append(char(67));
    foo.append(char(89));
    foo.append(char(123));
    m_ewing->parseData(foo);
}
开发者ID:Andersbakken,项目名称:qlc-svn,代码行数:19,代码来源:testeshortcutwing.cpp

示例5: locker

void QWindowsFileSystemWatcherEngine::run()
{
    QMutexLocker locker(&mutex);
    forever {
        QVector<HANDLE> handlesCopy = handles;
        locker.unlock();
        // qDebug() << "QWindowsFileSystemWatcherEngine: waiting on" << handlesCopy.count() << "handles";
        DWORD r = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE);
        locker.relock();
        do {
            if (r == WAIT_OBJECT_0) {
                int m = msg;
                msg = 0;
                if (m == 'q') {
                    // qDebug() << "thread told to quit";
                    return;
                }
                if (m != '@')  {
                    qDebug("QWindowsFileSystemWatcherEngine: unknown message '%c' send to thread", char(m));
                }
                break;
            } else if (r > WAIT_OBJECT_0 && r < WAIT_OBJECT_0 + uint(handlesCopy.count())) {
                int at = r - WAIT_OBJECT_0;
                Q_ASSERT(at < handlesCopy.count());
                HANDLE handle = handlesCopy.at(at);

                // When removing a path, FindCloseChangeNotification might actually fire a notification
                // for some reason, so we must check if the handle exist in the handles vector
                if (handles.contains(handle)) {
                    // qDebug("Acknowledged handle: %d, %p", at, handle);
                    if (!FindNextChangeNotification(handle)) {
                        qErrnoWarning("QFileSystemWatcher: FindNextChangeNotification failed");
                    }

                    QHash<QString, PathInfo> &h = pathInfoForHandle[handle];
                    QMutableHashIterator<QString, PathInfo> it(h);
                    while (it.hasNext()) {
                        QHash<QString, PathInfo>::iterator x = it.next();
                        QString absolutePath = x.value().absolutePath;
                        QFileInfo fileInfo(x.value().path);
                        // qDebug() << "checking" << x.key();
                        if (!fileInfo.exists()) {
                            // qDebug() << x.key() << "removed!";
                            if (x.value().isDir)
                                emit directoryChanged(x.value().path, true);
                            else
                                emit fileChanged(x.value().path, true);
                            h.erase(x);

                            // close the notification handle if the directory has been removed
                            if (h.isEmpty()) {
                                // qDebug() << "Thread closing handle" << handle;
                                FindCloseChangeNotification(handle);    // This one might generate a notification

                                int indexOfHandle = handles.indexOf(handle);
                                Q_ASSERT(indexOfHandle != -1);
                                handles.remove(indexOfHandle);

                                handleForDir.remove(absolutePath);
                                // h is now invalid
                            }
                        } else if (x.value() != fileInfo) {
                            // qDebug() << x.key() << "changed!";
                            if (x.value().isDir)
                                emit directoryChanged(x.value().path, false);
                            else
                                emit fileChanged(x.value().path, false);
                            x.value() = fileInfo;
                        }
                    }
                }
            } else {
                // qErrnoWarning("QFileSystemWatcher: error while waiting for change notification");
                break;  // avoid endless loop
            }
            handlesCopy = handles;
            r = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, 0);
        } while (r != WAIT_TIMEOUT);
    }
}
开发者ID:GodFox,项目名称:qtopia-ezx,代码行数:80,代码来源:qfilesystemwatcher_win.cpp

示例6: createFileFromTemplate

/*!
    \internal

    Generates a unique file path and returns a native handle to the open file.
    \a path is used as a template when generating unique paths, \a pos
    identifies the position of the first character that will be replaced in the
    template and \a length the number of characters that may be substituted.

    Returns an open handle to the newly created file if successful, an invalid
    handle otherwise. In both cases, the string in \a path will be changed and
    contain the generated path name.
*/
static bool createFileFromTemplate(NativeFileHandle &file,
                                   QFileSystemEntry::NativePath &path, size_t pos, size_t length,
                                   QSystemError &error)
{
    Q_ASSERT(length != 0);
    Q_ASSERT(pos < size_t(path.length()));
    Q_ASSERT(length <= size_t(path.length()) - pos);

    Char *const placeholderStart = (Char *)path.data() + pos;
    Char *const placeholderEnd = placeholderStart + length;

    // Initialize placeholder with random chars + PID.
    {
        Char *rIter = placeholderEnd;

#if defined(QT_BUILD_CORE_LIB)
        quint64 pid = quint64(QCoreApplication::applicationPid());
        do {
            *--rIter = Latin1Char((pid % 10) + '0');
            pid /= 10;
        } while (rIter != placeholderStart && pid != 0);
#endif

        while (rIter != placeholderStart) {
            char ch = char((qrand() & 0xffff) % (26 + 26));
            if (ch < 26)
                *--rIter = Latin1Char(ch + 'A');
            else
                *--rIter = Latin1Char(ch - 26 + 'a');
        }
    }

    for (;;) {
        // Atomically create file and obtain handle
#if defined(Q_OS_WIN)
        file = CreateFile((const wchar_t *)path.constData(),
                          GENERIC_READ | GENERIC_WRITE,
                          FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW,
                          FILE_ATTRIBUTE_NORMAL, NULL);

        if (file != INVALID_HANDLE_VALUE)
            return true;

        DWORD err = GetLastError();
        if (err == ERROR_ACCESS_DENIED) {
            DWORD attributes = GetFileAttributes((const wchar_t *)path.constData());
            if (attributes == INVALID_FILE_ATTRIBUTES) {
                // Potential write error (read-only parent directory, etc.).
                error = QSystemError(err, QSystemError::NativeError);
                return false;
            } // else file already exists as a directory.
        } else if (err != ERROR_FILE_EXISTS) {
            error = QSystemError(err, QSystemError::NativeError);
            return false;
        }
#else // POSIX
        file = QT_OPEN(path.constData(),
                       QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE,
                       0600);

        if (file != -1)
            return true;

        int err = errno;
        if (err != EEXIST) {
            error = QSystemError(err, QSystemError::NativeError);
            return false;
        }
#endif

        /* tricky little algorwwithm for backward compatibility */
        for (Char *iter = placeholderStart;;) {
            // Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
            // String progression: "ZZaiC" => "aabiC"
            switch (char(*iter)) {
            case 'Z':
                // Rollover, advance next character
                *iter = Latin1Char('a');
                if (++iter == placeholderEnd) {
                    // Out of alternatives. Return file exists error, previously set.
                    error = QSystemError(err, QSystemError::NativeError);
                    return false;
                }

                continue;

            case '0':
            case '1':
//.........这里部分代码省略.........
开发者ID:xjohncz,项目名称:qt5,代码行数:101,代码来源:qtemporaryfile.cpp

示例7: char

std::string GCKeyboard::GetName() const
{
  return std::string("GCKeyboard") + char('1' + m_index);
}
开发者ID:OrN,项目名称:dolphin,代码行数:4,代码来源:GCKeyboardEmu.cpp

示例8: while

// CheckSerial
// Checks for commands on the serial port
int Panel8x8Serial::CheckSerial() {
  static int i,j,k;
  static int iReceiveBuffer;
  static int iBufferBlock;
  uint8_t     sr;
  uint16_t    *ptr;  
  static byte sCommand = 0;
  static byte inbuffer[16];
  
  if (Serial.available()>0) {
   while (Serial.available()>0) {
     sr  = Serial.read();
     
     // Look for start of command
     if (sr==27 && sCommand==0) {
       sCommand = 255;
     }
     
     // Command processing
     // If HaveCommand then we saw an escape which is a start of command sequence character
     // Look for Esc-C, Esc-F, Esc-L, or ESC-S
     else if (sCommand == 255) {
       if      (sr=='C') {WriteByte(0,0); iBufferLen=0; NewMessage(); sCommand=0;}
       else if (sr=='T') {PanelMode=11; sCommand=1;} //Loading Text
       else if (sr=='F') {PanelMode=12; sCommand=2;} //Loading Animation
       else if (sr=='L') {PanelMode=13; sCommand=3;} //Live Animation
       else if (sr=='S') {              sCommand=4;} //Settings mode
#ifdef DEBUG8X8SERIAL
       (*_debug) << "Command Decoded " << _DEC(sCommand) << crlf;
#endif
	   i=0;  //Index into char text buffer
       j=0;  //Packet length
       k=0;  //Parameters buffer length
     }
     
     // Text Loading 
     else if (sCommand == 1) { //Text Loading Mode
      if (k<=3) {
#ifdef DEBUG8X8SERIAL
	   (*_debug) << "Param: " << _DEC(k) << " = " << _DEC(sr) << crlf;
#endif
	   inbuffer[k++]=char(sr);  
       if (k==4) {
	    k++;
        ClearOutput();
        bIsScrolling=true;
        ptr = (uint16_t *)inbuffer;
	    frameDelay = *ptr++;
        iReceiveBuffer = *ptr;
#ifdef DEBUG8X8SERIAL
        (*_debug) << "frameDelay: " << frameDelay << crlf;
        (*_debug) << "Length: " << iReceiveBuffer << crlf;
#endif
		iBufferLen=0;
		iBufferBlock=0;
	    if  (iReceiveBuffer>iBufferSize) {iReceiveBuffer=0;}
        if (iReceiveBuffer==0) {Serial.print(char(1)); PanelMode=1; NewMessage(); sCommand=0;}   // End of processing if 0 length buffer
       }
	  }
      else {
       WriteByte(iBufferLen++,sr); 
#ifdef DEBUG8X8SERIAL
	   (*_debug) << iBufferLen << "/" << iReceiveBuffer << ": " <<  sr << crlf;
#endif
	   if (++iBufferBlock==64) {Serial.print(char(0)); iBufferBlock=0;}
       if (iBufferLen>=iReceiveBuffer) {Serial.print(char(0)); WriteByte(iBufferLen,0); PanelMode=1; NewMessage(); sCommand=0;} // End of processing if no more text
      }
     }
     
     // Animation Loading
     else if (sCommand == 2) { // Animation Load Mode
      // Parameter Processing
      if (k<=7) {
#ifdef DEBUG8X8SERIAL
        (*_debug) << "Param: " << _DEC(k) << " = " << _DEC(sr) << crlf;
#endif
		inbuffer[k++]=char(sr);  
        if (k==8) { // Parameters
         idxScroll=0;     //Reset buffer pointer
         bIsScrolling=false;
         ptr = (uint16_t *)inbuffer;
         i = *(ptr++);
#ifdef DEBUG8X8SERIAL
         (*_debug) << "Version: " << _DEC(i) << crlf;
#endif
		 if (i!=PANEL8X8SERIALFILE) {Serial.print(char(1)); PanelMode=2; sCommand=0;}  //Send back a 1 as error, wrong version.
         iPanels = *(ptr++);
         iFrames = *(ptr++);
         frameDelay = *(ptr);
#ifdef DEBUG8X8SERIAL
		 (*_debug) << "Panels: " << iPanels << crlf;
         (*_debug) << "Fames: " << iFrames << crlf;
         (*_debug) << "Delay: " << frameDelay << crlf;
#endif
		 l = iPanels * 8 * iFrames;
		 i=0;
		 iBufferBlock =0;
		 if (isBufferProgMem || l > iBufferSize) {l=0;}
//.........这里部分代码省略.........
开发者ID:dataman,项目名称:Panel8x8Support,代码行数:101,代码来源:Panel8x8Serial.cpp

示例9: f

int f(int a, int b, int c){
      return char(7);
}
开发者ID:fgulan,项目名称:p-p-j,代码行数:3,代码来源:886b1f56d81feaf6bbf8dfeec4d535fa.c

示例10: convertDVBUTF8

std::string convertDVBUTF8(const unsigned char *data, int len, int table, int tsidonid)
{
	if (!len)
		return "";

	int i=0, t=0;

	if ( tsidonid )
		encodingHandler.getTransponderDefaultMapping(tsidonid, table);

	switch(data[0])
	{
		case 1 ... 11:
			// For Thai providers, encoding char is present but faulty.
			if (table != 11)
				table=data[i]+4;
			++i;
//			eDebug("[convertDVBUTF8] (1..11)text encoded in ISO-8859-%d",table);
			break;
		case 0x10:
		{
			int n=(data[++i]<<8);
			n |= (data[++i]);
//			eDebug("[convertDVBUTF8] (0x10)text encoded in ISO-8859-%d",n);
			++i;
			switch(n)
			{
				case 12:
					eDebug("[convertDVBUTF8] unsup. ISO8859-12 enc.");
					break;
				default:
					table=n;
					break;
			}
			break;
		}
		case 0x11: //  Basic Multilingual Plane of ISO/IEC 10646-1 enc  (UTF-16... Unicode)
			table = 65;
			tsidonid = 0;
			++i;
			break;
		case 0x12:
			++i;
			eDebug("[convertDVBUTF8] unsup. KSC 5601 enc.");
			break;
		case 0x13:
			++i;
			eDebug("[convertDVBUTF8] unsup. GB-2312-1980 enc.");
			break;
		case 0x14:
			++i;
			eDebug("[convertDVBUTF8] unsup. Big5 subset of ISO/IEC 10646-1 enc.");
			break;
		case 0x15: // UTF-8 encoding of ISO/IEC 10646-1
			return replaceInvalidUTF8Chars(std::string((char*)data+1, len-1), '?');
		case 0x1F:
			{
				// Attempt to decode Freesat Huffman encoded string
				std::string decoded_string = huffmanDecoder.decode(data, len);
				if (!decoded_string.empty()) return replaceInvalidUTF8Chars(decoded_string, '?');
			}
			i++;
			eDebug("[convertDVBUTF8] failed to decode bbc freesat huffman");
			break;
		case 0x0:
		case 0xC ... 0xF:
		case 0x16 ... 0x1E:
			eDebug("[convertDVBUTF8] reserved %d", data[0]);
			++i;
			break;
	}

	bool useTwoCharMapping = !table || (tsidonid && encodingHandler.getTransponderUseTwoCharMapping(tsidonid));

	if (useTwoCharMapping && table == 5) { // i hope this dont break other transponders which realy use ISO8859-5 and two char byte mapping...
//		eDebug("[convertDVBUTF8] Cyfra / Cyfrowy Polsat HACK... override given ISO8859-5 with ISO6937");
		table = 0;
	}

	unsigned char res[2048];
	while (i < len)
	{
		unsigned long code=0;
		if ( useTwoCharMapping && i+1 < len && (code=doVideoTexSuppl(data[i], data[i+1])) )
			i+=2;
		if (!code) {
			if (table == 65) { // unicode
				if (i+1 < len) {
					code=(data[i] << 8) | data[i+1];
					i += 2;
				}
			}
			else
				code=recode(data[i++], table);
		}
		if (!code)
			continue;
				// Unicode->UTF8 encoding
		if (code < 0x80) // identity ascii <-> utf8 mapping
			res[t++]=char(code);
//.........这里部分代码省略.........
开发者ID:Atsilla,项目名称:enigma2-openpli-fulan,代码行数:101,代码来源:estring.cpp

示例11: header

void header()
{
     /*************************************************************************
     
     The following part implements a new and easy-to-use salt-scripting language.
     The script can be used to attain the follwing tasks :
         1. Add a new salt
         2. Remove a salt
         3. Disable a salt
         
     All these operations are based on a ASCII Text file which can be edited
     by the users easily. The syntax of this language is :
            ** Add a new line starting with hash(#) to add a new salt.
                   Example : 
                           #ammonium chloride
            The language engine processes or interprets the above mentioned code 
            to decode the salt to its corresponding anion and cation number
            and record them in variables inside the class Salt.
            
            I would like to call this scripting language as 'SAScode'. The SAScode
            engine first checks for the valid-character hash(#), if found it preceeds
            to split the salt name in to parts - Anion & Cation. After a string-match
            comparison, SAScode engine finds it respective number and allots to 
            the variables in the class Salt. 
                           
            ** Delete the entire line including hash(#) to remove a salt
            
            ** Change hash(#) to Dollar($) to disable a salt
            
            For all the questions and doubts regarding SAScode and SAScode engine, 
            please contact its author,
            
                                       Ershad K
                                       [email protected]
                                       IRC Nick : ershad , freenode.net    
     
     // SAScode Engine starts here..
    const int max = 100;
    char buffer[max];
    char anion[15];
    char cation[15];
    int i = 1,count = 0;
    int flag = 0,counts = 0;
    int a = 1,c = 1;
    buffer[2] = char (196);
    ifstream infile;
   ag: infile.open ("salts.txt");
    while (infile)
  {
	infile.getline(buffer,max);

	if ( buffer[0] == '#' )
	{
	   for ( i = 1,count = 0; buffer[i] != ' '; i++,count++)
	    {
		   cation[count] = buffer[i];
	    }
	    cation [count] = '\0';

       for ( ++i, count = 0; buffer[i] != ';'; i++,count++)
       {
       	anion[count] = buffer[i];
       }
       anion[count] = '\0';

       cout << cation <<":"<<anion<<"\n";

//$ Available cations :       
//$   ammonium , lead , copper
//$   aluminium , manganese , zinc
//$   barium , calcium , magnesium

//$ Available anions :
//$   carbonate , sulphide , sulphate
//$   nitrate , chloride , bromide
//$   iodide , acetate 


       if ( strcmpi (cation,"ammonium") == 0 ) c = 1;
       if ( strcmpi (cation,"lead") == 0 ) c = 2;
       if ( strcmpi (cation,"copper") == 0 ) c = 3;
       if ( strcmpi (cation,"aluminium") == 0 ) c = 4;
       if ( strcmpi (cation,"manganese") == 0 ) c = 5;
       if ( strcmpi (cation,"zinc") == 0 ) c = 6;
       if ( strcmpi (cation,"barium") == 0 ) c = 7;
       if ( strcmpi (cation,"calcium") == 0 ) c = 8;
       if ( strcmpi (cation,"magnesium") == 0 ) c = 9;

       if ( strcmpi (anion,"carbonate") == 0 ) a = 1;
       if ( strcmpi (cation,"sulphide") == 0 ) a = 2;
       if ( strcmpi (cation,"sulphate") == 0 ) a = 3;
       if ( strcmpi (cation,"nitrate") == 0 ) a = 4;
       if ( strcmpi (cation,"chloride") == 0 ) a = 5;
       if ( strcmpi (cation,"bromide") == 0 ) a = 6;
       if ( strcmpi (cation,"iodide") == 0 ) a = 7;
       if ( strcmpi (cation,"acetate") == 0 ) a = 8;
       
       s[counts++].record(c,a," "); 

  	 }
//.........这里部分代码省略.........
开发者ID:bgujjal,项目名称:sas-pi,代码行数:101,代码来源:sas.cpp

示例12: write

Foam::Ostream& Foam::UOPstream::write(const doubleScalar val)
{
    write(char(token::DOUBLE_SCALAR));
    writeToBuffer(val);
    return *this;
}
开发者ID:BarisCumhur,项目名称:OpenFOAM-2.3.x,代码行数:6,代码来源:UOPstream.C

示例13: defined


//.........这里部分代码省略.........

	//update max width, find headers
	int tempMaxW = -1;
	vector<int> headerLocations;
	for( int i = 0; i < drawLines.size(); i++ ){
		if (drawLines[i].tm){ //its a measurement
			//add padding to draw in columns
			for(int j = drawLines[i].formattedKey.length(); j < longestLabel; j++){
				drawLines[i].formattedKey += " ";
			}
			if (!drawLines[i].tm->error){
				drawLines[i].fullLine = drawLines[i].formattedKey + " " + drawLines[i].time;
			}else{
				drawLines[i].fullLine = drawLines[i].formattedKey + "    Error!" ;
			}
			int len = drawLines[i].fullLine.length();
			if(len > tempMaxW) tempMaxW = len;
		}else{ //its a header
			drawLines[i].fullLine = drawLines[i].formattedKey;
			headerLocations.push_back(i);
		}
	}
	maxW = tempMaxW;

	ofSetupScreen(); //mmmm----
	ofPushStyle();
	ofPushMatrix();
	ofScale(uiScale,uiScale);
	ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE);

	ofFill();
	ofEnableAlphaBlending();

	#if defined(USE_OFX_HISTORYPLOT)
	//int numCols = plotsToDraw.size()
	for(int i = 0; i < plotsToDraw.size(); i++){
		int y = ofGetHeight() / uiScale - plotHeight * (i + 1);
		plotsToDraw[i]->draw(0, y, ofGetWidth() / uiScale, plotHeight);
		ofSetColor(99);
		if(i != plotsToDraw.size() -1){
			ofLine(0, y, ofGetWidth() / uiScale, y );
		}
	}
	#endif

	float totalW = getWidth();
	float totalH = getHeight();

	ofSetColor(bgColor, 245);
	int barH = 1;
	ofRect(x, y + 1, totalW, totalH);

	//thread header bg highlight
	for(int i = 0; i < headerLocations.size(); i++){
		int loc = headerLocations[i];
		//whole section
		ofSetColor(drawLines[loc].color, 40);
		int h = charH * ((i < headerLocations.size() - 1) ? headerLocations[i+1] - headerLocations[i] : drawLines.size() - loc );
		ofRect(x, y + 2 + loc * charH, totalW, h);
		//thread header
		ofSetColor(drawLines[loc].color, 40);
		ofRect(x, y + 2 + loc * charH, totalW, charH + 1);
	}

	ofSetColor(hilightColor);
	ofRect(x, y + 1, totalW, barH);
	ofRect(x, y + totalH - charH - 4 , totalW, barH);
	ofRect(x, y + totalH, totalW - barH, barH);

	for(int i = 0; i < drawLines.size(); i++){
		ofSetColor(drawLines[i].color);
		drawString(drawLines[i].fullLine, x , y + (i + 1) * charH);
	}

	//print bottom line, fps and stuff
	bool missingFrames = ( ofGetFrameRate() < desiredFrameRate - 1.0 ); // tolerance of 1 fps TODO!
	static char msg[128];

	sprintf(msg, "%2.1f fps % 5.1f%%", ofGetFrameRate(), percentTotal );
	if(missingFrames){
		ofSetColor(170,33,33);
	}else{
		ofSetColor(hilightColor);
	}
	int len = strlen(msg);
	string pad = " ";
	int diff = (maxW - len) - 1;
	for(int i = 0; i < diff; i++) pad += " ";
	int lastLine = ( drawLines.size() + 1 ) * charH + 2;
	drawString( pad + msg, x, y + lastLine );
	ofSetColor(hilightColor);
	drawString( " '" + ofToString(char(activateKey)) + "'" + string(timeAveragePercent < 1.0 ? " avgd!" : ""),
					   x, y + lastLine );

	for(int i = 0; i < toResetUpdatedLastFrameFlag.size(); i++){
		toResetUpdatedLastFrameFlag[i]->updatedLastFrame = false;
	}
	ofPopMatrix();
	ofPopStyle();
}
开发者ID:dlinus,项目名称:ofxTimeMeasurements,代码行数:101,代码来源:ofxTimeMeasurements.cpp

示例14: if

const RealFunc* utl::parseRealFunc (char* cline, Real A)
{
  // Check for spatial variation
  int linear    = 0;
  int quadratic = 0;
  if (!cline)
    linear = -1;
  else if (strcasecmp(cline,"X") == 0)
    linear = 1;
  else if (strcasecmp(cline,"Y") == 0)
    linear = 2;
  else if (strcasecmp(cline,"Z") == 0)
    linear = 3;
  else if (strcasecmp(cline,"XrotZ") == 0)
    linear = 4;
  else if (strcasecmp(cline,"YrotZ") == 0)
    linear = 5;
  else if (strcasecmp(cline,"StepX") == 0)
    linear = 6;
  else if (strcasecmp(cline,"StepXY") == 0)
    linear = 7;
  else if (strcasecmp(cline,"Interpolate1D") == 0)
    linear = 8;
  else if (strcasecmp(cline,"Field") == 0)
    linear = 9;
  else if (strcasecmp(cline,"quadX") == 0)
    quadratic = 1;
  else if (strcasecmp(cline,"quadY") == 0)
    quadratic = 2;
  else if (strcasecmp(cline,"quadZ") == 0)
    quadratic = 3;

  Real C = A;
  const RealFunc* f = 0;
  if (linear > 0 && (cline = strtok(nullptr," ")))
  {
    C = Real(1);
    IFEM::cout <<"("<< A <<"*";
    if (linear < 4)
      IFEM::cout << char('W' + linear) <<" + "<< cline <<")";
    else if (linear < 6)
      IFEM::cout << char('W' + linear-3) <<"RotZ("<< cline <<"))";
    switch (linear) {
    case 1:
      f = new LinearXFunc(A,atof(cline));
      break;
    case 2:
      f = new LinearYFunc(A,atof(cline));
      break;
    case 3:
      f = new LinearZFunc(A,atof(cline));
      break;
    case 4:
      f = new LinearRotZFunc(true,A,atof(cline),atof(strtok(nullptr," ")));
      break;
    case 5:
      f = new LinearRotZFunc(false,A,atof(cline),atof(strtok(nullptr," ")));
      break;
    case 6:
      {
        double x0 = atof(cline);
        double x1 = atof(strtok(nullptr," "));
        IFEM::cout <<"StepX("<< x0 <<","<< x1 <<"))";
        f = new StepXFunc(A,x0,x1);
      }
      break;
    case 7:
      {
        double x0 = atof(cline);
        double y0 = atof(strtok(nullptr," "));
        cline = strtok(nullptr," ");
        if (cline && cline[0] == 't')
        {
          double x1 = atof(strtok(nullptr," "));
          double y1 = atof(strtok(nullptr," "));
          IFEM::cout <<"StepXY(["<< x0 <<","<< x1
                     <<"]x["<< y0 <<","<< y1 <<"]))";
          f = new StepXYFunc(A,x1,y1,x0,y0);
        }
        else
        {
          IFEM::cout <<"StepXY([-inf,"<< x0 <<"]x[-inf,"<< y0 <<"]))";
          f = new StepXYFunc(A,x0,y0);
        }
      }
      break;
    case 8:
      {
        int dir = atoi(strtok(nullptr," ")), col = 2;
        IFEM::cout <<"Interpolate1D("<< cline;
        const char* t = strtok(nullptr," ");
        if (t && t[0] == 'c')
        {
          col = atoi(t+1);
          t = strtok(nullptr," ");
          IFEM::cout <<",column #"<< col;
        }
        IFEM::cout <<","<< (char)('X'+dir);
        if (t)
        {
//.........这里部分代码省略.........
开发者ID:TheBB,项目名称:IFEM,代码行数:101,代码来源:Functions.C

示例15: md5File

//MD5文件摘要
MD5VAL md5File(FILE * fpin)
{
	if(!Buffer)
		Buffer=new char[BUFFER_SIZE+64];
	char * buf=Buffer;
	MD5VAL val={0x67452301,0xefcdab89,0x98badcfe,0x10325476};
	unsigned int &a=val.a, &b=val.b, &c=val.c, &d=val.d;
	unsigned int aa,bb,cc,dd;
	unsigned int i,j,count,co;
	unsigned int * x;
	i=0;
	do
	{
		count=fread(buf,1,BUFFER_SIZE,fpin);
		i+=count;
		if(count==BUFFER_SIZE)
			co=BUFFER_SIZE;
		else
		{
			j=count;
			buf[j++]=char(0x80);
			for(j;j%64!=56;j++)
				buf[j]=0x00;
			*(unsigned int *)(buf+j)=i<<3; j+=4;
			*(unsigned int *)(buf+j)=i>>29; j+=4;
			co=j;
		}
		for(j=0;j<co;j+=64)
		{
			x=(unsigned int *)(buf+j);
			// Save the values
			aa=a; bb=b; cc=c; dd=d;
			// Round 1
			FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
			FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
			FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
			FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
			FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
			FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
			FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
			FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
			FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
			FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
			FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
			FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
			FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
			FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
			FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
			FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
			// Round 2
			GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
			GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
			GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
			GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
			GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
			GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
			GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
			GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
			GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
			GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
			GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
			GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
			GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
			GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
			GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
			GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
			// Round 3
			HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
			HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
			HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
			HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
			HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
			HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
			HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
			HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
			HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
			HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
			HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
			HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
			HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
			HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
			HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
			HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
			// Round 4 */
			II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
			II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
			II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
			II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
			II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
			II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
			II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
			II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
			II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
			II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
			II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
			II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
			II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
			II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
			II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
//.........这里部分代码省略.........
开发者ID:colordancer,项目名称:GenOpr,代码行数:101,代码来源:Md5.cpp


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