forked from mia/Aegisub
Re-work types.h for the second time, this is most likely not the final version, it's difficult to figure out a solution that makes the most sense when most of the code hasn't been written/moved over yet.
Originally committed to SVN as r4468.
This commit is contained in:
parent
9a3e1c58f0
commit
ea577f8245
5 changed files with 29 additions and 11 deletions
|
@ -20,11 +20,11 @@
|
|||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libaegisub/log.h"
|
||||
#include "libaegisub/mutex.h"
|
||||
#include "libaegisub/types.h"
|
||||
#include "libaegisub/util.h"
|
||||
|
||||
namespace agi {
|
||||
|
@ -38,7 +38,7 @@ LogSink *log = new LogSink();
|
|||
const char *Severity_ID = "EAWID";
|
||||
|
||||
SinkMessage::SinkMessage(const char *section, Severity severity, const char *file,
|
||||
const char *func, int line, timeval tv):
|
||||
const char *func, int line, agi_timeval tv):
|
||||
section(section),
|
||||
severity(severity),
|
||||
file(file),
|
||||
|
@ -109,7 +109,7 @@ Message::Message(const char *section,
|
|||
len(1024) {
|
||||
buf = new char[len];
|
||||
msg = new std::ostrstream(buf, len);
|
||||
timeval tv;
|
||||
agi_timeval tv;
|
||||
util::time_log(tv);
|
||||
sm = new SinkMessage(section, severity, file, func, line, tv);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ struct SinkMessage {
|
|||
/// @param line Source line
|
||||
/// @param tv Log time
|
||||
SinkMessage(const char *section, Severity severity, const char *file,
|
||||
const char *func, int line, timeval tv);
|
||||
const char *func, int line, agi_timeval tv);
|
||||
|
||||
// Destructor
|
||||
~SinkMessage();
|
||||
|
@ -88,7 +88,7 @@ struct SinkMessage {
|
|||
const char *file; ///< Source file
|
||||
const char *func; ///< Function name
|
||||
int line; ///< Source line
|
||||
timeval tv; ///< Time at execution
|
||||
agi_timeval tv; ///< Time at execution
|
||||
char *message; ///< Formatted message
|
||||
size_t len; ///< Message length
|
||||
};
|
||||
|
|
|
@ -21,6 +21,15 @@
|
|||
#ifndef LAGI_PRE
|
||||
#endif // LAGI_PRE
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <time.h>
|
||||
|
||||
#else // Unix / OSX
|
||||
#include <sys/time.h>
|
||||
|
||||
#endif // if _WIN32
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace agi {
|
||||
|
@ -61,3 +70,14 @@ typedef struct tm {
|
|||
|
||||
} // namespace type
|
||||
} // namespace agi
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
typedef agi::type::win::timeval agi_timeval;
|
||||
|
||||
#else // Unix / OSX
|
||||
|
||||
typedef timeval agi_timeval;
|
||||
|
||||
#endif // if _WIN32
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace agi {
|
|||
|
||||
const std::string DirName(const std::string& path);
|
||||
void Rename(const std::string& from, const std::string& to);
|
||||
void time_log(timeval &tv);
|
||||
void time_log(agi_timeval &tv);
|
||||
|
||||
} // namespace util
|
||||
} // namespace agi
|
||||
|
|
|
@ -25,13 +25,11 @@
|
|||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include <time.h>
|
||||
#include <windows.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include "libaegisub/types.h"
|
||||
#include <libaegisub/charset_conv_win.h>
|
||||
#include "libaegisub/charset_conv_win.h"
|
||||
#include "libaegisub/util.h"
|
||||
#include "libaegisub/util_win.h"
|
||||
|
||||
|
@ -74,9 +72,9 @@ std::string ErrorString(DWORD error) {
|
|||
}
|
||||
|
||||
/// @brief Get seconds and microseconds.
|
||||
/// @param tv[out] timeval struct
|
||||
/// @param tv[out] agi_timeval struct
|
||||
/// This code is from http://www.suacommunity.com/dictionary/gettimeofday-entry.php
|
||||
void time_log(type::win::timeval &tv) {
|
||||
void time_log(agi_timeval &tv) {
|
||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue