コード例 #1
0
    static String parseNameRecord (MemoryInputStream& input, const NameRecord& nameRecord,
                                   const int64 directoryOffset, const int64 offsetOfStringStorage)
    {
        String result;
        const int64 oldPos = input.getPosition();
        input.setPosition (directoryOffset + offsetOfStringStorage + ByteOrder::swapIfLittleEndian (nameRecord.offsetFromStorageArea));
        const int stringLength = (int) ByteOrder::swapIfLittleEndian (nameRecord.stringLength);
        const int platformID = ByteOrder::swapIfLittleEndian (nameRecord.platformID);

        if (platformID == 0 || platformID == 3)
        {
            const int numChars = stringLength / 2 + 1;
            HeapBlock<uint16> buffer;
            buffer.calloc (numChars + 1);
            input.read (buffer, stringLength);

            for (int i = 0; i < numChars; ++i)
                buffer[i] = ByteOrder::swapIfLittleEndian (buffer[i]);

            static_jassert (sizeof (CharPointer_UTF16::CharType) == sizeof (uint16));
            result = CharPointer_UTF16 ((CharPointer_UTF16::CharType*) buffer.getData());
        }
        else
        {
            HeapBlock<char> buffer;
            buffer.calloc (stringLength + 1);
            input.read (buffer, stringLength);
            result = CharPointer_UTF8 (buffer.getData());
        }

        input.setPosition (oldPos);
        return result;
    }
コード例 #2
0
ファイル: juce_Time.cpp プロジェクト: sonic59/JuceS1Text
 int doFTime (CharPointer_UTF32 dest, const size_t maxChars, const String& format, const struct tm* const tm) noexcept
 {
    #if JUCE_ANDROID
     HeapBlock <char> tempDest;
     tempDest.calloc (maxChars + 2);
     const int result = (int) strftime (tempDest, maxChars, format.toUTF8(), tm);
     if (result > 0)
         dest.writeAll (CharPointer_UTF8 (tempDest.getData()));
     return result;
    #elif JUCE_WINDOWS
     HeapBlock <wchar_t> tempDest;
     tempDest.calloc (maxChars + 2);
     const int result = (int) wcsftime (tempDest, maxChars, format.toWideCharPointer(), tm);
     if (result > 0)
         dest.writeAll (CharPointer_UTF16 (tempDest.getData()));
     return result;
    #else
     return (int) wcsftime (dest.getAddress(), maxChars, format.toUTF32(), tm);
    #endif
 }
コード例 #3
0
String JUCE_CALLTYPE Process::getCurrentCommandLineParams()
{
    return CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()),
                                               CharPointer_UTF16 (L" "),
                                               CharPointer_UTF16 (L"\"")).findEndOfWhitespace();
}
コード例 #4
0
ファイル: SPIniReadWrite.cpp プロジェクト: aseryang/WinThread
bool CSPIniReadWrite::loadFromBuffer(byte* pBuffer, uint length)
{
	if (pBuffer)
	{
		delAllSections();

		uint i = 0;
		uint start = 0;
		uint end = 0;

		String strOneLine;				// 一行文本内容
		String strKey;					// 键名
		String strValue;				// 键值
		Section *myPG = nullptr;		// 段的iter
		int squarebrackets_left = -1;	// 左中括号的位置
		int squarebrackets_right = - 1;	// 右中括号的位置
		int equalsymbol = -1;			// 等号的位置

		//unicode16
		if (length >= 2 && pBuffer[0] == 0xFF && pBuffer[1] == 0xFE)
		{
			CharPointer_UTF16::CharType byTemp;
			CharPointer_UTF16::CharType* pTBuffer = (CharPointer_UTF16::CharType*)(pBuffer + 2);
			length = (length - 2)/2;
// 			i = 2;
// 			start = i;
			while (1)
			{
				byTemp = pTBuffer[i];
				if (byTemp != 0 && byTemp != L'\r' && byTemp != L'\n' && i < length)
				{
					i++;
				}
				else
				{
					end = i;
					if (start == end)
					{
						if (byTemp == 0 || i >= length)
						{
							break;
						}
						else
						{
							start = end + 1;
							i = start;
							continue;
						}
					}
					//处理一行数据
					strOneLine = String(CharPointer_UTF16(pTBuffer + start), CharPointer_UTF16(pTBuffer + end)).trim();

					// 判断是否是空行
					if (strOneLine.isEmpty())
					{
						if (byTemp == 0 || i >= length)
						{
							break;
						}
						else
						{
							start = end + 1;
							i = start;
							continue;
						}
					}

					squarebrackets_left = strOneLine.indexOfChar(L'[');
					squarebrackets_right = strOneLine.indexOfChar(L']');

					// 以下处理建
					if ((squarebrackets_left != -1) && (squarebrackets_right != -1) && (squarebrackets_left < squarebrackets_right))
					{
						int equalPos = strOneLine.indexOfChar(L'=');
						if (equalPos == -1 || (equalPos > squarebrackets_left && equalPos < squarebrackets_right))
						{
							strKey = strOneLine.substring(squarebrackets_left + 1, squarebrackets_right);

							myPG = new Section(strKey);
							m_ini.push_back(myPG);

							if (byTemp == 0 || i >= length)
							{
								break;
							}
							else
							{
								start = end + 1;
								i = start;
								continue;
							}
						}
					}

					// 以下处理key
					equalsymbol = strOneLine.indexOfChar(L'=');
					strKey = strOneLine.substring(0, equalsymbol).trim();	// 取得键名

					// 取得键值
					strValue = strOneLine.substring(equalsymbol + 1, strOneLine.length()).trim();

					m_ini.back()->m_tKeys.insert(pair_Key(strKey, strValue));


					if (byTemp == 0 || i >= length)
					{
						break;
					}
					start = end + 1;
					i = start;
				}
			}
		}
		//UTF8
		else if (length >= 3 && pBuffer[0] == 0xEF && pBuffer[1] == 0xBB && pBuffer[2] == 0xBF)
		{
			i = 3;// 要先减去标志位
			start = i;
			CharPointer_UTF8::CharType byTemp;

			while (1)
			{
				byTemp = pBuffer[i];
				if (byTemp != 0 && byTemp != '\r' && byTemp != '\n' && i < length)
				{
					i++;
				}
				else
				{
					end = i;
					if (start == end)
					{
						if (byTemp == 0 || i >= length)
						{
							break;
						}
						else
						{
							start = end + 1;
							i = start;
							continue;
						}
					}
					//处理一行数据
					strOneLine = String(CharPointer_UTF8((CharPointer_UTF8::CharType*)(pBuffer + start)),
						CharPointer_UTF8((CharPointer_UTF8::CharType*)(pBuffer + end))).trim();

					// 判断是否是空行
					if (strOneLine.isEmpty())
					{
						if (byTemp == 0 || i >= length)
						{
							break;
						}
						else
						{
							start = end + 1;
							i = start;
							continue;
						}
					}

					squarebrackets_left = strOneLine.indexOfChar(L'[');
					squarebrackets_right = strOneLine.indexOfChar(L']');

					// 以下处理建
					if ((squarebrackets_left != -1) && (squarebrackets_right != -1) && (squarebrackets_left < squarebrackets_right))
					{
						int equalPos = strOneLine.indexOfChar(L'=');
						if (equalPos == -1 || (equalPos > squarebrackets_left && equalPos < squarebrackets_right))
						{
							strKey = strOneLine.substring(squarebrackets_left + 1, squarebrackets_right);
							myPG = new Section(strKey);
							m_ini.push_back(myPG);

							if (byTemp == 0 || i >= length)
							{
								break;
							}
							else
							{
								start = end + 1;
								i = start;
								continue;
							}
						}
					}

					// 以下处理key
					equalsymbol = strOneLine.indexOfChar(L'=');

					strKey = strOneLine.substring(0, equalsymbol).trim();	// 取得键名

					// 取得键值
					strValue = strOneLine.substring(equalsymbol + 1, strOneLine.length()).trim();

					m_ini.back()->m_tKeys.insert(pair_Key(strKey, strValue));

					if (byTemp == 0 || i >= length)
					{
						break;
					}
					start = end + 1;
					i = start;
				}
			}
		}
		else
		{
			CharPointer_ASCII::CharType byTemp;

			while (1)
			{
				byTemp = pBuffer[i];
				if (byTemp != 0 && byTemp != '\r' && byTemp != '\n' && i < length)
				{
					i++;
				}
				else
				{
					end = i;
					if (start == end)
					{
						if (byTemp == 0 || i >= length)
						{
							break;
						}
						else
						{
							start = end + 1;
							i = start;
							continue;
						}
					}
					//处理一行数据
					strOneLine = String((CharPointer_ASCII::CharType*)(pBuffer + start), end - start).trim();

					// 判断是否是空行
					if (strOneLine.isEmpty())
					{
						if (byTemp == 0 || i >= length)
						{
							break;
						}
						else
						{
							start = end + 1;
							i = start;
							continue;
						}
					}

					squarebrackets_left = strOneLine.indexOfChar(L'[');
					squarebrackets_right = strOneLine.indexOfChar(L']');

					// 以下处理建
					if ((squarebrackets_left != -1) && (squarebrackets_right != -1) && (squarebrackets_left < squarebrackets_right))
					{
						int equalPos = strOneLine.indexOfChar(L'=');
						if (equalPos == -1 || (equalPos > squarebrackets_left && equalPos < squarebrackets_right))
						{
							strKey = strOneLine.substring(squarebrackets_left + 1, squarebrackets_right);
							myPG = new Section(strKey);
							m_ini.push_back(myPG);

							if (byTemp == 0 || i >= length)
							{
								break;
							}
							else
							{
								start = end + 1;
								i = start;
								continue;
							}
						}
					}

					// 以下处理key
					equalsymbol = strOneLine.indexOfChar(L'=');
					if (equalsymbol != -1)
					{
						strKey = strOneLine.substring(0, equalsymbol).trim();	// 取得键名

						// 取得键值
						strValue = strOneLine.substring(equalsymbol + 1, strOneLine.length()).trim();

						m_ini.back()->m_tKeys.insert(pair_Key(strKey, strValue));
					}

					if (byTemp == 0 || i >= length)
					{
						break;
					}
					start = end + 1;
					i = start;
				}
			}
		}

		return true; 
	}
	return false;
}
コード例 #5
0
String JUCE_CALLTYPE JUCEApplicationBase::getCommandLineParameters()
{
    return CharacterFunctions::findEndOfToken (CharPointer_UTF16 (GetCommandLineW()),
                                               CharPointer_UTF16 (L" "),
                                               CharPointer_UTF16 (L"\"")).findEndOfWhitespace();
}