?? utils.hpp
字號(hào):
// (C) Copyright Chrstopher Diggins 2004 http://www.cdiggins.com
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
//
// Disclaimer: Not a Boost library
#ifndef UTILS_HPP_INCLUDED
#define UTILS_HPP_INCLUDED
#include <time.h>
#include <fstream>
#include <iostream>
class TimeIt {
public:
TimeIt() { mnStart = GetTickCount(); };
~TimeIt() { std::cout << "time elapsed (msec): " << GetMSecElapsed() << std::endl; };
int GetMSecElapsed() { return GetTickCount() - mnStart; };
int GetTickCount() { return int(double(clock()) * 1000 / CLOCKS_PER_SEC); };
private:
int mnStart;
};
unsigned int GetFileSize(const char * sFileName) {
std::ifstream f(sFileName, std::ios::binary);
if (!f.good()) { return 0; }
//std::ifstream::pos_type begin_pos = f.tellg();
long begin_pos = f.tellg();
f.seekg(0, std::ios::end);
return f.tellg() - begin_pos;
}
char * AllocFromFile(const char * sFileName) {
unsigned int n = GetFileSize(sFileName);
if (n == 0) return NULL;
char * ret = static_cast < char * > (calloc(n + 1, 1));
if (ret == NULL) return NULL;
std::ifstream f(sFileName, std::ios::binary);
f.read(ret, n);
f.close();
return ret;
}
#endif // UTILS_HPP_INLCUDED
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -