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


C++ BYTE_VECTOR::append方法代码示例

本文整理汇总了C++中BYTE_VECTOR::append方法的典型用法代码示例。如果您正苦于以下问题:C++ BYTE_VECTOR::append方法的具体用法?C++ BYTE_VECTOR::append怎么用?C++ BYTE_VECTOR::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BYTE_VECTOR的用法示例。


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

示例1: GetEncode

int CTortoiseGitBlameData::GetEncode(int *bomoffset)
{
	int encoding = 0;
	BYTE_VECTOR rawAll;
	for (const auto& rawBytes : m_RawLines)
		rawAll.append(rawBytes.data(), rawBytes.size());
	encoding = GetEncode(rawAll.data(), static_cast<int>(rawAll.size()), bomoffset);
	return encoding;
}
开发者ID:TortoiseGit,项目名称:TortoiseGit,代码行数:9,代码来源:TortoiseGitBlameData.cpp

示例2: GetEncode

int CTortoiseGitBlameData::GetEncode(int *bomoffset)
{
	int encoding = 0;
	BYTE_VECTOR rawAll;
	for (auto it = m_RawLines.begin(), it_end = m_RawLines.end(); it != it_end; ++it)
	{
		rawAll.append(&(*it)[0], it->size());
	}
	encoding = GetEncode(&rawAll[0], (int)rawAll.size(), bomoffset);
	return encoding;
}
开发者ID:545546460,项目名称:TortoiseGit,代码行数:11,代码来源:TortoiseGitBlameData.cpp

示例3: GetEncode

int CTortoiseGitBlameData::GetEncode(int *bomoffset)
{
	int encoding = 0;
	BYTE_VECTOR rawAll;
	for (const auto& rawBytes : m_RawLines)
	{
		rawAll.append(&rawBytes[0], rawBytes.size());
	}
	encoding = GetEncode(&rawAll[0], (int)rawAll.size(), bomoffset);
	return encoding;
}
开发者ID:mganss,项目名称:TortoiseGit,代码行数:11,代码来源:TortoiseGitBlameData.cpp

示例4:

	virtual bool	OnOutputData(const BYTE* data, size_t size)
	{
		m_DataCollector.append(data,size);
		while(true)
		{
			// lines from igit.exe are 0 terminated
			int found=m_DataCollector.findData((const BYTE*)"",1);
			if(found<0)
				return false;
			OnSingleLine( (LPCSTR)&*m_DataCollector.begin() );
			m_DataCollector.erase(m_DataCollector.begin(), m_DataCollector.begin()+found+1);
		}
		return false;//Should never reach this
	}
开发者ID:jrk,项目名称:tortoisegit,代码行数:14,代码来源:Git.cpp

示例5: ParseBlameOutput


//.........这里部分代码省略.........
									int numberOfSubsequentLinesBegin = finalLineNumberEnd + 1;
									int numberOfSubsequentLinesEnd = lineEnd;
									numberOfSubsequentLines = atoi(CStringA((LPCSTR)&data[numberOfSubsequentLinesBegin], numberOfSubsequentLinesEnd - numberOfSubsequentLinesBegin));
								}
							}
							else
							{
								// parse error
								finalLineNumber = 0;
								numberOfSubsequentLines = 0;
							}
						}
						else
						{
							// parse error
							finalLineNumber = 0;
							numberOfSubsequentLines = 0;
						}

						auto it = hashToFilename.find(hash);
						if (it != hashToFilename.end())
							filename = it->second;
						else
							filename.Empty();
					}
					else
					{
						// parse error
						finalLineNumber = 0;
						numberOfSubsequentLines = 0;
					}
				}
				else
				{
					int tokenBegin = lineBegin;
					int tokenEnd = data.find(' ', tokenBegin);
					if (tokenEnd >= 0)
					{
						if (!strncmp("filename", (const char*)&data[tokenBegin], tokenEnd - tokenBegin))
						{
							int filenameBegin = tokenEnd + 1;
							int filenameEnd = lineEnd;
							CStringA filenameA = CStringA((LPCSTR)&data[filenameBegin], filenameEnd - filenameBegin);
							filename = UnquoteFilename(filenameA);
							auto r = hashToFilename.insert(std::make_pair(hash, filename));
							if (!r.second)
							{
								r.first->second = filename;
							}
						}
					}
				}
			}
			else
			{
				expectHash = true;
				// remove <TAB> at start
				BYTE_VECTOR line;
				if (lineEnd - 1 > lineBegin)
					line.append(&data[lineBegin + 1], lineEnd-lineBegin - 1);

				hashes.push_back(hash);
				filenames.push_back(filename);
				originalLineNumbers.push_back(originalLineNumber);
				rawLines.push_back(line);
				--numberOfSubsequentLines;
			}
		}
		pos = lineEnd + 1;
	}

	for (auto it = hashes.begin(), it_end = hashes.end(); it != it_end; ++it)
	{
		CGitHash hash = *it;
		CString err;
		GitRev* pRev = GetRevForHash(HashToRev, hash, &err);
		if (pRev)
		{
			authors.push_back(pRev->GetAuthorName());
			dates.push_back(CLoglistUtils::FormatDateAndTime(pRev->GetAuthorDate(), dateFormat, true, bRelativeTimes));
		}
		else
		{
			MessageBox(nullptr, err, _T("TortoiseGit"), MB_ICONERROR);
			authors.push_back(CString());
			dates.push_back(CString());
		}
	}

	m_Hash.swap(hashes);
	m_OriginalLineNumbers.swap(originalLineNumbers);
	m_Filenames.swap(filenames);
	m_RawLines.swap(rawLines);

	m_Authors.swap(authors);
	m_Dates.swap(dates);
	// reset detected and applied encoding
	m_encode = -1;
	m_Utf8Lines.clear();
}
开发者ID:545546460,项目名称:TortoiseGit,代码行数:101,代码来源:TortoiseGitBlameData.cpp

示例6: UpdateEncoding

int CTortoiseGitBlameData::UpdateEncoding(int encode)
{
	int encoding = encode;
	int bomoffset = 0;
	if (encoding==0)
	{
		BYTE_VECTOR all;
		for (auto it = m_RawLines.begin(); it != m_RawLines.end(); ++it)
		{
			if (!it->empty())
				all.append(&(*it)[0], it->size());
		}
		encoding = GetEncode(&all[0], (int)all.size(), &bomoffset);
	}

	if (encoding != m_encode)
	{
		m_encode = encoding;

		m_Utf8Lines.resize(m_RawLines.size());
		for (size_t i_Lines = 0; i_Lines < m_RawLines.size(); ++i_Lines)
		{
			const BYTE_VECTOR& rawLine = m_RawLines[i_Lines];

			int bomoffset = 0;
			CStringA lineUtf8;
			lineUtf8.Empty();

			if (!rawLine.empty())
			{
				if (encoding == 1201)
				{
					CString line;
					int size = (int)((rawLine.size() - bomoffset)/2);
					TCHAR *buffer = line.GetBuffer(size);
					memcpy(buffer, &rawLine[bomoffset], sizeof(TCHAR)*size);
					// swap the bytes to little-endian order to get proper strings in wchar_t format
					wchar_t * pSwapBuf = buffer;
					for (int i = 0; i < size; ++i)
					{
						*pSwapBuf = WideCharSwap2(*pSwapBuf);
						++pSwapBuf;
					}
					line.ReleaseBuffer();

					lineUtf8 = CUnicodeUtils::GetUTF8(line);
				}
				else if (encoding == 1200)
				{
					CString line;
					// the first bomoffset is 2, after that it's 1 (see issue #920)
					// also: don't set bomoffset if called from Encodings menu (i.e. start == 42 and bomoffset == 0); bomoffset gets only set if autodetected
					if (bomoffset == 0 && i_Lines != 0)
					{
						bomoffset = 1;
					}
					int size = (int)((rawLine.size() - bomoffset)/2);
					TCHAR *buffer = line.GetBuffer(size);
					memcpy(buffer, &rawLine[bomoffset], sizeof(TCHAR) * size);
					line.ReleaseBuffer();

					lineUtf8 = CUnicodeUtils::GetUTF8(line);
				}
				else if (encoding == CP_UTF8)
					lineUtf8 = CStringA((LPCSTR)&rawLine[bomoffset], (int)(rawLine.size() - bomoffset));
				else
				{
					CString line = CUnicodeUtils::GetUnicode(CStringA((LPCSTR)&rawLine[bomoffset], (int)(rawLine.size() - bomoffset)), encoding);
					lineUtf8 = CUnicodeUtils::GetUTF8(line);
				}
			}

			m_Utf8Lines[i_Lines] = lineUtf8;
			bomoffset = 0;
		}
	}
	return encoding;
}
开发者ID:545546460,项目名称:TortoiseGit,代码行数:78,代码来源:TortoiseGitBlameData.cpp

示例7: ParseBlameOutput


//.........这里部分代码省略.........
								{
									size_t numberOfSubsequentLinesBegin = finalLineNumberEnd + 1;
									size_t numberOfSubsequentLinesEnd = lineEnd;
									numberOfSubsequentLines = atoi(CStringA(reinterpret_cast<LPCSTR>(&data[numberOfSubsequentLinesBegin]), static_cast<int>(numberOfSubsequentLinesEnd - numberOfSubsequentLinesBegin)));
								}
							}
							else
							{
								// parse error
								numberOfSubsequentLines = 0;
							}
						}
						else
						{
							// parse error
							numberOfSubsequentLines = 0;
						}

						auto it = hashToFilename.find(hash);
						if (it != hashToFilename.end())
							filename = it->second;
						else
							filename.Empty();
					}
					else
					{
						// parse error
						numberOfSubsequentLines = 0;
					}
				}
				else
				{
					size_t tokenBegin = lineBegin;
					size_t tokenEnd = data.find(' ', tokenBegin);
					if (tokenEnd != BYTE_VECTOR::npos)
					{
						if (!strncmp("filename", reinterpret_cast<const char*>(&data[tokenBegin]), tokenEnd - tokenBegin))
						{
							size_t filenameBegin = tokenEnd + 1;
							size_t filenameEnd = lineEnd;
							CStringA filenameA = CStringA(reinterpret_cast<LPCSTR>(&data[filenameBegin]), static_cast<int>(filenameEnd - filenameBegin));
							filename = UnquoteFilename(filenameA);
							auto r = hashToFilename.emplace(hash, filename);
							if (!r.second)
							{
								r.first->second = filename;
							}
						}
					}
				}
			}
			else
			{
				expectHash = true;
				// remove <TAB> at start
				BYTE_VECTOR line;
				if (lineEnd - 1 > lineBegin)
					line.append(&data[lineBegin + 1], lineEnd-lineBegin - 1);

				while (!line.empty() && line[line.size() - 1] == 13)
					line.pop_back();

				hashes.push_back(hash);
				filenames.push_back(filename);
				originalLineNumbers.push_back(originalLineNumber);
				rawLines.push_back(line);
				--numberOfSubsequentLines;
			}
		}
		pos = lineEnd + 1;
	}

	for (const auto& hash2 : hashes)
	{
		CString err;
		GitRev* pRev = GetRevForHash(HashToRev, hash2, &err);
		if (pRev)
		{
			authors.push_back(pRev->GetAuthorName());
			dates.push_back(CLoglistUtils::FormatDateAndTime(pRev->GetAuthorDate(), dateFormat, true, bRelativeTimes));
		}
		else
		{
			MessageBox(nullptr, err, L"TortoiseGit", MB_ICONERROR);
			authors.emplace_back();
			dates.emplace_back();
		}
	}

	m_Hash.swap(hashes);
	m_OriginalLineNumbers.swap(originalLineNumbers);
	m_Filenames.swap(filenames);
	m_RawLines.swap(rawLines);

	m_Authors.swap(authors);
	m_Dates.swap(dates);
	// reset detected and applied encoding
	m_encode = -1;
	m_Utf8Lines.clear();
}
开发者ID:TortoiseGit,项目名称:TortoiseGit,代码行数:101,代码来源:TortoiseGitBlameData.cpp


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