Changeset 303 in pacpusframework
- Timestamp:
- Apr 8, 2014, 11:22:06 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/FileLib/src/DbiteFile.cpp
r292 r303 38 38 typedef int8_t VariableDataSizeT; 39 39 40 DECLARE_STATIC_LOGGER("pacpus.core.DbiteFile") ;40 DECLARE_STATIC_LOGGER("pacpus.core.DbiteFile") 41 41 42 42 namespace pacpus 43 43 { 44 VariableDataSizeTag VariableDataSize;45 ReadModeTag ReadMode;46 WriteModeTag WriteMode;47 DiagnoseModeTag DiagnoseMode;44 VariableDataSizeTag VariableDataSize; 45 ReadModeTag ReadMode; 46 WriteModeTag WriteMode; 47 DiagnoseModeTag DiagnoseMode; 48 48 } 49 49 … … 115 115 LOG_ERROR("Dbite exception: " << e.what()); 116 116 close(); 117 BOOST_THROW_EXCEPTION(DbiteException("cannot open file for reading") 117 BOOST_THROW_EXCEPTION(e 118 //<< "cannot open file for reading" 118 119 << errinfo_file_name(mPath) 119 120 << errinfo_ios_base_open_mode(openmode) … … 128 129 // TODO: readAndDiagnoseHeader(); 129 130 close(); 130 BOOST_THROW_EXCEPTION(DbiteException("cannot read header") 131 BOOST_THROW_EXCEPTION(e 132 //<< "cannot read header" 131 133 << errinfo_nested_exception(copy_exception(e)) 132 134 ); … … 194 196 // TODO: readAndDiagnoseHeader(); 195 197 close(); 196 BOOST_THROW_EXCEPTION(DbiteException("cannot read header")); 198 //BOOST_THROW_EXCEPTION(DbiteException("cannot read header")); 199 throw; 197 200 } 198 201 } else { … … 343 346 checkFileOpen(); 344 347 read((char *)(&mHeader), sizeof(mHeader)); 348 // FIXME: header has good format 345 349 LOG_DEBUG("file: " << getPath()); 346 350 LOG_TRACE("header read:\n" << string(*this)); … … 824 828 string errorMessage = "file is not open"; 825 829 LOG_WARN(errorMessage); 826 BOOST_THROW_EXCEPTION(DbiteException(errorMessage .c_str())830 BOOST_THROW_EXCEPTION(DbiteException(errorMessage) 827 831 << errinfo_file_name(mPath) 832 << errinfo_api_function("open") 828 833 ); 829 834 } -
trunk/src/FileLib/test/TestFileLib.cpp
r301 r303 21 21 #include <Pacpus/kernel/Log.h> 22 22 23 #include <boost/exception/diagnostic_information.hpp> 24 #include <boost/exception/errinfo_api_function.hpp> 25 #include <boost/exception/get_error_info.hpp> 23 26 #include <boost/noncopyable.hpp> 24 27 #include <cstdio> 25 28 26 DECLARE_STATIC_LOGGER("pacpus.framework.test.FileLib") ;29 DECLARE_STATIC_LOGGER("pacpus.framework.test.FileLib") 27 30 28 31 using namespace boost; … … 31 34 32 35 struct HasExceptionMessage 33 36 : noncopyable 34 37 { 35 38 HasExceptionMessage(const string expectedMessage) … … 48 51 }; 49 52 53 template < 54 typename ErrorInfo, 55 typename E = typename ErrorInfo::error_info::value_type 56 > 57 struct HasErrorInfo 58 : noncopyable 59 { 60 HasErrorInfo(E const& expectedValue) 61 : mExpectedValue(expectedValue) 62 { 63 } 64 65 bool operator()(DbiteException const& ex) 66 { 67 LOG_INFO("diagnostic_information: " << diagnostic_information(ex)); 68 E const* value = get_error_info<ErrorInfo>(ex); 69 if (!value) { 70 return false; 71 } 72 return mExpectedValue == *value; 73 } 74 75 private: 76 E const mExpectedValue; 77 }; 78 50 79 BOOST_AUTO_TEST_SUITE(suiteBasic) 51 80 … … 150 179 (df.open("data/bad-empty-file.dbt", ReadMode)) 151 180 , DbiteException 152 , HasExceptionMessage("cannot read header") 181 // , HasExceptionMessage("cannot read data") // FIXME: cannot read header 182 , HasErrorInfo<errinfo_api_function>("open") 153 183 ); 154 184 } … … 164 194 (df.open("data/bad-incomplete-header.dbt", ReadMode)) 165 195 , DbiteException 166 , HasExceptionMessage("cannot read header")196 , HasExceptionMessage("cannot read data") // FIXME: cannot read header 167 197 ); 168 198 } -
trunk/src/PacpusLib/ColorSeverityFormatter.hpp
r301 r303 18 18 #if defined(PACPUS_LOG_COLORED_OUTPUT) 19 19 20 #include <Pacpus/predef/os.h> 21 20 22 #include <boost/assert.hpp> 21 23 #include <boost/log/attributes/attribute_name.hpp> … … 28 30 #include <string> 29 31 30 // could use Boost.Predef with Boost >= 1.55 31 #if defined(WIN32) || defined(_WINDOWS) 32 # define PACPUS_OS_WINDOWS 1 33 #elif defined(__unix) || defined(__unix__) 34 # define PACPUS_OS_UNIX 1 35 # if defined(__linux) || defined(__linux__) 36 # define PACPUS_OS_LINUX 1 37 # endif 38 #elif defined(__APPLE__) || defined(__MACH__) || defined(Macintosh) || defined(macintosh) 39 # define PACPUS_OS_MACOS 1 40 #else 41 // unknown system 42 #endif 43 44 #if defined(PACPUS_OS_WINDOWS) 32 #if PACPUS_OS_WINDOWS 45 33 # include <Windows.h> 46 34 #endif … … 73 61 } 74 62 75 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)63 #if PACPUS_OS_WINDOWS 76 64 77 65 // Returns the character attribute for the given color. … … 134 122 } 135 123 136 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)124 #endif // PACPUS_OS_WINDOWS 137 125 138 126 bool shouldUseColor(bool stdoutIsTty) 139 127 { 140 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)128 #if PACPUS_OS_WINDOWS // && !PACPUS_OS_WINDOWS_MOBILE 141 129 return true; 142 130 #else … … 150 138 || (term == "cygwin"); 151 139 return stdoutIsTty && termSupportsColor; 152 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)140 #endif // PACPUS_OS_WINDOWS 153 141 } 154 142 … … 157 145 { 158 146 ColorFormatter() 159 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)147 #if PACPUS_OS_WINDOWS 160 148 : mStreamHandle(GetStdHandle(STD_OUTPUT_HANDLE)) 161 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)149 #endif // PACPUS_OS_WINDOWS 162 150 { 163 151 mShouldUseColor = shouldUseColor(/*stdoutIsTty*/ true); … … 169 157 return; 170 158 } 171 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)159 #if PACPUS_OS_WINDOWS 172 160 // Gets the current text color. 173 161 CONSOLE_SCREEN_BUFFER_INFO bufferInfo; … … 182 170 #else 183 171 strm << getAnsiColorCode(getColor(sev)).c_str(); 184 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)172 #endif // PACPUS_OS_WINDOWS 185 173 } 186 174 187 175 bool mShouldUseColor; 188 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)176 #if PACPUS_OS_WINDOWS 189 177 const HANDLE mStreamHandle; 190 178 WORD mSavedConsoleBufferInfo; 191 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)179 #endif // PACPUS_OS_WINDOWS 192 180 }; 193 181 … … 196 184 { 197 185 DefaultFormatter() 198 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)186 #if PACPUS_OS_WINDOWS 199 187 //DefaultFormatter(WORD savedConsoleBufferInfo) 200 188 : mStreamHandle(GetStdHandle(STD_OUTPUT_HANDLE)) 201 189 //, mSavedConsoleBufferInfo(savedConsoleBufferInfo) 202 190 , mSavedConsoleBufferInfo(getColorAttribute(COLOR_WHITE)) // FIXME: restore old value, not just reset 203 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)191 #endif // PACPUS_OS_WINDOWS 204 192 { 205 193 mShouldUseColor = shouldUseColor(/*stdoutIsTty*/ true); … … 211 199 return; 212 200 } 213 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)201 #if PACPUS_OS_WINDOWS 214 202 fflush(stdout); 215 203 // Restores the text color. … … 217 205 #else 218 206 strm << getAnsiColorCodeRestoreDefault().c_str(); 219 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)207 #endif // PACPUS_OS_WINDOWS 220 208 } 221 209 222 210 bool mShouldUseColor; 223 #if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)211 #if PACPUS_OS_WINDOWS 224 212 const HANDLE mStreamHandle; 225 213 WORD mSavedConsoleBufferInfo; 226 #endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)214 #endif // PACPUS_OS_WINDOWS 227 215 }; 228 216 … … 273 261 { 274 262 if (restoreDefault) { 275 //#if defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)263 //#if PACPUS_OS_WINDOWS 276 264 // m_formatter = formatter_function_type(DefaultFormatter<char_type>()); 277 //#else // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)265 //#else // PACPUS_OS_WINDOWS 278 266 m_formatter = formatter_function_type(DefaultFormatter<char_type>()); 279 //#endif // defined(PACPUS_OS_WINDOWS) && !defined(PACPUS_OS_WINDOWS_MOBILE)267 //#endif // PACPUS_OS_WINDOWS 280 268 } else { 281 269 m_formatter = formatter_function_type(ColorFormatter<char_type>()); -
trunk/src/PacpusTools/src/SharedMemory.cpp
r300 r303 17 17 #endif 18 18 19 DECLARE_STATIC_LOGGER("pacpus.framwork.SharedMemory") ;19 DECLARE_STATIC_LOGGER("pacpus.framwork.SharedMemory") 20 20 21 21 using namespace pacpus;
Note:
See TracChangeset
for help on using the changeset viewer.