本文整理汇总了C++中ReadFromFile函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadFromFile函数的具体用法?C++ ReadFromFile怎么用?C++ ReadFromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadFromFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: m_fragmentPath
Shader::Shader(const string vertexPath, const string fragmentPath):m_vertexPath(vertexPath) , m_fragmentPath(fragmentPath)
{
string vertexCode = ReadFromFile(vertexPath.c_str());
string fragmentCode = ReadFromFile(fragmentPath.c_str());
const char* tempChar;
GLuint vertexId;
GLuint fragmentId;
vertexId = glCreateShader(GL_VERTEX_SHADER);
tempChar = vertexCode.c_str();
glShaderSource(vertexId, 1, &tempChar, NULL);
glCompileShader(vertexId);
CheckCompileState(vertexId , GL_COMPILE_STATUS, "VERTEX");
fragmentId = glCreateShader(GL_FRAGMENT_SHADER);
tempChar = fragmentCode.c_str();
glShaderSource(fragmentId, 1, &tempChar, NULL);
glCompileShader(fragmentId);
CheckCompileState(fragmentId, GL_COMPILE_STATUS, "FRAGMENT");
this->m_shaderId = glCreateProgram();
glAttachShader(this->m_shaderId, vertexId);
glAttachShader(this->m_shaderId, fragmentId);
glLinkProgram(this->m_shaderId);
CheckCompileState(m_shaderId, GL_LINK_STATUS, "SHADER_PROGRAM");
glDeleteShader(vertexId);
glDeleteShader(fragmentId);
}
开发者ID:YampoKnaf,项目名称:BaseGameEngine,代码行数:30,代码来源:Shader.cpp
示例2: AG_ReadNotes
std::string AG_ReadNotes( filehandle refNum )
{
// File notes
std::ostringstream notes; notes << "\0";
AXGLONG notes_size = 0;
AXGLONG bytes = sizeof(AXGLONG);
int result = ReadFromFile( refNum, &bytes, ¬es_size );
if ( result )
return notes.str();
#ifdef __LITTLE_ENDIAN__
ByteSwapLong( ¬es_size );
#endif
if (notes_size > 0) {
std::vector< unsigned char > charBuffer( notes_size, '\0' );
result = ReadFromFile( refNum, ¬es_size, &charBuffer[0] );
if ( result )
return notes.str();
// Copy characters one by one into title (tedious but safe)
for (std::size_t nc=1; nc<charBuffer.size(); nc+=2) {
notes << char(charBuffer[nc]);
}
}
return notes.str();
}
开发者ID:410pfeliciano,项目名称:stimfit,代码行数:26,代码来源:AxoGraph_ReadWrite.cpp
示例3: main
int main(int argc, char** argv) {
if (argc != 4) {
std::cout << "usage: RSA_decrypt N PRIVATE_KEY CIPHERTEXT\n";
return 0;
}
for (int i = 1; i < 4; i++) {
if (!FileExists(argv[i])) {
std::cout << "File " << argv[i] << " does not exist.\n";
return 0;
}
}
N = ReadFromFile(argv[1]);
d = ReadFromFile(argv[2]);
std::fstream mfile;
mfile.open(argv[3], std::ios::binary | std::ios::in);
mfile >> len;
std::string output;
m.resize(len);
for (int i = 0; i < len; i++) {
mfile >> m[i];
}
for (int i = 0; i < len; i++) {
output += char(Decrypt(m[i]).get_si());
}
std::cout << output;
return 0;
}
开发者ID:whopper66,项目名称:RSA-C-,代码行数:34,代码来源:RSA_decrypt.cpp
示例4: while
// return is only good thru end of level.
// using fgetc() since it auto-converts CRLF pairs
char *ReadTextFile(char *filename) {
FILE *fp;
char *filestring = NULL;
long int i = 0;
struct stat mstat;
if (stat(filename, &mstat) != 0)
return NULL;
while (true) {
fp = fopen(filename, "rb");
if (!fp) break;
i = ReadFromFile(fp, NULL);
filestring = V_Malloc(i, TAG_LEVEL);
if (!filestring)
break;
fseek(fp, 0, SEEK_SET);
ReadFromFile(fp, filestring);
break;
}
if (fp) fclose(fp);
return(filestring); // return new text
}
开发者ID:emmamai,项目名称:vortex-indy,代码行数:31,代码来源:ents.c
示例5: ReadFromFile
void RunLog::Load()
{
const string& data1 = ReadFromFile( loopsFile );
const string& data2 = ReadFromFile( logFile );
const string& data3 = ReadFromFile( logFile_Stats );
m_Loops->buildVector( data1 );
m_Log->buildLog( data2 );
m_Log->buildLogStats( data3 );
}
开发者ID:Belgiumboy123,项目名称:Run-Log,代码行数:9,代码来源:RunLog.cpp
示例6: InitCheck
/*! Constructs a DefaultCatalog with given signature and language and reads
the catalog from disk.
InitCheck() will be B_OK if catalog could be loaded successfully, it will
give an appropriate error-code otherwise.
*/
DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *language,
uint32 fingerprint)
:
HashMapCatalog("", language, fingerprint)
{
// We created the catalog with an invalid signature, but we fix that now.
SetSignature(catalogOwner);
status_t status;
// search for catalog living in sub-folder of app's folder:
node_ref nref;
nref.device = catalogOwner.device;
nref.node = catalogOwner.directory;
BDirectory appDir(&nref);
BString catalogName("locale/");
catalogName << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
BPath catalogPath(&appDir, catalogName.String());
status = ReadFromFile(catalogPath.Path());
if (status != B_OK) {
// search in data folders
directory_which which[] = {
B_USER_DATA_DIRECTORY,
B_COMMON_DATA_DIRECTORY,
B_SYSTEM_DATA_DIRECTORY
};
for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
BPath path;
if (find_directory(which[i], &path) == B_OK) {
BString catalogName(path.Path());
catalogName << "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
if (status == B_OK)
break;
}
}
}
if (status != B_OK) {
// give lowest priority to catalog embedded as resource in application
// executable, so they can be overridden easily.
status = ReadFromResource(catalogOwner);
}
fInitCheck = status;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:59,代码来源:DefaultCatalog.cpp
示例7: LoadFlat
//======================================
// Load a flat format binary executable
//======================================
void LoadFlat(struct FCB * fHandle)
{
char header[15];
char *location, *temp;
long codelen, datalen, currentPage, size;
int bytesRead, n;
(void) ReadFromFile(fHandle, header, 14);
(void) ReadFromFile(fHandle, (char *) &codelen, 8);
(void) ReadFromFile(fHandle, (char *) &datalen, 8);
// Allocate pages for user code
currentPage = UserCode;
size = codelen;
ClearUserMemory();
while (size > 0)
{
(void) AllocAndCreatePTE(currentPage, currentTask->pid, RW | US | P);
size -= PageSize;
currentPage += PageSize;
}
memcpy((char *) UserCode, (char *) header, 14);
memcpy((char *) UserCode + 14, (char *) &codelen, 8);
memcpy((char *) UserCode + 22, (char *) &datalen, 8);
location = (char *) UserCode + 30;
// Load the user code
(void) ReadFromFile(fHandle, location, codelen - 30);
entrypoint = (void *) UserCode;
// Allocate pages for user data
currentPage = UserData;
size = datalen + sizeof(struct MemStruct);
while (size > 0)
{
(void) AllocAndCreatePTE(currentPage, currentTask->pid, RW | US | P);
size -= PageSize;
currentPage += PageSize;
}
// Load the user data
bytesRead = ReadFromFile(fHandle, (char *) UserData, datalen);
// Zero the rest of the data segment
temp = (char *) (UserData + bytesRead);
while (bytesRead >= PageSize)
bytesRead -= PageSize;
for (n = 0; n < bytesRead; n++)
temp[n] = 0;
currentTask->firstfreemem = UserData + datalen;
}
开发者ID:romeromferr,项目名称:IanOS,代码行数:55,代码来源:newtask.c
示例8: CalcWinsAndLosses
// *CalcWinsAndLosses
void CalcWinsAndLosses()
{
double winScore = 0.0, loseScore = 0.0;
ReadFromFile(iScores);//Read In the File
iWins = iScores[0];//Store iScore at pos [0] in iWins
iLosses = iScores[1];//Store iScore at pos [1] in iLosses
iCntGamesPlayed = iScores[2];//Store iScore at pos [2] in iCntGamesPlayed
if (iCntGamesPlayed > 0)//Only Calc %score if games played > 0
{
winScore = (iWins * 100.00) / iCntGamesPlayed + 0.5;//Calc to get persentage of winScore +0.5 To Round up
loseScore = (iLosses * 100.00) / iCntGamesPlayed + 0.5;//Calc to get persentage of loseScore +0.5 To Round up
}
iScores[3] = (int)winScore; //Store winScore in iScores[3]
iScores[4] = (int)loseScore;//Store loseScore in iScores[4]
iPercentWins = iScores[3];//Store iScore at pos [3] in iPercentWins
iPercentLosses = iScores[4];//Store iScore at pos [4] in iPercentLosses
WriteToFile();//Writing to File
}//End CalcWinsAndLosses()
开发者ID:UnderDev,项目名称:C-Programming,代码行数:26,代码来源:Functions.c
示例9: ReadFromFile
void AuthConfig::RemoveUser()
{
ReadFromFile();
if (m_users.size() == 0)
{
std::cout << "No users to remove." << std::endl << std::endl;
return;
}
PrintUsersList();
std::string userName;
std::cout << "Enter user name to delete:" << std::endl << "> ";
std::getline(std::cin, userName);
auto it = std::find_if(m_users.begin(), m_users.end(), [&](auto user) { return user.Name.compare(userName) == 0; } );
if (it == m_users.end())
{
std::cout << "ERROR: Can't find the user with the entered name." << std::endl << std::endl;
return;
}
std::cout << "Are you sure you want to remove \"" << it->Name << "\" user? [y/n]" << std::endl << "> ";
char key = (char)_getch();
if (key == 'y')
{
m_users.erase(it);
WriteToFile();
std::cout << "User successfully removed." << std::endl << std::endl;
}
else if (key == 'n')
std::cout << "User removal CANCELED." << std::endl << std::endl;
else
std::cout << "Token not recognized. User removal CANCELED." << std::endl << std::endl;
}
开发者ID:dohxehapo,项目名称:NetLib,代码行数:35,代码来源:AuthConfig.cpp
示例10: FindFirstFile
void V2Localisation::ReadFromAllFilesInFolder(const std::string& folderPath)
{
// Get all files in the folder.
std::vector<std::string> fileNames;
WIN32_FIND_DATA findData; // the file data
HANDLE findHandle = FindFirstFile((folderPath + "\\*").c_str(), &findData); // the find handle
if (findHandle == INVALID_HANDLE_VALUE)
{
return;
}
do
{
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
fileNames.push_back(findData.cFileName);
}
} while (FindNextFile(findHandle, &findData) != 0);
FindClose(findHandle);
// Read all these files.
for (const auto& fileName : fileNames)
{
ReadFromFile(folderPath + '\\' + fileName);
}
}
开发者ID:Clonefusion,项目名称:paradoxGameConverters,代码行数:25,代码来源:V2Localisation.cpp
示例11: UnwrapKey
int UnwrapKey(const char *pin, int keyid, const char* filename)
{
uint16 sw1sw2;
uint8 *pWrapped;
int len;
int rc = SC_Open(pin, 0);
if (rc < 0)
return rc;
if (!(1 <= keyid && keyid <= 127)) {
printf("keyid (%d) must be between 1 and 127\n", keyid);
return ERR_INVALID;
}
ReadFromFile(filename, pWrapped, len);
if (pWrapped == NULL) {
printf("file '%s' not found\n", filename);
return ERR_INVALID;
}
if (len <= 0) {
free(pWrapped);
printf("file '%s' empty\n", filename);
return ERR_INVALID;
}
/* - SmartCard-HSM: UNWRAP KEY */
rc = SC_ProcessAPDU(
0, 0x80,0x74,keyid,0x93,
pWrapped, len,
NULL, 0,
&sw1sw2);
free(pWrapped);
SC_Close();
if (rc < 0)
return rc;
return sw1sw2;
}
开发者ID:shearl,项目名称:sc-hsm-embedded,代码行数:34,代码来源:sc-hsm-ultralite-tool.c
示例12: main
int main(){
MGragh<int> intGragh(10);
ReadFromFile("flight.txt", intGragh);
intGragh.PrintNearest(2, 11);
return 0;
/*for(int i = 0; i < 10; ++i){
intGragh.AddNode(i);
}
intGragh.AddEdge(0, 1);
intGragh.AddEdge(0, 2);
intGragh.AddEdge(0, 3);
intGragh.AddEdge(0, 5);
intGragh.AddEdge(0, 6);
intGragh.AddEdge(1, 2);
intGragh.AddEdge(1, 3);
intGragh.AddEdge(3, 9);
intGragh.AddEdge(3, 4);
intGragh.AddEdge(4, 7);
// intGragh.AddEdge(7, 8);
std::cout << intGragh.GetCurrentNodeCount() << std::endl;
std::cout << intGragh.GetEdgeCount() << std::endl;
std::cout << intGragh.GetMaxNodeCount() << std::endl;
intGragh.PrintNearest(0, 7);
// intGragh.DeepOrder(Print);
intGragh.BroadOrder(Print);*/
}
开发者ID:inksmallfrog,项目名称:DataStructur_homework_MGragh,代码行数:27,代码来源:Main.cpp
示例13: GetCurrentProcessId
/**
@param hPrinter Handle to the printer
@return true if loaded the data auccessfully, false if failed to load
*/
bool CCPrintData::LoadProcessData(HANDLE hPrinter)
{
// Get process ID
TCHAR cKeyTime[64], cKeyFile[64];
DWORD dwProcessID = GetCurrentProcessId(), dwTimeKey;
time_t tNow, tKey;
// Clean this data and all the old data
CleanThis();
CleanOldData(hPrinter);
// Check registry for time
_stprintf_s(cKeyTime, _S(cKeyTime), JOBDATA_TIME_KEY, dwProcessID);
if ((dwTimeKey = CCPrintRegistry::GetRegistryDWORD(hPrinter, cKeyTime, 0)) == 0)
// No time, no data
return false;
// Compare times:
tKey = (time_t)dwTimeKey;
tNow = time(NULL);
// Check if time stamp current (up to 5 minutes)
bool bRet = false;
if (difftime(tNow, tKey) < 300)
{
// OK, not too old, read the file name
_stprintf_s(cKeyFile, _S(cKeyFile), JOBDATA_FILE_KEY, dwProcessID);
std::tstring sFilename = CCPrintRegistry::GetRegistryString(hPrinter, cKeyFile, _T(""));
if (!sFilename.empty())
// Found a filename, read the file
bRet = ReadFromFile(sFilename.c_str());
}
return bRet;
}
开发者ID:romain-ortega,项目名称:NanocloudPrinter,代码行数:39,代码来源:CCPrintData.cpp
示例14: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
const int BufferLength = 1024;
char readBuffer[BufferLength] = {0,};
if (false == ReadFromFile("test.json", readBuffer, BufferLength))
return 0;
std::string config_doc = readBuffer;
Json::Value root;
Json::Reader reader;
bool parsingSuccessful = reader.parse( config_doc, root );
if ( !parsingSuccessful )
{
std::cout << "Failed to parse configuration\n"
<< reader.getFormatedErrorMessages();
return 0;
}
std::string encoding = root.get("encoding", "" ).asString();
std::cout << encoding << std::endl;
const Json::Value plugins = root["plug-ins"];
for ( int index = 0; index < plugins.size(); ++index )
{
std::cout << plugins[index].asString() << std::endl;
}
std::cout << root["indent"].get("length", 0).asInt() << std::endl;
std::cout << root["indent"]["use_space"].asBool() << std::endl;
return 0;
}
开发者ID:kyduke,项目名称:study,代码行数:27,代码来源:sample.cpp
示例15: ReadFromFile
void ObjMesh::Init()
{
ReadFromFile(filePath.c_str(), scale_factor);
ComputeNormal();
ApplyTransformation();
ComputeAABB();
}
开发者ID:ziyezhou-Jerry,项目名称:Project3-CUDA-Path-Tracer,代码行数:7,代码来源:mesh.cpp
示例16: ReadSalt
nsresult
ReadSalt(nsIFile* aPath, nsACString& aOutData)
{
return ReadFromFile(aPath, NS_LITERAL_CSTRING("salt"),
aOutData, NodeIdSaltLength);
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:7,代码来源:GMPServiceParent.cpp
示例17: main
int main(){
// 创建客户链表头结点
PCUSTOMER_HEAD head = (PCUSTOMER_HEAD) Create_List(LIST_CUSTOMER_HEAD);
printf("Read data from the file.\n");
// 从文件中读取数据
if (ReadFromFile(head) == TRUE){
printf("Data read success.\n");
}
else{
printf("Data does not exist or read failure.\n");
}
// print_customers(head->customers);
// 显示主界面
view_main(head);
printf("\nSave the data to files.\n");
// 保存数据到文件
if (WriteToFile(head) == TRUE){
printf("Save success.\n");
}
else{
printf("Save failure.\n");
}
printf("\nRelease of lists\n");
// 释放链表
free_all(head);
return 0;
}
开发者ID:SimleCat,项目名称:assignment,代码行数:28,代码来源:main.c
示例18: dlg
void wxExSTCFile::DoFileLoad(bool synced)
{
if (GetContentsChanged())
{
wxExFileDialog dlg(m_STC, this);
if (dlg.ShowModalIfChanged() == wxID_CANCEL) return;
}
// Synchronizing by appending only new data only works for log files.
// Other kind of files might get new data anywhere inside the file,
// we cannot sync that by keeping pos.
// Also only do it for reasonably large files.
ReadFromFile(
synced &&
GetFileName().GetExt().CmpNoCase("log") == 0 &&
m_STC->GetTextLength() > 1024);
m_STC->SetLexer(GetFileName().GetLexer().GetScintillaLexer(), true);
if (!synced)
{
wxLogStatus(_("Opened") + ": " + GetFileName().GetFullPath());
}
m_STC->PropertiesMessage(synced ? STAT_SYNC: STAT_DEFAULT);
// No edges for log files.
if (GetFileName().GetExt() == "log")
{
m_STC->SetEdgeMode(wxSTC_EDGE_NONE);
}
}
开发者ID:hugofvw,项目名称:wxExtension,代码行数:32,代码来源:stcfile.cpp
示例19: ReadFromFile
void CCPULoad::read()
{
unsigned long long totalUser,
totalUserLow,
totalSys,
totalIdle,
totalIowait,
totalIrq,
totalSoftIrq;
ReadFromFile(totalUser,
totalUserLow,
totalSys,
totalIdle,
totalIowait,
totalIrq,
totalSoftIrq);
if (totalUser < m_lastTotalUser ||
totalUserLow < m_lastTotalUserLow ||
totalSys < m_lastTotalSys ||
totalIdle < m_lastTotalIdle ||
totalIowait < m_lastTotalIowait ||
totalIrq < m_lastTotalIrq ||
totalSoftIrq < m_lastTotalSoftIrq
)
{
//Overflow detection. Just skip this value.
}
else
{
double total = (totalUser - m_lastTotalUser) +
(totalUserLow - m_lastTotalUserLow) +
(totalSys - m_lastTotalSys) +
(totalIrq - m_lastTotalIrq) +
(totalSoftIrq - m_lastTotalSoftIrq);
double percent = total;
total = total + (totalIdle - m_lastTotalIdle) +
(totalIowait - m_lastTotalIowait);
if ((total) >0)
{
percent /= total;
percent *= 100;
m_keyword->set (percent);
}
else
{
std::cout << "CPU Load : time too short between execution" << std::endl;
}
}
m_lastTotalUser = totalUser;
m_lastTotalUserLow = totalUserLow;
m_lastTotalSys = totalSys;
m_lastTotalIdle = totalIdle;
m_lastTotalIowait = totalIowait;
m_lastTotalIrq = totalIrq;
m_lastTotalSoftIrq = totalSoftIrq;
}
开发者ID:Yadoms,项目名称:yadoms,代码行数:59,代码来源:CPULoad.cpp
示例20: failed
/********************************************************************************************
> static BOOL GIFUtil::ReadFromFile( CCLexFile *File, LPBITMAPINFO *Info, LPBYTE *Bits,
int *TransColour, int& nBitmapToRead,
String_64 *ProgressString, BaseCamelotFilter *pFilter = NULL )
Author: Neville Humphrys
Created: 29/6/95
Inputs: File A opened CCLexFile that can be read from. It should be positioned at the
start. Caller is responsible for closing it. The file needs to be in
Binary mode.
nBitmapToRead The number of the bitmap in the GIF that you wish to read.
If 1 then the GIF will be read from the beginning obtaining the
header information.
For any number other than 1 it should be noted that bitmaps can only
be read in an incremental sequence and that the first one must have
been read prior to any call with a non-1 value.
ProgressString allows the user to specify whether they require a progress hourglass or
not. If NULL then none is shown, otherwise an progress bar is shown
using the text supplied. Defaults to NULL i.e. no progress bar.
pFilter is an alternative way of handling the progress bar, assume the
progress bar has been start and just call the IncProgressBarCount in
BaseCamelotFilter to do the progress bar update.
Defaults to NULL i.e. no progress bar.
Outputs: Info points to a new LPBITMAPINFO struct and Bits points to the bytes.
These can be freed up with FreeDIB.
TransColour is either -1 == none or equal to the transparency colour found
nBitmapToRead Returns the number of the next bitmap that can be read from the GIF
or -1 if no further bitmaps exist.
Returns: TRUE if worked, FALSE if failed (error will be set accordingly but not reported)
Purpose: Reads a .gif file into memory decompressing it as it goes.
***Errors on 16-bit builds***
A progress hourglass can be shown if required.
Errors: Calls SetError on FALSE returns.
Scope: Static, Public
SeeAlso: DIBUtil::ReadFromFile; AccusoftFilters::ReadFromFile;
********************************************************************************************/
BOOL GIFUtil::ReadFromFile( CCLexFile *File, LPBITMAPINFO *Info, LPBYTE *Bits,
int *TransColour, String_64 *ProgressString,
BaseCamelotFilter *pFilter )
{
int nBitmap = 1;
return (ReadFromFile( File, Info, Bits, TransColour, nBitmap, ProgressString, pFilter));
}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:46,代码来源:gifutil.cpp
注:本文中的ReadFromFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论