• R/O
  • SSH
  • HTTPS

iris-fmw: Commit


Commit MetaInfo

Revision96 (tree)
Time2011-01-24 17:51:21
Authorshirayanagi

Log Message

duration 追加中
iml 修正
リファクタリング

Change Summary

Incremental Difference

--- trunk/framework/sample/Windows/test/VS2008/iml_test/test_iml_ratio.cpp (revision 95)
+++ trunk/framework/sample/Windows/test/VS2008/iml_test/test_iml_ratio.cpp (revision 96)
@@ -95,6 +95,14 @@
9595 ASSERT_EQ( -11, ratio12::num );
9696 ASSERT_EQ( 500, ratio12::den );
9797 }
98+
99+ {
100+ typedef iml::ratio< 0, 300>::type ratio1;
101+ typedef iml::ratio< 33, 255>::type ratio2;
102+ typedef iml::ratio_multiply<ratio1, ratio2>::type ratio12;
103+ ASSERT_EQ( 0, ratio12::num );
104+ ASSERT_EQ( 1, ratio12::den );
105+ }
98106 }
99107
100108 TEST(iml_ratioTest, divide)
@@ -129,3 +137,88 @@
129137 ASSERT_FALSE( (iml::ratio_not_equal< iml::ratio<1, 100>, iml::ratio<2, 200>::type >::value) );
130138 ASSERT_TRUE ( (iml::ratio_not_equal< iml::ratio<3, 200>, iml::ratio<2, 200>::type >::value) );
131139 }
140+
141+TEST(iml_ratioTest, less)
142+{
143+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio< 0, 5>, iml::ratio<12, 5>::type >::value) );
144+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio< 1, 5>, iml::ratio<12, 5>::type >::value) );
145+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio<-8, 5>, iml::ratio<-1, 5>::type >::value) );
146+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio< 1, 5>, iml::ratio< 2, 5>::type >::value) );
147+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio<-2, 5>, iml::ratio< 2, 5>::type >::value) );
148+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio<-2, 5>, iml::ratio<-1, 5>::type >::value) );
149+ ASSERT_TRUE ( (iml::ratio_less< iml::ratio< 1, 3>, iml::ratio<11, 5>::type >::value) );
150+
151+ ASSERT_FALSE( (iml::ratio_less< iml::ratio< 2, 5>, iml::ratio< 2, 5>::type >::value) );
152+ ASSERT_FALSE( (iml::ratio_less< iml::ratio<-2, 5>, iml::ratio<-2, 5>::type >::value) );
153+
154+ ASSERT_FALSE( (iml::ratio_less< iml::ratio<12, 5>, iml::ratio< 0, 5>::type >::value) );
155+ ASSERT_FALSE( (iml::ratio_less< iml::ratio<12, 5>, iml::ratio< 1, 5>::type >::value) );
156+ ASSERT_FALSE( (iml::ratio_less< iml::ratio<-1, 5>, iml::ratio<-9, 5>::type >::value) );
157+ ASSERT_FALSE( (iml::ratio_less< iml::ratio< 3, 5>, iml::ratio< 2, 5>::type >::value) );
158+ ASSERT_FALSE( (iml::ratio_less< iml::ratio< 2, 5>, iml::ratio<-2, 5>::type >::value) );
159+ ASSERT_FALSE( (iml::ratio_less< iml::ratio<-2, 5>, iml::ratio<-3, 5>::type >::value) );
160+}
161+
162+TEST(iml_ratioTest, less_equal)
163+{
164+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio< 0, 5>, iml::ratio<12, 5>::type >::value) );
165+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio< 1, 5>, iml::ratio<12, 5>::type >::value) );
166+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio<-8, 5>, iml::ratio<-1, 5>::type >::value) );
167+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio< 1, 5>, iml::ratio< 2, 5>::type >::value) );
168+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio<-2, 5>, iml::ratio< 2, 5>::type >::value) );
169+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio<-2, 5>, iml::ratio<-1, 5>::type >::value) );
170+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio< 1, 3>, iml::ratio<11, 5>::type >::value) );
171+
172+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio< 2, 5>, iml::ratio< 2, 5>::type >::value) );
173+ ASSERT_TRUE ( (iml::ratio_less_equal< iml::ratio<-2, 5>, iml::ratio<-2, 5>::type >::value) );
174+
175+ ASSERT_FALSE( (iml::ratio_less_equal< iml::ratio<12, 5>, iml::ratio< 0, 5>::type >::value) );
176+ ASSERT_FALSE( (iml::ratio_less_equal< iml::ratio<12, 5>, iml::ratio< 1, 5>::type >::value) );
177+ ASSERT_FALSE( (iml::ratio_less_equal< iml::ratio<-1, 5>, iml::ratio<-9, 5>::type >::value) );
178+ ASSERT_FALSE( (iml::ratio_less_equal< iml::ratio< 3, 5>, iml::ratio< 2, 5>::type >::value) );
179+ ASSERT_FALSE( (iml::ratio_less_equal< iml::ratio< 2, 5>, iml::ratio<-2, 5>::type >::value) );
180+ ASSERT_FALSE( (iml::ratio_less_equal< iml::ratio<-2, 5>, iml::ratio<-3, 5>::type >::value) );
181+}
182+
183+TEST(iml_ratioTest, greater)
184+{
185+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio< 0, 5>, iml::ratio<12, 5>::type >::value) );
186+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio< 1, 5>, iml::ratio<12, 5>::type >::value) );
187+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio<-8, 5>, iml::ratio<-1, 5>::type >::value) );
188+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio< 1, 5>, iml::ratio< 2, 5>::type >::value) );
189+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio<-2, 5>, iml::ratio< 2, 5>::type >::value) );
190+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio<-2, 5>, iml::ratio<-1, 5>::type >::value) );
191+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio< 1, 3>, iml::ratio<11, 5>::type >::value) );
192+
193+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio< 2, 5>, iml::ratio< 2, 5>::type >::value) );
194+ ASSERT_FALSE( (iml::ratio_greater< iml::ratio<-2, 5>, iml::ratio<-2, 5>::type >::value) );
195+
196+ ASSERT_TRUE ( (iml::ratio_greater< iml::ratio<12, 5>, iml::ratio< 0, 5>::type >::value) );
197+ ASSERT_TRUE ( (iml::ratio_greater< iml::ratio<12, 5>, iml::ratio< 1, 5>::type >::value) );
198+ ASSERT_TRUE ( (iml::ratio_greater< iml::ratio<-1, 5>, iml::ratio<-9, 5>::type >::value) );
199+ ASSERT_TRUE ( (iml::ratio_greater< iml::ratio< 3, 5>, iml::ratio< 2, 5>::type >::value) );
200+ ASSERT_TRUE ( (iml::ratio_greater< iml::ratio< 2, 5>, iml::ratio<-2, 5>::type >::value) );
201+ ASSERT_TRUE ( (iml::ratio_greater< iml::ratio<-2, 5>, iml::ratio<-3, 5>::type >::value) );
202+}
203+
204+TEST(iml_ratioTest, greater_equal)
205+{
206+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio< 0, 5>, iml::ratio<12, 5>::type >::value) );
207+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio< 1, 5>, iml::ratio<12, 5>::type >::value) );
208+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio<-8, 5>, iml::ratio<-1, 5>::type >::value) );
209+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio< 1, 5>, iml::ratio< 2, 5>::type >::value) );
210+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio<-2, 5>, iml::ratio< 2, 5>::type >::value) );
211+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio<-2, 5>, iml::ratio<-1, 5>::type >::value) );
212+ ASSERT_FALSE( (iml::ratio_greater_equal< iml::ratio< 1, 3>, iml::ratio<11, 5>::type >::value) );
213+
214+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio< 2, 5>, iml::ratio< 2, 5>::type >::value) );
215+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio<-2, 5>, iml::ratio<-2, 5>::type >::value) );
216+
217+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio<12, 5>, iml::ratio< 0, 5>::type >::value) );
218+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio<12, 5>, iml::ratio< 1, 5>::type >::value) );
219+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio<-1, 5>, iml::ratio<-9, 5>::type >::value) );
220+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio< 3, 5>, iml::ratio< 2, 5>::type >::value) );
221+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio< 2, 5>, iml::ratio<-2, 5>::type >::value) );
222+ ASSERT_TRUE ( (iml::ratio_greater_equal< iml::ratio<-2, 5>, iml::ratio<-3, 5>::type >::value) );
223+}
224+
--- trunk/framework/sample/Windows/test/VS2008/container_test/test_duration.cpp (nonexistent)
+++ trunk/framework/sample/Windows/test/VS2008/container_test/test_duration.cpp (revision 96)
@@ -0,0 +1,54 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file test_duration.cpp
5+ * @brief FndDuration テスト ファイル
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2010 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#define _FILE_test_duration_CPP_
18+
19+//======================================================================
20+// include
21+#include "unit/gt/gt_inchead.h"
22+#include "fnd/container/FndDuration.h"
23+#include "iris_using.h"
24+#include "iris_iostream.h"
25+
26+TEST(FndDurationTest, Func)
27+{
28+ CDuration<int, iml::mega> d(100);
29+
30+ ASSERT_EQ( 100, d.count() );
31+ ASSERT_EQ( 101, (++d).count() );
32+ ASSERT_EQ( 101, (d++).count() );
33+ ASSERT_EQ( 102, d.count() );
34+
35+ ASSERT_EQ( 101, (--d).count() );
36+ ASSERT_EQ( 101, (d--).count() );
37+ ASSERT_EQ( 100, d.count() );
38+
39+ ASSERT_EQ( 200, (d*2).count() );
40+ ASSERT_EQ( 50, (d/2).count() );
41+ ASSERT_EQ( 1, (d%9).count() );
42+
43+ d *= 2;
44+ ASSERT_EQ( 200, d.count() );
45+ d /= 2;
46+ ASSERT_EQ( 100, d.count() );
47+ d %= 9;
48+ ASSERT_EQ( 1, d.count() );
49+ d = CDuration<int, iml::mega>(100);
50+ ASSERT_EQ( 100, d.count() );
51+ d %= CDuration<int, iml::mega>(9);
52+ ASSERT_EQ( 1, d.count() );
53+}
54+
--- trunk/framework/sample/Windows/test/VS2008/windows/registry/test_privateprofile.cpp (nonexistent)
+++ trunk/framework/sample/Windows/test/VS2008/windows/registry/test_privateprofile.cpp (revision 96)
@@ -0,0 +1,76 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file test_privateprofile.cpp
5+ * @brief privateprofile テストファイル
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2010 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#define _FILE_test_privateprofile_CPP_
18+
19+//======================================================================
20+// include
21+#include "unit/gt/gt_inchead.h"
22+#include "platform/windows/win/registry/WXPrivateProfile.h"
23+#include "iris_using.h"
24+#include <tchar.h>
25+
26+TEST(WXPrivateProfileTest, WriteRead)
27+{
28+ // wirte
29+ {
30+ CPrivateProfile pp;
31+ pp.Open(TEXT(".\\test.ini"));
32+
33+ ASSERT_TRUE( pp.WriteSection(TEXT("TEST"), TEXT("SECTION=0")) );
34+
35+ ASSERT_TRUE( pp.WriteString(TEXT("TEST"), TEXT("TEXT"), TEXT("test文字列123")) );
36+ ASSERT_TRUE( pp.WriteInt(TEXT("TEST"), TEXT("INT"), 345) );
37+ ASSERT_TRUE( pp.WriteFloat(TEXT("TEST"), TEXT("FLOAT"), 1.2345678f) );
38+ ASSERT_TRUE( pp.WriteHex(TEXT("TEST"), TEXT("HEX"), 0xABCDEF01) );
39+ }
40+ // read
41+ {
42+ CPrivateProfile pp;
43+ pp.Open(TEXT(".\\test.ini"));
44+
45+ TCHAR name[256];
46+ ASSERT_EQ( 5, pp.GetSectionNames(name, 256) );
47+ ASSERT_TRUE( pp.GetSection(TEXT("TEST"), name, 256) );
48+
49+ ASSERT_TRUE( pp.GetString(TEXT("TEST"), TEXT("TEXT"), TEXT("FAILED"), name, 256) );
50+ ASSERT_STREQ( TEXT("test文字列123"), name );
51+ ASSERT_EQ( 345, pp.GetInt(TEXT("TEST"), TEXT("INT"), 0) );
52+ ASSERT_FLOAT_EQ( 1.2345678f, pp.GetFloat(TEXT("TEST"), TEXT("FLOAT"), 0.0f) );
53+ ASSERT_EQ( 0xABCDEF01, pp.GetHex(TEXT("TEST"), TEXT("HEX"), 0x0) );
54+ }
55+ // remove
56+ {
57+ CPrivateProfile pp;
58+ pp.Open(TEXT(".\\test.ini"));
59+
60+ ASSERT_TRUE( pp.RemoveKey(TEXT("TEST"), TEXT("INT")) );
61+
62+ TCHAR name[256];
63+ ASSERT_EQ( 5, pp.GetSectionNames(name, 256) );
64+ ASSERT_TRUE( pp.GetSection(TEXT("TEST"), name, 256) );
65+
66+ ASSERT_TRUE( pp.GetString(TEXT("TEST"), TEXT("TEXT"), TEXT("FAILED"), name, 256) );
67+ ASSERT_STREQ( TEXT("test文字列123"), name );
68+ ASSERT_EQ( 0, pp.GetInt(TEXT("TEST"), TEXT("INT"), 0) );
69+ ASSERT_FLOAT_EQ( 1.2345678f, pp.GetFloat(TEXT("TEST"), TEXT("FLOAT"), 0.0f) );
70+ ASSERT_EQ( 0xABCDEF01, pp.GetHex(TEXT("TEST"), TEXT("HEX"), 0x0) );
71+
72+ pp.Remove();
73+ ASSERT_EQ( 0, pp.GetSectionNames(name, 256) );
74+ }
75+}
76+
--- trunk/framework/sample/Windows/test/VS2008/device_test/test_hid.cpp (revision 95)
+++ trunk/framework/sample/Windows/test/VS2008/device_test/test_hid.cpp (revision 96)
@@ -35,8 +35,8 @@
3535 , nullptr, OPEN_EXISTING, 0, nullptr) )
3636 {
3737 CScopedLastError err;
38- CErrorString es(err);
39- _putts(es);
38+ CLastError es(err);
39+ _putts(es.ToString());
4040 return;
4141 }
4242
--- trunk/framework/sample/Windows/test/VS2008/debugclass_test/test_lasterror.cpp (revision 95)
+++ trunk/framework/sample/Windows/test/VS2008/debugclass_test/test_lasterror.cpp (revision 96)
@@ -23,18 +23,38 @@
2323 #include <tchar.h>
2424 #include "iris_using.h"
2525
26-TEST(LastErrorTest, Func)
26+TEST(LastErrorTest, ToString)
2727 {
28- ASSERT_EQ( NULL, SetClipboardData( CF_UNICODETEXT, nullptr ) );
28+ {
29+ CLastError es(ERROR_SUCCESS);
30+ ASSERT_STREQ( TEXT("この操作を正しく終了しました。\r\n"), es.ToString() );
31+ }
32+ {
33+ CLastError es(ERROR_OPEN_FAILED);
34+ ASSERT_STREQ( TEXT("指定されたデバイスまたはファイルを開けません。\r\n"), es.ToString() );
35+ }
36+}
2937
30- DWORD error = GetLastError();
38+TEST(LastErrorTest, Scoped)
39+{
40+ LASTERROR error = GetLastError();
3141
3242 {
3343 CScopedLastError le;
34- SetLastError(0);
35- CErrorString es(le);
44+ SetLastError(99);
45+ CLastError es(le);
3646
37- _putts(es);
47+ {
48+ CScopedLastError le2;
49+ ASSERT_EQ( 99, le2 );
50+
51+ SetLastError(1);
52+ }
53+
54+ CLastError es2;
55+ ASSERT_EQ( 99, es2() );
56+
57+ std::cout << es.ToStringA() << std::endl;
3858 }
3959
4060 ASSERT_EQ( error, GetLastError() );
--- trunk/framework/src/c++0x/cpp0x_nullptr.h (revision 95)
+++ trunk/framework/src/c++0x/cpp0x_nullptr.h (revision 96)
@@ -85,3 +85,18 @@
8585 #endif
8686
8787 #endif
88+
89+/**
90+ * @section autoexp
91+ * @code
92+;------------------------------------------------------------------------------
93+; nullptr_t
94+;------------------------------------------------------------------------------
95+nullptr_t {
96+ preview
97+ (
98+ 0
99+ )
100+}
101+ * @endcode
102+*/
--- trunk/framework/src/c++0x/type_traits/cpp0x_trivial_traits.hpp (revision 95)
+++ trunk/framework/src/c++0x/type_traits/cpp0x_trivial_traits.hpp (revision 96)
@@ -44,9 +44,9 @@
4444 class has_trivial_copy
4545 {
4646 public:
47- enum { value = iml::op_and< iml::iml_or< is_pod<_TN>::value
47+ enum { value = iml::op_and< iml::op_or< is_pod<_TN>::value
4848 , IRIS_HAS_TRIVIAL_COPY(_TN) >::value
49- , iml::iml_not< is_volatile<_TN>::value >::value
49+ , iml::op_not< is_volatile<_TN>::value >::value
5050 >::value };
5151 };
5252
@@ -55,10 +55,10 @@
5555 class has_trivial_assign
5656 {
5757 public:
58- enum { value = iml::op_and< iml::iml_or< is_pod<_TN>::value
58+ enum { value = iml::op_and< iml::op_or< is_pod<_TN>::value
5959 , IRIS_HAS_TRIVIAL_ASSIGN(_TN) >::value
60- , iml::iml_not< is_const<_TN>::value >::value
61- , iml::iml_not< is_volatile<_TN>::value >::value
60+ , iml::op_not< is_const<_TN>::value >::value
61+ , iml::op_not< is_volatile<_TN>::value >::value
6262 >::value };
6363 };
6464
--- trunk/framework/src/c++0x/cpp0x_static_assert.h (revision 95)
+++ trunk/framework/src/c++0x/cpp0x_static_assert.h (revision 96)
@@ -27,7 +27,8 @@
2727 # define STATIC_ASSERT( B ) static_assert( B, "" )
2828 #else
2929
30-namespace cpp0x
30+namespace cpp0x {
31+namespace detail
3132 {
3233 //================================================================================
3334 // template
@@ -40,6 +41,7 @@
4041 // HP aCC cannot deal with missing names for template value parameters
4142 template<int x> struct static_assert_test{};
4243
44+} // end of namespace detail
4345 } // end of namespace cpp0x
4446
4547 //================================================================================
@@ -51,13 +53,13 @@
5153 #ifndef IRIS_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS
5254
5355 # define static_assert( B ) \
54- typedef ::cpp0x::static_assert_test< sizeof(::cpp0x::STATIC_ASSERTION_FAILURE< (bool)( B ) >) > IRIS_PP_CAT(iris_static_assert_typedef_, __LINE__)
56+ typedef ::cpp0x::detail::static_assert_test< sizeof(::cpp0x::detail::STATIC_ASSERTION_FAILURE< (bool)( B ) >) > IRIS_PP_CAT(iris_static_assert_typedef_, __LINE__)
5557
5658 #else
5759
5860 // alternative enum based implementation:
5961 # define static_assert( B ) \
60- enum { IRIS_PP_CAT(iris_static_assert_enum_, __LINE__) = sizeof(::cpp0x::STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
62+ enum { IRIS_PP_CAT(iris_static_assert_enum_, __LINE__) = sizeof(::cpp0x::detail::STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
6163
6264 #endif
6365
--- trunk/framework/src/iris_stdint.h (revision 95)
+++ trunk/framework/src/iris_stdint.h (revision 96)
@@ -6,6 +6,11 @@
66 *
77 * @author t.sirayanagi
88 * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2010-2011 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
914 */
1015 //-----------------------------------------------------------------------
1116 //======================================================================
@@ -14,12 +19,16 @@
1419
1520 //======================================================================
1621 // include
22+#if !defined(__STDC_CONSTANT_MACROS)
23+# define __STDC_CONSTANT_MACROS // iris では定義する
24+#endif
25+
1726 #include "iris_compiler.h"
1827 #include "iris_limits.h"
1928
2029 #if !defined(_STDINT_H) && !defined(__stdint_h)
2130
22-#ifdef _IRIS_HAS_C99_H
31+#if defined(_IRIS_HAS_C99_H)
2332 # include <stdint.h>
2433 #else
2534
@@ -153,25 +162,25 @@
153162 #endif
154163
155164 #if defined(__STDC_CONSTANT_MACROS)
156-# define INT8_C(c) c
165+# define INT8_C(c) c
157166 # define UINT8_C(c) IRIS_PP_CAT(c, U)
158167 # define INT16_C(c) c
159168 # define UINT16_C(c) IRIS_PP_CAT(c, U)
160169 # if (ULONG_MAX == 0xFFFFFFFF)
161-# define INT32_C(c) IRIS_PP_CAT(c, L)
162-# define UINT32_C(c) IRIS_PP_CAT(c, UL)
170+# define INT32_C(c) IRIS_PP_CAT(c, L)
171+# define UINT32_C(c) IRIS_PP_CAT(c, UL)
163172 # elif (UINT_MAX = 0xFFFFFFFF)
164-# define INT32_C(c) c
165-# define UINT32_C(c) IRIS_PP_CAT(c, U)
173+# define INT32_C(c) c
174+# define UINT32_C(c) IRIS_PP_CAT(c, U)
166175 # else
167176 # error iris not support
168177 # endif
169178 # if !defined(_IRIS_NOT_SUPPORT_LLONG) && (ULLONG_MAX == 0xffffffffffffffffULL)
170-# define INT64_C(c) IRIS_PP_CAT(c, LL)
171-# define UINT64_C(c) IRIS_PP_CAT(c, ULL)
179+# define INT64_C(c) IRIS_PP_CAT(c, LL)
180+# define UINT64_C(c) IRIS_PP_CAT(c, ULL)
172181 # if !defined(_IRIS_SUPPORT_INT128)
173182 # define INTMAX_C(c) INT64_C(c)
174-# define UINTMAX_C(c) UINT64_C(c)
183+# define UINTMAX_C(c) UINT64_C(c)
175184 # endif
176185 # elif (ULONG_MAX != 0xFFFFFFFF)
177186 # if (ULONG_MAX == 18446744073709551615)
@@ -178,7 +187,7 @@
178187 # define INT64_C(c) IRIS_PP_CAT(c, L)
179188 # define UINT64_C(c) IRIS_PP_CAT(c, UL)
180189 # if !defined(_IRIS_SUPPORT_INT128)
181-# define INTMAX_C(c) INT64_C(c)
190+# define INTMAX_C(c) INT64_C(c)
182191 # define UINTMAX_C(c) UINT64_C(c)
183192 # endif
184193 # else
@@ -185,8 +194,8 @@
185194 # error iris not support
186195 # endif
187196 # elif defined(IRIS_BORLANDC) || defined(IRIS_MSC)
188-# define INT64_C(c) IRIS_PP_CAT(c, i64)
189-# define UINT64_C(c) IRIS_PP_CAT(c, ui64)
197+# define INT64_C(c) IRIS_PP_CAT(c, i64)
198+# define UINT64_C(c) IRIS_PP_CAT(c, ui64)
190199 # if !defined(_IRIS_SUPPORT_INT128)
191200 # define INTMAX_C(c) INT64_C(c)
192201 # define UINTMAX_C(c) UINT64_C(c)
@@ -209,10 +218,77 @@
209218
210219 #endif
211220
212-#endif
221+#endif // stdint
213222
214223 //----------------------------------------
215224 // for iris
225+// CONSTANT_MACROS が定義されていない場合
226+#if !defined(__STDC_CONSTANT_MACROS)
227+# define IRIS_INT8_C(c) c
228+# define IRIS_UINT8_C(c) IRIS_PP_CAT(c, U)
229+# define IRIS_INT16_C(c) c
230+# define IRIS_UINT16_C(c) IRIS_PP_CAT(c, U)
231+# if (ULONG_MAX == 0xFFFFFFFF)
232+# define IRIS_INT32_C(c) IRIS_PP_CAT(c, L)
233+# define IRIS_UINT32_C(c) IRIS_PP_CAT(c, UL)
234+# elif (UINT_MAX = 0xFFFFFFFF)
235+# define IRIS_INT32_C(c) c
236+# define IRIS_UINT32_C(c) IRIS_PP_CAT(c, U)
237+# else
238+# error iris not support
239+# endif
240+# if !defined(_IRIS_NOT_SUPPORT_LLONG) && (ULLONG_MAX == 0xffffffffffffffffULL)
241+# define IRIS_INT64_C(c) IRIS_PP_CAT(c, LL)
242+# define IRIS_UINT64_C(c) IRIS_PP_CAT(c, ULL)
243+# if !defined(_IRIS_SUPPORT_INT128)
244+# define IRIS_INTMAX_C(c) IRIS_INT64_C(c)
245+# define IRIS_UINTMAX_C(c) IRIS_UINT64_C(c)
246+# endif
247+# elif (ULONG_MAX != 0xFFFFFFFF)
248+# if (ULONG_MAX == 18446744073709551615)
249+# define IRIS_INT64_C(c) IRIS_PP_CAT(c, L)
250+# define IRIS_UINT64_C(c) IRIS_PP_CAT(c, UL)
251+# if !defined(_IRIS_SUPPORT_INT128)
252+# define IRIS_INTMAX_C(c) IRIS_INT64_C(c)
253+# define IRIS_UINTMAX_C(c) IRIS_UINT64_C(c)
254+# endif
255+# else
256+# error iris not support
257+# endif
258+# elif defined(IRIS_BORLANDC) || defined(IRIS_MSC)
259+# define IRIS_INT64_C(c) IRIS_PP_CAT(c, i64)
260+# define IRIS_UINT64_C(c) IRIS_PP_CAT(c, ui64)
261+# if !defined(_IRIS_SUPPORT_INT128)
262+# define IRIS_INTMAX_C(c) IRIS_INT64_C(c)
263+# define IRIS_UINTMAX_C(c) IRIS_UINT64_C(c)
264+# endif
265+# else
266+# define IRIS_INT64_C(c) c
267+# define IRIS_UINT64_C(c) c
268+# if !defined(_IRIS_SUPPORT_INT128)
269+# define IRIS_INTMAX_C(c) IRIS_INT32_C(c)
270+# define IRIS_UINTMAX_C(c) IRIS_UINT32_C(c)
271+# endif
272+# endif
273+# if defined(_IRIS_SUPPORT_INT128)
274+# define IRIS_INT128_C(c) IRIS_PP_CAT(c, i128)
275+# define IRIS_UINT128_C(c) IRIS_PP_CAT(c, ui128)
276+# define IRIS_INTMAX_C(c) IRIS_INT128_C(c)
277+# define IRIS_UINTMAX_C(c) IRIS_UINT128_C(c)
278+# endif
279+#else
280+# define IRIS_INT8_C(c) INT8_C(c)
281+# define IRIS_UINT8_C(c) UINT8_C(c)
282+# define IRIS_INT16_C(c) INT16_C(c)
283+# define IRIS_UINT16_C(c) UINT16_C(c)
284+# define IRIS_INT32_C(c) INT32_C(c)
285+# define IRIS_UINT32_C(c) UINT32_C(c)
286+# define IRIS_INT64_C(c) INT64_C(c)
287+# define IRIS_UINT64_C(c) UINT64_C(c)
288+# define IRIS_INTMAX_C(c) INTMAX_C(c)
289+# define IRIS_UINTMAX_C(c) UINTMAX_C(c)
290+#endif
291+
216292 // 定数マクロ
217293 #define S8_C(c) c
218294 #define S16_C(c) c
--- trunk/framework/src/platform/windows/d3dx/mobile/math/DMXMath.h (revision 95)
+++ trunk/framework/src/platform/windows/d3dx/mobile/math/DMXMath.h (revision 96)
@@ -31,9 +31,7 @@
3131
3232 #define D3DXMatrixTranslation D3DMXMatrixTranslation
3333 #define D3DXMatrixRotationQuaternion
34-#define D3DXMatrixLookAtLH D3DMXMatrixLookAtLHFxd
3534 #define D3DXMatrixPerspectiveFovLH D3DMXMatrixPerspectiveFovLHFxd
36-#define D3DXMatrixRotationYawPitchRoll D3DMXMatrixRotationYawPitchRollFxd
3735
3836 #define D3DXQuaternionSlerp
3937
@@ -86,6 +84,16 @@
8684 STATICINLINE D3DMXMATRIX* D3DXMatrixIdentity(D3DMXMATRIX *pOut) { return D3DMXMatrixIdentity(pOut); }
8785 STATICINLINE D3DMXMATRIXFXD* D3DXMatrixIdentity(D3DMXMATRIXFXD *pOut) { return D3DMXMatrixIdentityFxd(pOut); }
8886
87+STATICINLINE D3DMXMATRIX* D3DXMatrixLookAtLH(D3DMXMATRIX* pOut, CONST D3DMXVECTOR3 *pEye
88+ , CONST D3DMXVECTOR3 *pAt, CONST D3DMXVECTOR3 *pUp) { return D3DMXMatrixLookAtLH(pOut, pEye, pAt, pUp); }
89+STATICINLINE D3DMXMATRIXFXD* D3DXMatrixLookAtLH(D3DMXMATRIXFXD* pOut, CONST D3DMXVECTOR3FXD *pEye
90+ , CONST D3DMXVECTOR3FXD *pAt, CONST D3DMXVECTOR3FXD *pUp) { return D3DMXMatrixLookAtLHFxd(pOut, pEye, pAt, pUp); }
91+
92+STATICINLINE D3DMXMATRIX* D3DXMatrixRotationYawPitchRoll(D3DMXMATRIX *pOut
93+ , FLOAT Yaw, FLOAT Pitch, FLOAT Roll) { return D3DMXMatrixRotationYawPitchRoll(pOut, Yaw, Pitch, Roll); }
94+STATICINLINE D3DMXMATRIXFXD* D3DXMatrixRotationYawPitchRoll(D3DMXMATRIXFXD *pOut
95+ , FIXED Yaw, FIXED Pitch, FIXED Roll) { return D3DMXMatrixRotationYawPitchRollFxd(pOut, Yaw, Pitch, Roll); }
96+
8997 #endif
9098
9199 #endif
--- trunk/framework/src/platform/windows/win/app/WXWindow.cpp (revision 95)
+++ trunk/framework/src/platform/windows/win/app/WXWindow.cpp (revision 96)
@@ -503,8 +503,8 @@
503503 DWORD error = GetLastError();
504504 if( error != 0 )
505505 {
506- CErrorString err_str;
507- IRIS_WARNING(err_str.GetErrorStringA(error));
506+ CLastError es(error);
507+ IRIS_WARNING(es.ToStringA());
508508 }
509509 IRIS_WARNING("CreateWindowEx failed.");
510510 #endif
@@ -560,11 +560,11 @@
560560 if( hWnd == nullptr )
561561 {
562562 #ifdef _IRIS_DEBUG
563- DWORD error = GetLastError();
564- if( error != 0 )
563+ CScopedLastError scoped_le;
564+ if( scoped_le != 0 )
565565 {
566- CErrorString err_str;
567- IRIS_WARNING(err_str.GetErrorStringA(error));
566+ CLastError err_str(scoped_le);
567+ IRIS_WARNING(err_str.ToString());
568568 }
569569 IRIS_WARNING("CreateWindowEx failed.");
570570 #endif
@@ -904,26 +904,25 @@
904904 {
905905 #ifdef _IRIS_DEBUG
906906 std::_tstring t;
907- DWORD error = GetLastError();
907+ LASTERROR error = GetLastError();
908908 if( error != 0 )
909909 {
910- CErrorString err_msg;
910+ CLastError err_msg(error);
911911 TCHAR err_str[32];
912912 wsprintf(err_str, IRIS_TEXT("%x : "), error);
913- err_msg.GetErrorString(error);
914913 if( text != nullptr )
915914 {
916915 t = text;
917916 t += IRIS_TEXT("\n");
918917 t += err_str;
919- t += err_msg;
918+ t += err_msg.ToString();
920919 }
921920 else
922921 {
923922 t = err_str;
924- t += err_msg;
923+ t += err_msg.ToString();
925924 }
926- dprintf((LPCTSTR)err_msg);
925+ dprintf(err_msg.ToString());
927926 }
928927 return MessageBox(t.c_str(), cap, uType);
929928 #else
--- trunk/framework/src/platform/windows/win/os/WXModule.cpp (revision 95)
+++ trunk/framework/src/platform/windows/win/os/WXModule.cpp (revision 96)
@@ -74,9 +74,9 @@
7474 if( hModule == nullptr )
7575 {
7676 #ifdef _IRIS_DEBUG
77- CErrorString es;
78- es.GetErrorString(CScopedLastError());
79- _tprintf(es.GetErrorString());
77+ CScopedLastError sle;
78+ CLastError le(sle);
79+ _tprintf(le.ToString());
8080 #endif
8181 return FALSE;
8282 }
@@ -94,9 +94,9 @@
9494 if( hModule == nullptr )
9595 {
9696 #ifdef _IRIS_DEBUG
97- CErrorString es;
98- es.GetErrorString(CScopedLastError());
99- _tprintf(es.GetErrorString());
97+ CScopedLastError sle;
98+ CLastError le(sle);
99+ _tprintf(le.ToString());
100100 #endif
101101 return FALSE;
102102 }
--- trunk/framework/src/platform/windows/win/container/WXLiberator.h (nonexistent)
+++ trunk/framework/src/platform/windows/win/container/WXLiberator.h (revision 96)
@@ -0,0 +1,53 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file WXLiberator.h
5+ * @brief ポインタ解放基本クラスファイル
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2011 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#ifndef _IRIS_WXLiberator_H_
18+#define _IRIS_WXLiberator_H_
19+
20+//======================================================================
21+// include
22+#include "fnd/container/FndLiberator.h"
23+
24+namespace iris {
25+namespace wx
26+{
27+
28+//======================================================================
29+// class
30+//! ポインタ解放基本クラス
31+class CLocalMemLiberator : public fnd::CLiberator
32+{
33+public:
34+ /// コンストラクタ
35+ CLocalMemLiberator(value_ptr p=nullptr) : fnd::CLiberator(p) {}
36+public:
37+ /// 解放関数
38+ void liberate( void )
39+ {
40+ if( m_ptr != nullptr )
41+ {
42+ LocalFree(m_ptr);
43+ m_ptr = nullptr;
44+ }
45+ }
46+};
47+
48+
49+} // end of namespace wx
50+} // end of namespace iris
51+
52+#endif
53+
--- trunk/framework/src/platform/windows/win/image/WXBitmap.cpp (revision 95)
+++ trunk/framework/src/platform/windows/win/image/WXBitmap.cpp (revision 96)
@@ -74,9 +74,8 @@
7474 if( ret == 0 )
7575 {
7676 CScopedLastError e;
77- CErrorString es;
78- es.GetErrorStringA(e);
79- printf("%d, %s\n", ret, es.GetErrorStringA());
77+ CLastError le(e);
78+ printf("%d, %s\n", ret, le.ToStringA());
8079 }
8180 }
8281
--- trunk/framework/src/platform/windows/win/exp/plugin/WXPlugin.cpp (revision 95)
+++ trunk/framework/src/platform/windows/win/exp/plugin/WXPlugin.cpp (revision 96)
@@ -115,9 +115,9 @@
115115 if( CreateInstance == nullptr )
116116 {
117117 #ifdef _IRIS_DEBUG
118- CErrorString es;
119- es.GetErrorString(CScopedLastError());
120- _tprintf(es.GetErrorString());
118+ CLastError es(0);
119+ es = CScopedLastError();
120+ _tprintf(es.ToString());
121121 #endif
122122 return 0;
123123 }
@@ -164,9 +164,9 @@
164164 if( DeleteInstance == nullptr )
165165 {
166166 #ifdef _IRIS_DEBUG
167- CErrorString es;
168- es.GetErrorString(CScopedLastError());
169- _tprintf(es.GetErrorString());
167+ CLastError es(0);
168+ es = CScopedLastError();
169+ _tprintf(es.ToString());
170170 #endif
171171 IRIS_WARNING("GetProcAddress \"DeletePluginInstance\" was failed.");
172172 DeleteInstance = DefaultDeletePluginInstance;
--- trunk/framework/src/platform/windows/win/shell/dialog/WXSHBrowseFolder.cpp (revision 95)
+++ trunk/framework/src/platform/windows/win/shell/dialog/WXSHBrowseFolder.cpp (revision 96)
@@ -24,7 +24,7 @@
2424 //======================================================================
2525 // function
2626 #if (_WIN32_IE < 0x0601)
27-static void SHFree(ITEMIDLIST* pidl)
27+static void SHFree(LPITEMIDLIST pidl)
2828 {
2929 IMalloc* pMalloc;
3030 SHGetMalloc( &pMalloc );
--- trunk/framework/src/platform/windows/win/registry/WXProfile.cpp (revision 95)
+++ trunk/framework/src/platform/windows/win/registry/WXProfile.cpp (nonexistent)
@@ -1,518 +0,0 @@
1-//======================================================================
2-//-----------------------------------------------------------------------
3-/**
4- * @file WXProfile.cpp
5- * @brief Profileクラス
6- *
7- * @author t.sirayanagi
8- * @version 1.0
9- *
10- * @par copyright
11- * Copyright (C) 2009-2011 Takazumi Shirayanagi\n
12- * The new BSD License is applied to this software.
13- * see iris_LICENSE.txt
14-*/
15-//-----------------------------------------------------------------------
16-//======================================================================
17-#define _IRIS_WXProfile_CPP_
18-
19-//======================================================================
20-// include
21-#include "WXProfile.h"
22-#include "iris_debug.h"
23-#include <tchar.h>
24-
25-#include "../debug/WXDebugLeakCheckMacro.h"
26-
27-namespace iris {
28-namespace wx
29-{
30-
31-//======================================================================
32-// function
33-
34-/**********************************************************************//**
35- *
36- * 初期化ファイルに整数値を書き込み
37- *
38- -----------------------------------------------------------------------
39- * @param [in] lpAppName = セクション名
40- * @param [in] lpKeyName = キー名
41- * @param [in] nValue = キー値
42- * @param [in] lpFileName = ファイル名
43- * @return 成否
44-*//***********************************************************************/
45-BOOL WritePrivateProfileIntA(LPCSTR lpAppName, LPCSTR lpKeyName, UINT nValue, LPCSTR lpFileName)
46-{
47- CHAR val[128];
48- wsprintfA(val, "%d", nValue);
49- return WritePrivateProfileStringA(lpAppName, lpKeyName, val, lpFileName);
50-}
51-/// iris::wx::WritePrivateProfileIntA 参照
52-BOOL WritePrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, UINT nValue, LPCWSTR lpFileName)
53-{
54- WCHAR val[128];
55- wsprintfW(val, L"%d", nValue);
56- return WritePrivateProfileStringW(lpAppName, lpKeyName, val, lpFileName);
57-}
58-
59-/**********************************************************************//**
60- *
61- * 初期化ファイルに整数値(HEX)を書き込み
62- *
63- -----------------------------------------------------------------------
64- * @param [in] lpAppName = セクション名
65- * @param [in] lpKeyName = キー名
66- * @param [in] nValue = キー値
67- * @param [in] lpFileName = ファイル名
68- * @return 成否
69-*//***********************************************************************/
70-BOOL WritePrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nValue, LPCSTR lpFileName)
71-{
72- CHAR val[128];
73- wsprintfA(val, "0x%x", nValue);
74- return WritePrivateProfileStringA(lpAppName, lpKeyName, val, lpFileName);
75-}
76-/// iris::wx::WritePrivateProfileHexA 参照
77-BOOL WritePrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nValue, LPCWSTR lpFileName)
78-{
79- WCHAR val[128];
80- wsprintfW(val, L"0x%x", nValue);
81- return WritePrivateProfileStringW(lpAppName, lpKeyName, val, lpFileName);
82-}
83-
84-/**********************************************************************//**
85- *
86- * 初期化ファイルから整数値(HEX)を取得
87- *
88- -----------------------------------------------------------------------
89- * @param [in] lpAppName = セクション名
90- * @param [in] lpKeyName = キー名
91- * @param [in] nDefault = デフォルト値
92- * @param [in] lpFileName = ファイル名
93- * @return 値
94-*//***********************************************************************/
95-DWORD GetPrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nDefault, LPCSTR lpFileName)
96-{
97- CHAR val[128], def[128];
98- wsprintfA(def, "%x", nDefault);
99- DWORD size = GetPrivateProfileStringA(lpAppName, lpKeyName, def, val, 128, lpFileName);
100- LPSTR p = nullptr;
101- DWORD ret = (DWORD)strtol(val, &p, 16);
102- if( ret == 0 && p == val ) return nDefault;
103- return ret;
104-}
105-/// iris::wx::GetPrivateProfileHexA 参照
106-DWORD GetPrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nDefault, LPCWSTR lpFileName)
107-{
108- WCHAR val[128], def[128];
109- wsprintfW(def, L"%x", nDefault);
110- DWORD size = GetPrivateProfileStringW(lpAppName, lpKeyName, def, val, 128, lpFileName);
111- LPWSTR p = nullptr;
112- DWORD ret = (DWORD)wcstol(val, &p, 16);
113- if( ret == 0 && p == val ) return nDefault;
114- return ret;
115-}
116-
117-/**********************************************************************//**
118- *
119- * 初期化ファイルに小数値を書き込み
120- *
121- -----------------------------------------------------------------------
122- * @param [in] lpAppName = セクション名
123- * @param [in] lpKeyName = キー名
124- * @param [in] fValue = キー値
125- * @param [in] lpFileName = ファイル名
126- * @return 成否
127-*//***********************************************************************/
128-BOOL WritePrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fValue, LPCSTR lpFileName)
129-{
130- CHAR val[128];
131- wsprintfA(val, "%f", fValue);
132- return WritePrivateProfileStringA(lpAppName, lpKeyName, val, lpFileName);
133-}
134-/// iris::wx::WritePrivateProfileFloatA 参照
135-BOOL WritePrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fValue, LPCWSTR lpFileName)
136-{
137- WCHAR val[128];
138- wsprintfW(val, L"%f", fValue);
139- return WritePrivateProfileStringW(lpAppName, lpKeyName, val, lpFileName);
140-}
141-
142-/**********************************************************************//**
143- *
144- * 初期化ファイルから小数値を取得
145- *
146- -----------------------------------------------------------------------
147- * @param [in] lpAppName = セクション名
148- * @param [in] lpKeyName = キー名
149- * @param [in] fDefault = 失敗したときに返す値
150- * @param [in] lpFileName = ファイル名
151- * @return 小数値
152-*//***********************************************************************/
153-float GetPrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fDefault, LPCSTR lpFileName)
154-{
155- CHAR val[128], def[128];
156- wsprintfA(def, "%f", fDefault);
157- GetPrivateProfileStringA(lpAppName, lpKeyName, def, val, 128, lpFileName);
158- float ret = (float)atof(val);
159- return ret;
160-}
161-/// iris::wx::GetPrivateProfileFloatA 参照
162-float GetPrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fDefault, LPCWSTR lpFileName)
163-{
164- WCHAR val[128], def[128];
165- wsprintfW(def, L"%f", fDefault);
166- GetPrivateProfileStringW(lpAppName, lpKeyName, def, val, 128, lpFileName);
167- float ret = (float)_wtof(val);
168- return ret;
169-}
170-
171-/**********************************************************************//**
172- *
173- * 初期化ファイルにWINDOWPLACEMENTを書き込み
174- *
175- -----------------------------------------------------------------------
176- * @param [in] lpAppName = セクション名
177- * @param [in] lpKeyName = キー名
178- * @param [in] hWnd = ウィンドウハンドル
179- * @param [in] lpFileName = ファイル名
180- * @return 成否
181-*//***********************************************************************/
182-BOOL WritePrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName)
183-{
184- WINDOWPLACEMENT wndpl;
185- if( GetWindowPlacement(hWnd, &wndpl) == 0 ) return 0;
186- return WritePrivateProfileStructA(lpAppName, lpKeyName, &wndpl, sizeof(wndpl), lpFileName);
187-}
188-/// iris::wx::WritePrivateProfileWindowPlacementA 参照
189-BOOL WritePrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName)
190-{
191- WINDOWPLACEMENT wndpl;
192- if( GetWindowPlacement(hWnd, &wndpl) == 0 ) return 0;
193- return WritePrivateProfileStructW(lpAppName, lpKeyName, &wndpl, sizeof(wndpl), lpFileName);
194-}
195-
196-/**********************************************************************//**
197- *
198- * 初期化ファイルからWINDOWPLACEMENTを取得
199- *
200- -----------------------------------------------------------------------
201- * @param [in] lpAppName = セクション名
202- * @param [in] lpKeyName = キー名
203- * @param [in] lpwdpl = 出力
204- * @param [in] lpFileName = ファイル名
205- * @return 成否
206-*//***********************************************************************/
207-BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCSTR lpFileName)
208-{
209- return GetPrivateProfileStructA(lpAppName, lpKeyName, lpwdpl, sizeof(WINDOWPLACEMENT), lpFileName);
210-}
211-/// iris::wx::GetPrivateProfileWindowPlacementA 参照
212-BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCWSTR lpFileName)
213-{
214- return GetPrivateProfileStructW(lpAppName, lpKeyName, lpwdpl, sizeof(WINDOWPLACEMENT), lpFileName);
215-}
216-
217-/**********************************************************************//**
218- *
219- * 初期化ファイルからWINDOWPLACEMENTを取得
220- *
221- -----------------------------------------------------------------------
222- * @param [in] lpAppName = セクション名
223- * @param [in] lpKeyName = キー名
224- * @param [in] hWnd = 出力先ハンドル
225- * @param [in] lpFileName = ファイル名
226- * @return 成否
227-*//***********************************************************************/
228-BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName)
229-{
230- WINDOWPLACEMENT wndpl;
231- if( !GetPrivateProfileStructA(lpAppName, lpKeyName, &wndpl, sizeof(WINDOWPLACEMENT), lpFileName) )
232- return FALSE;
233- SetWindowPlacement(hWnd, &wndpl);
234- return TRUE;
235-}
236-/// iris::wx::GetPrivateProfileWindowPlacementA 参照
237-BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName)
238-{
239- WINDOWPLACEMENT wndpl;
240- if( !GetPrivateProfileStructW(lpAppName, lpKeyName, &wndpl, sizeof(WINDOWPLACEMENT), lpFileName) )
241- return FALSE;
242- SetWindowPlacement(hWnd, &wndpl);
243- return TRUE;
244-}
245-
246-//======================================================================
247-// class
248-/**********************************************************************//**
249- *
250- * コンストラクタ
251- *
252-*//***********************************************************************/
253-CPrivateProfile::CPrivateProfile(void)
254-{
255- m_Path[0] = IRIS_TEXT('\0');
256-}
257-
258-/**********************************************************************//**
259- *
260- * デストラクタ
261- *
262-*//***********************************************************************/
263-CPrivateProfile::~CPrivateProfile(void)
264-{
265- Close();
266-}
267-
268-/**********************************************************************//**
269- *
270- * 開く
271- *
272- -----------------------------------------------------------------------
273- * @param [in] path = パス
274-*//***********************************************************************/
275-void CPrivateProfile::Open(LPCTSTR path)
276-{
277- Close();
278- _tcscpy_s(m_Path, MAX_PATH, path);
279-}
280-
281-/**********************************************************************//**
282- *
283- * 閉じる
284- *
285-*//***********************************************************************/
286-void CPrivateProfile::Close(void)
287-{
288- ZeroMemory(m_Path, sizeof(m_Path));
289-}
290-
291-/**********************************************************************//**
292- *
293- * 存在するセクション名を取得
294- *
295- -----------------------------------------------------------------------
296- * @param [out] lpReturn = 出力バッファ(キー名は'\0'区切りで出力される)
297- * @param [in] nSize = 出力バッファサイズ
298- * @return
299-*//***********************************************************************/
300-DWORD CPrivateProfile::GetSectionNames(LPTSTR lpReturn, DWORD nSize) const
301-{
302- return GetPrivateProfileSectionNames(lpReturn, nSize, m_Path);
303-}
304-
305-/**********************************************************************//**
306- *
307- * セクションに存在するキー名を取得
308- *
309- -----------------------------------------------------------------------
310- * @param [in] lpAppName = セクション名
311- * @param [out] lpReturn = 出力バッファ(キー名は'\0'区切りで出力される)
312- * @param [in] nSize = 出力バッファサイズ
313- * @return
314-*//***********************************************************************/
315-DWORD CPrivateProfile::GetSection(LPCTSTR lpAppName, LPTSTR lpReturn, DWORD nSize) const
316-{
317- return GetPrivateProfileSection(lpAppName, lpReturn, nSize, m_Path);
318-}
319-
320-/**********************************************************************//**
321- *
322- * 初期化ファイルから文字列を取得
323- *
324- -----------------------------------------------------------------------
325- * @param [in] lpAppName = セクション名
326- * @param [in] lpKeyName = キー名
327- * @param [in] lpDefault = 失敗したときに返す文字列
328- * @param [out] lpReturn = 出力バッファ(キー名は'='区切りで出力される)
329- * @param [in] nSize = 出力バッファサイズ
330- * @return
331-*//***********************************************************************/
332-DWORD CPrivateProfile::GetString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturn, DWORD nSize) const
333-{
334- return GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpReturn, nSize, m_Path);
335-}
336-
337-/**********************************************************************//**
338- *
339- * 初期化ファイルから整数値を取得
340- *
341- -----------------------------------------------------------------------
342- * @param [in] lpAppName = セクション名
343- * @param [in] lpKeyName = キー名
344- * @param [in] nDefault = 失敗したときに返す値
345- * @return 整数値
346-*//***********************************************************************/
347-UINT CPrivateProfile::GetInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nDefault) const
348-{
349- return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault, m_Path);
350-}
351-
352-/**********************************************************************//**
353- *
354- * 初期化ファイルから小数値を取得
355- *
356- -----------------------------------------------------------------------
357- * @param [in] lpAppName = セクション名
358- * @param [in] lpKeyName = キー名
359- * @param [in] fDefault = 失敗したときに返す値
360- * @return 小数値
361-*//***********************************************************************/
362-float CPrivateProfile::GetFloat(LPCTSTR lpAppName, LPCTSTR lpKeyName, float fDefault) const
363-{
364- return GetPrivateProfileFloat(lpAppName, lpKeyName, fDefault, m_Path);
365-}
366-
367-/**********************************************************************//**
368- *
369- * 初期化ファイルから構造体を取得
370- *
371- -----------------------------------------------------------------------
372- * @param [in] lpAppName = セクション名
373- * @param [in] lpKeyName = キー名
374- * @param [out] lpStruct = 出力バッファ
375- * @param [in] nSize = 出力バッファサイズ
376- * @return
377-*//***********************************************************************/
378-DWORD CPrivateProfile::GetStruct(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize) const
379-{
380- return GetPrivateProfileStruct(lpAppName, lpKeyName, lpStruct, nSize, m_Path);
381-}
382-
383-/**********************************************************************//**
384- *
385- * 初期化ファイルからWINDOWPLACEMENTを取得
386- *
387- -----------------------------------------------------------------------
388- * @param [in] lpAppName = セクション名
389- * @param [in] lpKeyName = キー名
390- * @param [in] lpwdpl = 出力バッファ(WINDOWPLACEMENT)
391- * @return
392-*//***********************************************************************/
393-DWORD CPrivateProfile::GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl) const
394-{
395- return GetPrivateProfileWindowPlacement(lpAppName, lpKeyName, lpwdpl, m_Path);
396-}
397-
398-/**********************************************************************//**
399- *
400- * 初期化ファイルからWINDOWPLACEMENTを取得
401- *
402- -----------------------------------------------------------------------
403- * @param [in] lpAppName = セクション名
404- * @param [in] lpKeyName = キー名
405- * @param [in] hWnd = 出力先ハンドル
406- * @return
407-*//***********************************************************************/
408-DWORD CPrivateProfile::GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd) const
409-{
410- return GetPrivateProfileWindowPlacement(lpAppName, lpKeyName, hWnd, m_Path);
411-}
412-
413-/**********************************************************************//**
414- *
415- * 初期化ファイルにキーを書き込み
416- *
417- -----------------------------------------------------------------------
418- * @param [in] lpAppName = セクション名
419- * @param [in] lpString = キー
420- * @return 成否
421-*//***********************************************************************/
422-BOOL CPrivateProfile::WriteSection(LPCTSTR lpAppName, LPCTSTR lpString)
423-{
424- return WritePrivateProfileSection(lpAppName,lpString,m_Path);
425-}
426-
427-/**********************************************************************//**
428- *
429- * 初期化ファイルに整数値を書き込み
430- *
431- -----------------------------------------------------------------------
432- * @param [in] lpAppName = セクション名
433- * @param [in] lpKeyName = キー名
434- * @param [in] nValue = キー値
435- * @return 成否
436-*//***********************************************************************/
437-BOOL CPrivateProfile::WriteInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nValue)
438-{
439- return WritePrivateProfileInt(lpAppName,lpKeyName,nValue,m_Path);
440-}
441-
442-/**********************************************************************//**
443- *
444- * 初期化ファイルに小数値を書き込み
445- *
446- -----------------------------------------------------------------------
447- * @param [in] lpAppName = セクション名
448- * @param [in] lpKeyName = キー名
449- * @param [in] fValue = キー値
450- * @return 成否
451-*//***********************************************************************/
452-BOOL CPrivateProfile::WriteFloat(LPCTSTR lpAppName, LPCTSTR lpKeyName, float fValue)
453-{
454- return WritePrivateProfileFloat(lpAppName, lpKeyName, fValue, m_Path);
455-}
456-
457-/**********************************************************************//**
458- *
459- * 初期化ファイルに文字列を書き込み
460- *
461- -----------------------------------------------------------------------
462- * @param [in] lpAppName = セクション名
463- * @param [in] lpKeyName = キー名
464- * @param [in] lpString = 文字列
465- * @return 成否
466-*//***********************************************************************/
467-BOOL CPrivateProfile::WriteString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString)
468-{
469- return WritePrivateProfileString(lpAppName, lpKeyName, lpString, m_Path);
470-}
471-
472-/**********************************************************************//**
473- *
474- * 初期化ファイルに構造体を書き込み
475- *
476- -----------------------------------------------------------------------
477- * @param [in] lpAppName = セクション名
478- * @param [in] lpKeyName = キー名
479- * @param [in] lpStruct = 構造体ポインタ
480- * @param [in] nSize = 構造体サイズ
481- * @return 成否
482-*//***********************************************************************/
483-BOOL CPrivateProfile::WriteStruct(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize)
484-{
485- return WritePrivateProfileStruct(lpAppName, lpKeyName, lpStruct, nSize, m_Path);
486-}
487-
488-/**********************************************************************//**
489- *
490- * 初期化ファイルにWINDOWPLACEMENTを書き込み
491- *
492- -----------------------------------------------------------------------
493- * @param [in] lpAppName = セクション名
494- * @param [in] lpKeyName = キー名
495- * @param [in] hWnd = WINDOWPLACEMENTの取得ウィンドウハンドル
496- * @return 成否
497-*//***********************************************************************/
498-BOOL CPrivateProfile::WriteWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd)
499-{
500- return WritePrivateProfileWindowPlacement(lpAppName, lpKeyName, hWnd, m_Path);
501-}
502-
503-/**********************************************************************//**
504- *
505- * 空かどうか
506- *
507- -----------------------------------------------------------------------
508- * @return 真偽値
509-*//***********************************************************************/
510-bool CPrivateProfile::IsEmpty(void) const
511-{
512- IRIS_ASSERT( IsOpen() );
513- TCHAR tmp[256];
514- return (GetSectionNames(tmp, 256) == 0);
515-}
516-
517-} // end of namespace wx
518-} // end of namespace iris
--- trunk/framework/src/platform/windows/win/registry/WXProfile.h (revision 95)
+++ trunk/framework/src/platform/windows/win/registry/WXProfile.h (nonexistent)
@@ -1,138 +0,0 @@
1-//======================================================================
2-//-----------------------------------------------------------------------
3-/**
4- * @file WXProfile.h
5- * @brief Profileクラス
6- *
7- * @author t.sirayanagi
8- * @version 1.0
9- *
10- * @par copyright
11- * Copyright (C) 2009-2011 Takazumi Shirayanagi\n
12- * The new BSD License is applied to this software.
13- * see iris_LICENSE.txt
14-*/
15-//-----------------------------------------------------------------------
16-//======================================================================
17-#ifndef _IRIS_WXProfile_H_
18-#define _IRIS_WXProfile_H_
19-
20-//======================================================================
21-// include
22-#include "stl/STLvecmap.h"
23-#include "stl/STLtstring.h"
24-
25-#if defined(IRIS_WIN32_WCE)
26-#error not support.
27-#endif
28-
29-namespace iris {
30-namespace wx
31-{
32-
33-//======================================================================
34-// function
35-// 整数値の書き込み
36-BOOL WritePrivateProfileIntA(LPCSTR lpAppName, LPCSTR lpKeyName, UINT nValue, LPCSTR lpFileName);
37-BOOL WritePrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, UINT nValue, LPCWSTR lpFileName);
38-// 整数値(HEX)の書き込み
39-BOOL WritePrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nValue, LPCSTR lpFileName);
40-BOOL WritePrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nValue, LPCWSTR lpFileName);
41-// 整数値(HEX)の取得
42-DWORD GetPrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nDefault, LPCSTR lpFileName);
43-DWORD GetPrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nDefault, LPCWSTR lpFileName);
44-// 小数値の書き込み
45-BOOL WritePrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fValue, LPCSTR lpFileName);
46-BOOL WritePrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fValue, LPCWSTR lpFileName);
47-// 小数値の取得
48-float GetPrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fDefault, LPCSTR lpFileName);
49-float GetPrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fDefault, LPCWSTR lpFileName);
50-// WINDOWPLACEMENTの書き込み
51-BOOL WritePrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName);
52-BOOL WritePrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName);
53-// WINDOWPLACEMENTの取得
54-BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCSTR lpFileName);
55-BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCWSTR lpFileName);
56-BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName);
57-BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName);
58-
59-//======================================================================
60-// define
61-#ifdef UNICODE
62-#define WritePrivateProfileInt WritePrivateProfileIntW
63-#define WritePrivateProfileHex WritePrivateProfileHexW
64-#define WritePrivateProfileFloat WritePrivateProfileFloatW
65-#define GetPrivateProfileFloat GetPrivateProfileFloatW
66-#define WritePrivateProfileWindowPlacement WritePrivateProfileWindowPlacementW
67-#define GetPrivateProfileWindowPlacement GetPrivateProfileWindowPlacementW
68-#else
69-#define WritePrivateProfileInt WritePrivateProfileIntA
70-#define WritePrivateProfileHex WritePrivateProfileHexA
71-#define WritePrivateProfileFloat WritePrivateProfileFloatA
72-#define GetPrivateProfileFloat GetPrivateProfileFloatA
73-#define WritePrivateProfileWindowPlacement WritePrivateProfileWindowPlacementA
74-#define GetPrivateProfileWindowPlacement GetPrivateProfileWindowPlacementA
75-#endif
76-
77-//======================================================================
78-// class
79-//! PrivateProfileクラス
80-class CPrivateProfile : public IIrisObject
81-{
82-protected:
83- // iniファイル名
84- TCHAR m_Path[MAX_PATH];
85-
86-public:
87- // コンストラクタ
88- CPrivateProfile(void);
89- // デストラクタ
90- virtual ~CPrivateProfile(void);
91-public:
92- // 開く
93- virtual void Open(LPCTSTR path);
94- // 閉じる
95- virtual void Close(void);
96-
97-public:
98-
99- // セクション名を取得
100- DWORD GetSectionNames(LPTSTR lpReturn, DWORD nSize) const;
101- // セクションに存在するキー名を取得
102- DWORD GetSection (LPCTSTR lpAppName, LPTSTR lpReturn, DWORD nSize) const;
103- // 初期化ファイルから文字列を取得
104- DWORD GetString (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturn, DWORD nSize) const;
105- // 初期化ファイルから整数値を取得
106- UINT GetInt (LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nDefault) const;
107- // 初期化ファイルから小数値を取得
108- float GetFloat (LPCTSTR lpAppName, LPCTSTR lpKeyName, float fDefault) const;
109- // 初期化ファイルから構造体を取得
110- DWORD GetStruct (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize) const;
111- // 初期化ファイルからWINDOWPLACEMENTを取得
112- DWORD GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl) const;
113- DWORD GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd) const;
114-
115- // 初期化ファイルにキーを書き込み
116- BOOL WriteSection(LPCTSTR lpAppName, LPCTSTR lpString);
117- // 初期化ファイルに整数値を書き込み
118- BOOL WriteInt (LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nValue);
119- // 初期化ファイルに小数値を書き込み
120- BOOL WriteFloat (LPCTSTR lpAppName, LPCTSTR lpKeyName, float fValue);
121- // 初期化ファイルに文字列を書き込み
122- BOOL WriteString (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString);
123- // 初期化ファイルに構造体を書き込み
124- BOOL WriteStruct (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize);
125- // 初期化ファイルにWINDOWPLACEMENTを書き込み
126- BOOL WriteWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd);
127-
128-public:
129- // 開いているか
130- bool IsOpen(void) const { return (m_Path[0] != TEXT('\0')); }
131- // 空かどうか
132- bool IsEmpty(void) const;
133-};
134-
135-} // end of namespace wx
136-} // end of namespace iris
137-
138-#endif
--- trunk/framework/src/platform/windows/win/registry/WXPrivateProfile.h (nonexistent)
+++ trunk/framework/src/platform/windows/win/registry/WXPrivateProfile.h (revision 96)
@@ -0,0 +1,151 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file WXPrivateProfile.h
5+ * @brief PrivateProfile クラス
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2009-2011 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#ifndef _IRIS_WXPrivateProfile_H_
18+#define _IRIS_WXPrivateProfile_H_
19+
20+//======================================================================
21+// include
22+#include "stl/STLvecmap.h"
23+#include "stl/STLtstring.h"
24+
25+#if defined(IRIS_WIN32_WCE)
26+#error not support.
27+#endif
28+
29+namespace iris {
30+namespace wx
31+{
32+
33+//======================================================================
34+// function
35+// 整数値の書き込み
36+BOOL WritePrivateProfileIntA(LPCSTR lpAppName, LPCSTR lpKeyName, UINT nValue, LPCSTR lpFileName);
37+BOOL WritePrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, UINT nValue, LPCWSTR lpFileName);
38+// 整数値(HEX)の書き込み
39+BOOL WritePrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nValue, LPCSTR lpFileName);
40+BOOL WritePrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nValue, LPCWSTR lpFileName);
41+// 整数値(HEX)の取得
42+DWORD GetPrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nDefault, LPCSTR lpFileName);
43+DWORD GetPrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nDefault, LPCWSTR lpFileName);
44+// 小数値の書き込み
45+BOOL WritePrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fValue, LPCSTR lpFileName);
46+BOOL WritePrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fValue, LPCWSTR lpFileName);
47+// 小数値の取得
48+float GetPrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fDefault, LPCSTR lpFileName);
49+float GetPrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fDefault, LPCWSTR lpFileName);
50+// WINDOWPLACEMENTの書き込み
51+BOOL WritePrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName);
52+BOOL WritePrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName);
53+// WINDOWPLACEMENTの取得
54+BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCSTR lpFileName);
55+BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCWSTR lpFileName);
56+BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName);
57+BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName);
58+
59+//======================================================================
60+// define
61+#ifdef UNICODE
62+# define WritePrivateProfileInt WritePrivateProfileIntW
63+# define WritePrivateProfileHex WritePrivateProfileHexW
64+# define WritePrivateProfileFloat WritePrivateProfileFloatW
65+# define WritePrivateProfileWindowPlacement WritePrivateProfileWindowPlacementW
66+# define GetPrivateProfileHex GetPrivateProfileHexW
67+# define GetPrivateProfileFloat GetPrivateProfileFloatW
68+# define GetPrivateProfileWindowPlacement GetPrivateProfileWindowPlacementW
69+#else
70+# define WritePrivateProfileInt WritePrivateProfileIntA
71+# define WritePrivateProfileHex WritePrivateProfileHexA
72+# define WritePrivateProfileFloat WritePrivateProfileFloatA
73+# define WritePrivateProfileWindowPlacement WritePrivateProfileWindowPlacementA
74+# define GetPrivateProfileHex GetPrivateProfileHexA
75+# define GetPrivateProfileFloat GetPrivateProfileFloatA
76+# define GetPrivateProfileWindowPlacement GetPrivateProfileWindowPlacementA
77+#endif
78+
79+//======================================================================
80+// class
81+//! PrivateProfileクラス
82+class CPrivateProfile : public IIrisObject
83+{
84+protected:
85+ // iniファイル名
86+ TCHAR m_Path[MAX_PATH];
87+
88+public:
89+ // コンストラクタ
90+ CPrivateProfile(void);
91+ // デストラクタ
92+ virtual ~CPrivateProfile(void);
93+public:
94+ // 開く
95+ virtual void Open(LPCTSTR path);
96+ // 閉じる
97+ virtual void Close(void);
98+
99+public:
100+
101+ // セクション名を取得
102+ DWORD GetSectionNames(LPTSTR lpReturn, DWORD nSize) const;
103+ // セクションに存在するキー名を取得
104+ DWORD GetSection (LPCTSTR lpAppName, LPTSTR lpReturn, DWORD nSize) const;
105+ // 初期化ファイルから文字列を取得
106+ DWORD GetString (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturn, DWORD nSize) const;
107+ // 初期化ファイルから整数値を取得
108+ UINT GetInt (LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nDefault) const;
109+ // 初期化ファイルからHEX値を取得
110+ DWORD GetHex (LPCTSTR lpAppName, LPCTSTR lpKeyName, DWORD dwDefault) const;
111+ // 初期化ファイルから小数値を取得
112+ float GetFloat (LPCTSTR lpAppName, LPCTSTR lpKeyName, float fDefault) const;
113+ // 初期化ファイルから構造体を取得
114+ DWORD GetStruct (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize) const;
115+ // 初期化ファイルからWINDOWPLACEMENTを取得
116+ DWORD GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl) const;
117+ DWORD GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd) const;
118+
119+ // 初期化ファイルにキーを書き込み
120+ BOOL WriteSection(LPCTSTR lpAppName, LPCTSTR lpString);
121+ // 初期化ファイルに整数値を書き込み
122+ BOOL WriteInt (LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nValue);
123+ // 初期化ファイルに小数値を書き込み
124+ BOOL WriteFloat (LPCTSTR lpAppName, LPCTSTR lpKeyName, float fValue);
125+ // 初期化ファイルにHEX値を書き込み
126+ BOOL WriteHex (LPCTSTR lpAppName, LPCTSTR lpKeyName, DWORD dwValue);
127+ // 初期化ファイルに文字列を書き込み
128+ BOOL WriteString (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString);
129+ // 初期化ファイルに構造体を書き込み
130+ BOOL WriteStruct (LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize);
131+ // 初期化ファイルにWINDOWPLACEMENTを書き込み
132+ BOOL WriteWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd);
133+
134+ // 初期化ファイルからキーを削除
135+ BOOL RemoveKey(LPCTSTR lpAppName, LPCTSTR lpKeyName);
136+ // 初期化ファイルからセクションを削除
137+ BOOL RemoveSection(LPCTSTR lpAppName);
138+ // ファイルを削除
139+ BOOL Remove(void);
140+
141+public:
142+ // 開いているか
143+ bool IsOpen(void) const { return (m_Path[0] != TEXT('\0')); }
144+ // 空かどうか
145+ bool IsEmpty(void) const;
146+};
147+
148+} // end of namespace wx
149+} // end of namespace iris
150+
151+#endif
--- trunk/framework/src/platform/windows/win/registry/WXPrivateProfile.cpp (nonexistent)
+++ trunk/framework/src/platform/windows/win/registry/WXPrivateProfile.cpp (revision 96)
@@ -0,0 +1,609 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file WXPrivateProfile.cpp
5+ * @brief PrivateProfile クラス
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2009-2011 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#define _IRIS_WXPrivateProfile_CPP_
18+
19+//======================================================================
20+// include
21+#include "WXPrivateProfile.h"
22+#include "iris_debug.h"
23+#include <tchar.h>
24+
25+#include "../debug/WXDebugLeakCheckMacro.h"
26+
27+namespace iris {
28+namespace wx
29+{
30+
31+//======================================================================
32+// function
33+
34+/**********************************************************************//**
35+ *
36+ * 初期化ファイルに整数値を書き込み
37+ *
38+ -----------------------------------------------------------------------
39+ * @param [in] lpAppName = セクション名
40+ * @param [in] lpKeyName = キー名
41+ * @param [in] nValue = キー値
42+ * @param [in] lpFileName = ファイル名
43+ * @return 成否
44+*//***********************************************************************/
45+BOOL WritePrivateProfileIntA(LPCSTR lpAppName, LPCSTR lpKeyName, UINT nValue, LPCSTR lpFileName)
46+{
47+ CHAR val[128];
48+ wsprintfA(val, "%d", nValue);
49+ return WritePrivateProfileStringA(lpAppName, lpKeyName, val, lpFileName);
50+}
51+/// iris::wx::WritePrivateProfileIntA 参照
52+BOOL WritePrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, UINT nValue, LPCWSTR lpFileName)
53+{
54+ WCHAR val[128];
55+ wsprintfW(val, L"%d", nValue);
56+ return WritePrivateProfileStringW(lpAppName, lpKeyName, val, lpFileName);
57+}
58+
59+/**********************************************************************//**
60+ *
61+ * 初期化ファイルに整数値(HEX)を書き込み
62+ *
63+ -----------------------------------------------------------------------
64+ * @param [in] lpAppName = セクション名
65+ * @param [in] lpKeyName = キー名
66+ * @param [in] nValue = キー値
67+ * @param [in] lpFileName = ファイル名
68+ * @return 成否
69+*//***********************************************************************/
70+BOOL WritePrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nValue, LPCSTR lpFileName)
71+{
72+ CHAR val[128];
73+ wsprintfA(val, "0x%x", nValue);
74+ return WritePrivateProfileStringA(lpAppName, lpKeyName, val, lpFileName);
75+}
76+/// iris::wx::WritePrivateProfileHexA 参照
77+BOOL WritePrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nValue, LPCWSTR lpFileName)
78+{
79+ WCHAR val[128];
80+ wsprintfW(val, L"0x%x", nValue);
81+ return WritePrivateProfileStringW(lpAppName, lpKeyName, val, lpFileName);
82+}
83+
84+/**********************************************************************//**
85+ *
86+ * 初期化ファイルから整数値(HEX)を取得
87+ *
88+ -----------------------------------------------------------------------
89+ * @param [in] lpAppName = セクション名
90+ * @param [in] lpKeyName = キー名
91+ * @param [in] nDefault = デフォルト値
92+ * @param [in] lpFileName = ファイル名
93+ * @return 値
94+*//***********************************************************************/
95+DWORD GetPrivateProfileHexA(LPCSTR lpAppName, LPCSTR lpKeyName, DWORD nDefault, LPCSTR lpFileName)
96+{
97+ CHAR val[128], def[128];
98+ wsprintfA(def, "%x", nDefault);
99+ DWORD size = GetPrivateProfileStringA(lpAppName, lpKeyName, def, val, 128, lpFileName);
100+ LPSTR p = nullptr;
101+#if 0
102+ DWORD ret = reinterpret_cast<DWORD>(strtol(val, &p, 16));
103+ if( ret == LONG_MAX )
104+ {
105+ if( errno == ERANGE )
106+ {
107+ ret = strtoul(val, &p, 16);
108+ }
109+ }
110+#else
111+ DWORD ret = strtoul(val, &p, 16);
112+#endif
113+ if( ret == 0 && p == val ) return nDefault;
114+ return ret;
115+}
116+/// iris::wx::GetPrivateProfileHexA 参照
117+DWORD GetPrivateProfileHexW(LPCWSTR lpAppName, LPCWSTR lpKeyName, DWORD nDefault, LPCWSTR lpFileName)
118+{
119+ WCHAR val[128], def[128];
120+ wsprintfW(def, L"%x", nDefault);
121+ DWORD size = GetPrivateProfileStringW(lpAppName, lpKeyName, def, val, 128, lpFileName);
122+ LPWSTR p = nullptr;
123+#if 0
124+ DWORD ret = reinterpret_cast<DWORD>(wcstol(val, &p, 16));
125+ if( ret == LONG_MAX )
126+ {
127+ if( errno == ERANGE )
128+ {
129+ ret = wcstol(val, &p, 16);
130+ }
131+ }
132+#else
133+ DWORD ret = wcstoul(val, &p, 16);
134+#endif
135+ if( ret == 0 && p == val ) return nDefault;
136+ return ret;
137+}
138+
139+/**********************************************************************//**
140+ *
141+ * 初期化ファイルに小数値を書き込み
142+ *
143+ -----------------------------------------------------------------------
144+ * @param [in] lpAppName = セクション名
145+ * @param [in] lpKeyName = キー名
146+ * @param [in] fValue = キー値
147+ * @param [in] lpFileName = ファイル名
148+ * @return 成否
149+*//***********************************************************************/
150+BOOL WritePrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fValue, LPCSTR lpFileName)
151+{
152+ CHAR val[128];
153+ sprintf_s(val, 128, "%f", fValue);
154+ return WritePrivateProfileStringA(lpAppName, lpKeyName, val, lpFileName);
155+}
156+/// iris::wx::WritePrivateProfileFloatA 参照
157+BOOL WritePrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fValue, LPCWSTR lpFileName)
158+{
159+ WCHAR val[128];
160+ swprintf_s(val, 128, L"%f", fValue);
161+ return WritePrivateProfileStringW(lpAppName, lpKeyName, val, lpFileName);
162+}
163+
164+/**********************************************************************//**
165+ *
166+ * 初期化ファイルから小数値を取得
167+ *
168+ -----------------------------------------------------------------------
169+ * @param [in] lpAppName = セクション名
170+ * @param [in] lpKeyName = キー名
171+ * @param [in] fDefault = 失敗したときに返す値
172+ * @param [in] lpFileName = ファイル名
173+ * @return 小数値
174+*//***********************************************************************/
175+float GetPrivateProfileFloatA(LPCSTR lpAppName, LPCSTR lpKeyName, float fDefault, LPCSTR lpFileName)
176+{
177+ CHAR val[128], def[128];
178+ sprintf_s(def, 128, "%f", fDefault);
179+ GetPrivateProfileStringA(lpAppName, lpKeyName, def, val, 128, lpFileName);
180+ float ret = (float)atof(val);
181+ return ret;
182+}
183+/// iris::wx::GetPrivateProfileFloatA 参照
184+float GetPrivateProfileFloatW(LPCWSTR lpAppName, LPCWSTR lpKeyName, float fDefault, LPCWSTR lpFileName)
185+{
186+ WCHAR val[128], def[128];
187+ swprintf_s(def, 128, L"%f", fDefault);
188+ GetPrivateProfileStringW(lpAppName, lpKeyName, def, val, 128, lpFileName);
189+ float ret = (float)_wtof(val);
190+ return ret;
191+}
192+
193+/**********************************************************************//**
194+ *
195+ * 初期化ファイルにWINDOWPLACEMENTを書き込み
196+ *
197+ -----------------------------------------------------------------------
198+ * @param [in] lpAppName = セクション名
199+ * @param [in] lpKeyName = キー名
200+ * @param [in] hWnd = ウィンドウハンドル
201+ * @param [in] lpFileName = ファイル名
202+ * @return 成否
203+*//***********************************************************************/
204+BOOL WritePrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName)
205+{
206+ WINDOWPLACEMENT wndpl;
207+ if( GetWindowPlacement(hWnd, &wndpl) == 0 ) return 0;
208+ return WritePrivateProfileStructA(lpAppName, lpKeyName, &wndpl, sizeof(wndpl), lpFileName);
209+}
210+/// iris::wx::WritePrivateProfileWindowPlacementA 参照
211+BOOL WritePrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName)
212+{
213+ WINDOWPLACEMENT wndpl;
214+ if( GetWindowPlacement(hWnd, &wndpl) == 0 ) return 0;
215+ return WritePrivateProfileStructW(lpAppName, lpKeyName, &wndpl, sizeof(wndpl), lpFileName);
216+}
217+
218+/**********************************************************************//**
219+ *
220+ * 初期化ファイルからWINDOWPLACEMENTを取得
221+ *
222+ -----------------------------------------------------------------------
223+ * @param [in] lpAppName = セクション名
224+ * @param [in] lpKeyName = キー名
225+ * @param [in] lpwdpl = 出力
226+ * @param [in] lpFileName = ファイル名
227+ * @return 成否
228+*//***********************************************************************/
229+BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCSTR lpFileName)
230+{
231+ return GetPrivateProfileStructA(lpAppName, lpKeyName, lpwdpl, sizeof(WINDOWPLACEMENT), lpFileName);
232+}
233+/// iris::wx::GetPrivateProfileWindowPlacementA 参照
234+BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl, LPCWSTR lpFileName)
235+{
236+ return GetPrivateProfileStructW(lpAppName, lpKeyName, lpwdpl, sizeof(WINDOWPLACEMENT), lpFileName);
237+}
238+
239+/**********************************************************************//**
240+ *
241+ * 初期化ファイルからWINDOWPLACEMENTを取得
242+ *
243+ -----------------------------------------------------------------------
244+ * @param [in] lpAppName = セクション名
245+ * @param [in] lpKeyName = キー名
246+ * @param [in] hWnd = 出力先ハンドル
247+ * @param [in] lpFileName = ファイル名
248+ * @return 成否
249+*//***********************************************************************/
250+BOOL GetPrivateProfileWindowPlacementA(LPCSTR lpAppName, LPCSTR lpKeyName, HWND hWnd, LPCSTR lpFileName)
251+{
252+ WINDOWPLACEMENT wndpl;
253+ if( !GetPrivateProfileStructA(lpAppName, lpKeyName, &wndpl, sizeof(WINDOWPLACEMENT), lpFileName) )
254+ return FALSE;
255+ SetWindowPlacement(hWnd, &wndpl);
256+ return TRUE;
257+}
258+/// iris::wx::GetPrivateProfileWindowPlacementA 参照
259+BOOL GetPrivateProfileWindowPlacementW(LPCWSTR lpAppName, LPCWSTR lpKeyName, HWND hWnd, LPCWSTR lpFileName)
260+{
261+ WINDOWPLACEMENT wndpl;
262+ if( !GetPrivateProfileStructW(lpAppName, lpKeyName, &wndpl, sizeof(WINDOWPLACEMENT), lpFileName) )
263+ return FALSE;
264+ SetWindowPlacement(hWnd, &wndpl);
265+ return TRUE;
266+}
267+
268+//======================================================================
269+// class
270+/**********************************************************************//**
271+ *
272+ * コンストラクタ
273+ *
274+*//***********************************************************************/
275+CPrivateProfile::CPrivateProfile(void)
276+{
277+ m_Path[0] = IRIS_TEXT('\0');
278+}
279+
280+/**********************************************************************//**
281+ *
282+ * デストラクタ
283+ *
284+*//***********************************************************************/
285+CPrivateProfile::~CPrivateProfile(void)
286+{
287+ Close();
288+}
289+
290+/**********************************************************************//**
291+ *
292+ * 開く
293+ *
294+ -----------------------------------------------------------------------
295+ * @param [in] path = パス
296+*//***********************************************************************/
297+void CPrivateProfile::Open(LPCTSTR path)
298+{
299+ Close();
300+ _tcscpy_s(m_Path, MAX_PATH, path);
301+}
302+
303+/**********************************************************************//**
304+ *
305+ * 閉じる
306+ *
307+*//***********************************************************************/
308+void CPrivateProfile::Close(void)
309+{
310+ ZeroMemory(m_Path, sizeof(m_Path));
311+}
312+
313+/**********************************************************************//**
314+ *
315+ * 存在するセクション名を取得
316+ *
317+ -----------------------------------------------------------------------
318+ * @param [out] lpReturn = 出力バッファ(キー名は'\0'区切りで出力される)
319+ * @param [in] nSize = 出力バッファサイズ
320+ * @return
321+*//***********************************************************************/
322+DWORD CPrivateProfile::GetSectionNames(LPTSTR lpReturn, DWORD nSize) const
323+{
324+ return GetPrivateProfileSectionNames(lpReturn, nSize, m_Path);
325+}
326+
327+/**********************************************************************//**
328+ *
329+ * セクションに存在するキー名を取得
330+ *
331+ -----------------------------------------------------------------------
332+ * @param [in] lpAppName = セクション名
333+ * @param [out] lpReturn = 出力バッファ(キー名は'\0'区切りで出力される)
334+ * @param [in] nSize = 出力バッファサイズ
335+ * @return
336+*//***********************************************************************/
337+DWORD CPrivateProfile::GetSection(LPCTSTR lpAppName, LPTSTR lpReturn, DWORD nSize) const
338+{
339+ return GetPrivateProfileSection(lpAppName, lpReturn, nSize, m_Path);
340+}
341+
342+/**********************************************************************//**
343+ *
344+ * 初期化ファイルから文字列を取得
345+ *
346+ -----------------------------------------------------------------------
347+ * @param [in] lpAppName = セクション名
348+ * @param [in] lpKeyName = キー名
349+ * @param [in] lpDefault = 失敗したときに返す文字列
350+ * @param [out] lpReturn = 出力バッファ(キー名は'='区切りで出力される)
351+ * @param [in] nSize = 出力バッファサイズ
352+ * @return
353+*//***********************************************************************/
354+DWORD CPrivateProfile::GetString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturn, DWORD nSize) const
355+{
356+ return GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpReturn, nSize, m_Path);
357+}
358+
359+/**********************************************************************//**
360+ *
361+ * 初期化ファイルから整数値を取得
362+ *
363+ -----------------------------------------------------------------------
364+ * @param [in] lpAppName = セクション名
365+ * @param [in] lpKeyName = キー名
366+ * @param [in] nDefault = 失敗したときに返す値
367+ * @return 整数値
368+*//***********************************************************************/
369+UINT CPrivateProfile::GetInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nDefault) const
370+{
371+ return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault, m_Path);
372+}
373+
374+/**********************************************************************//**
375+ *
376+ * 初期化ファイルからHEX値を取得
377+ *
378+ -----------------------------------------------------------------------
379+ * @param [in] lpAppName = セクション名
380+ * @param [in] lpKeyName = キー名
381+ * @param [in] nDefault = 失敗したときに返す値
382+ * @return HEX値
383+*//***********************************************************************/
384+DWORD CPrivateProfile::GetHex(LPCTSTR lpAppName, LPCTSTR lpKeyName, DWORD dwDefault) const
385+{
386+ return GetPrivateProfileHex(lpAppName, lpKeyName, dwDefault, m_Path);
387+}
388+
389+/**********************************************************************//**
390+ *
391+ * 初期化ファイルから小数値を取得
392+ *
393+ -----------------------------------------------------------------------
394+ * @param [in] lpAppName = セクション名
395+ * @param [in] lpKeyName = キー名
396+ * @param [in] fDefault = 失敗したときに返す値
397+ * @return 小数値
398+*//***********************************************************************/
399+float CPrivateProfile::GetFloat(LPCTSTR lpAppName, LPCTSTR lpKeyName, float fDefault) const
400+{
401+ return GetPrivateProfileFloat(lpAppName, lpKeyName, fDefault, m_Path);
402+}
403+
404+/**********************************************************************//**
405+ *
406+ * 初期化ファイルから構造体を取得
407+ *
408+ -----------------------------------------------------------------------
409+ * @param [in] lpAppName = セクション名
410+ * @param [in] lpKeyName = キー名
411+ * @param [out] lpStruct = 出力バッファ
412+ * @param [in] nSize = 出力バッファサイズ
413+ * @return
414+*//***********************************************************************/
415+DWORD CPrivateProfile::GetStruct(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize) const
416+{
417+ return GetPrivateProfileStruct(lpAppName, lpKeyName, lpStruct, nSize, m_Path);
418+}
419+
420+/**********************************************************************//**
421+ *
422+ * 初期化ファイルからWINDOWPLACEMENTを取得
423+ *
424+ -----------------------------------------------------------------------
425+ * @param [in] lpAppName = セクション名
426+ * @param [in] lpKeyName = キー名
427+ * @param [in] lpwdpl = 出力バッファ(WINDOWPLACEMENT)
428+ * @return
429+*//***********************************************************************/
430+DWORD CPrivateProfile::GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPWINDOWPLACEMENT lpwdpl) const
431+{
432+ return GetPrivateProfileWindowPlacement(lpAppName, lpKeyName, lpwdpl, m_Path);
433+}
434+
435+/**********************************************************************//**
436+ *
437+ * 初期化ファイルからWINDOWPLACEMENTを取得
438+ *
439+ -----------------------------------------------------------------------
440+ * @param [in] lpAppName = セクション名
441+ * @param [in] lpKeyName = キー名
442+ * @param [in] hWnd = 出力先ハンドル
443+ * @return
444+*//***********************************************************************/
445+DWORD CPrivateProfile::GetWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd) const
446+{
447+ return GetPrivateProfileWindowPlacement(lpAppName, lpKeyName, hWnd, m_Path);
448+}
449+
450+/**********************************************************************//**
451+ *
452+ * 初期化ファイルにキーを書き込み
453+ *
454+ -----------------------------------------------------------------------
455+ * @param [in] lpAppName = セクション名
456+ * @param [in] lpString = キー
457+ * @return 成否
458+*//***********************************************************************/
459+BOOL CPrivateProfile::WriteSection(LPCTSTR lpAppName, LPCTSTR lpString)
460+{
461+ return WritePrivateProfileSection(lpAppName, lpString, m_Path);
462+}
463+
464+/**********************************************************************//**
465+ *
466+ * 初期化ファイルに整数値を書き込み
467+ *
468+ -----------------------------------------------------------------------
469+ * @param [in] lpAppName = セクション名
470+ * @param [in] lpKeyName = キー名
471+ * @param [in] nValue = キー値
472+ * @return 成否
473+*//***********************************************************************/
474+BOOL CPrivateProfile::WriteInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, UINT nValue)
475+{
476+ return WritePrivateProfileInt(lpAppName, lpKeyName, nValue, m_Path);
477+}
478+
479+/**********************************************************************//**
480+ *
481+ * 初期化ファイルにHEX値を書き込み
482+ *
483+ -----------------------------------------------------------------------
484+ * @param [in] lpAppName = セクション名
485+ * @param [in] lpKeyName = キー名
486+ * @param [in] dwValue = キー値
487+ * @return 成否
488+*//***********************************************************************/
489+BOOL CPrivateProfile::WriteHex(LPCTSTR lpAppName, LPCTSTR lpKeyName, DWORD dwValue)
490+{
491+ return WritePrivateProfileHex(lpAppName, lpKeyName, dwValue, m_Path);
492+}
493+
494+/**********************************************************************//**
495+ *
496+ * 初期化ファイルに小数値を書き込み
497+ *
498+ -----------------------------------------------------------------------
499+ * @param [in] lpAppName = セクション名
500+ * @param [in] lpKeyName = キー名
501+ * @param [in] fValue = キー値
502+ * @return 成否
503+*//***********************************************************************/
504+BOOL CPrivateProfile::WriteFloat(LPCTSTR lpAppName, LPCTSTR lpKeyName, float fValue)
505+{
506+ return WritePrivateProfileFloat(lpAppName, lpKeyName, fValue, m_Path);
507+}
508+
509+/**********************************************************************//**
510+ *
511+ * 初期化ファイルに文字列を書き込み
512+ *
513+ -----------------------------------------------------------------------
514+ * @param [in] lpAppName = セクション名
515+ * @param [in] lpKeyName = キー名
516+ * @param [in] lpString = 文字列
517+ * @return 成否
518+*//***********************************************************************/
519+BOOL CPrivateProfile::WriteString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString)
520+{
521+ return WritePrivateProfileString(lpAppName, lpKeyName, lpString, m_Path);
522+}
523+
524+/**********************************************************************//**
525+ *
526+ * 初期化ファイルに構造体を書き込み
527+ *
528+ -----------------------------------------------------------------------
529+ * @param [in] lpAppName = セクション名
530+ * @param [in] lpKeyName = キー名
531+ * @param [in] lpStruct = 構造体ポインタ
532+ * @param [in] nSize = 構造体サイズ
533+ * @return 成否
534+*//***********************************************************************/
535+BOOL CPrivateProfile::WriteStruct(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPVOID lpStruct, DWORD nSize)
536+{
537+ return WritePrivateProfileStruct(lpAppName, lpKeyName, lpStruct, nSize, m_Path);
538+}
539+
540+/**********************************************************************//**
541+ *
542+ * 初期化ファイルにWINDOWPLACEMENTを書き込み
543+ *
544+ -----------------------------------------------------------------------
545+ * @param [in] lpAppName = セクション名
546+ * @param [in] lpKeyName = キー名
547+ * @param [in] hWnd = WINDOWPLACEMENTの取得ウィンドウハンドル
548+ * @return 成否
549+*//***********************************************************************/
550+BOOL CPrivateProfile::WriteWindowPlacement(LPCTSTR lpAppName, LPCTSTR lpKeyName, HWND hWnd)
551+{
552+ return WritePrivateProfileWindowPlacement(lpAppName, lpKeyName, hWnd, m_Path);
553+}
554+
555+/**********************************************************************//**
556+ *
557+ * 初期化ファイルからキーを削除
558+ *
559+ -----------------------------------------------------------------------
560+ * @param [in] lpAppName = セクション名
561+ * @param [in] lpKeyName = キー名
562+ * @return 成否
563+*//***********************************************************************/
564+BOOL CPrivateProfile::RemoveKey(LPCTSTR lpAppName, LPCTSTR lpKeyName)
565+{
566+ return WritePrivateProfileString(lpAppName, lpKeyName, nullptr, m_Path);
567+}
568+
569+/**********************************************************************//**
570+ *
571+ * 初期化ファイルからセクションを削除
572+ *
573+ -----------------------------------------------------------------------
574+ * @param [in] lpAppName = セクション名
575+ * @return 成否
576+*//***********************************************************************/
577+BOOL CPrivateProfile::RemoveSection(LPCTSTR lpAppName)
578+{
579+ return WritePrivateProfileString(lpAppName, nullptr, nullptr, m_Path);
580+}
581+
582+/**********************************************************************//**
583+ *
584+ * ファイルを削除
585+ *
586+ -----------------------------------------------------------------------
587+ * @return 成否
588+*//***********************************************************************/
589+BOOL CPrivateProfile::Remove(void)
590+{
591+ return DeleteFile(m_Path);
592+}
593+
594+/**********************************************************************//**
595+ *
596+ * 空かどうか
597+ *
598+ -----------------------------------------------------------------------
599+ * @return 真偽値
600+*//***********************************************************************/
601+bool CPrivateProfile::IsEmpty(void) const
602+{
603+ IRIS_ASSERT( IsOpen() );
604+ TCHAR tmp[256];
605+ return (GetSectionNames(tmp, 256) == 0);
606+}
607+
608+} // end of namespace wx
609+} // end of namespace iris
--- trunk/framework/src/platform/windows/win/registry/WXMappedProfile.h (revision 95)
+++ trunk/framework/src/platform/windows/win/registry/WXMappedProfile.h (revision 96)
@@ -19,7 +19,7 @@
1919
2020 //======================================================================
2121 // include
22-#include "WXProfile.h"
22+#include "WXPrivateProfile.h"
2323 #include "stl/STLvecmap.h"
2424 #include "stl/STLtstring.h"
2525
--- trunk/framework/src/platform/windows/win/base/WXError.h (revision 95)
+++ trunk/framework/src/platform/windows/win/base/WXError.h (revision 96)
@@ -8,7 +8,7 @@
88 * @version 1.0
99 *
1010 * @par copyright
11- * Copyright (C) 2009-2010 Takazumi Shirayanagi\n
11+ * Copyright (C) 2009-2011 Takazumi Shirayanagi\n
1212 * The new BSD License is applied to this software.
1313 * see iris_LICENSE.txt
1414 */
@@ -19,7 +19,8 @@
1919
2020 //======================================================================
2121 // include
22-#include "iris_object.h"
22+#include "fnd/container/FndAutoPtr.h"
23+#include "../container/WXLiberator.h"
2324
2425 namespace iris {
2526 namespace wx
@@ -26,11 +27,16 @@
2627 {
2728
2829 //======================================================================
30+// typedef
31+/// GetLastError の戻り値型
32+typedef DWORD LASTERROR;
33+
34+//======================================================================
2935 // class
3036 /// スコープ有効エラー定数クラス
3137 class CScopedLastError : public IIrisObject
3238 {
33- DWORD m_LastError; //!< LastError 値
39+ LASTERROR m_LastError; //!< LastError 値
3440 public:
3541 /// コンストラクタ
3642 CScopedLastError(void)
@@ -43,34 +49,43 @@
4349 ::SetLastError(m_LastError);
4450 }
4551 public:
46- operator DWORD (void) { return m_LastError; }
52+ operator LASTERROR (void) const { return m_LastError; }
4753 };
4854
49-/// エラー文字列取得クラス
50-class CErrorString : public IIrisObject
55+/// LASTERROR クラス
56+class CLastError : public IIrisObject
5157 {
58+public:
59+ typedef fnd::CAutoPtr<TCHAR, CLocalMemLiberator> String;
60+ typedef fnd::CAutoPtr<CHAR , CLocalMemLiberator> StringA;
61+ typedef fnd::CAutoPtr<WCHAR, CLocalMemLiberator> StringW;
62+
5263 private:
53- void* m_pString; //!< 文字列
64+ LASTERROR m_LastError; //!< LastError 値
5465
5566 public:
56- // コンストラクタ
57- CErrorString(void) : m_pString(nullptr) {}
58- CErrorString(DWORD error) : m_pString(nullptr) { GetErrorString(error); }
59- // デストラクタ
60- ~CErrorString(void) { Release(); }
67+ /**
68+ * @name コンストラクタ
69+ * @{
70+ */
71+ CLastError(void) : m_LastError(0) { m_LastError = GetLastError(); }
72+ CLastError(LASTERROR error) : m_LastError(error) { }
73+ /**
74+ * @}
75+ */
76+
77+
6178 public:
62- LPCTSTR GetErrorString (void) { return static_cast<LPCTSTR>(m_pString); }
63- LPCSTR GetErrorStringA(void) { return static_cast<LPCSTR >(m_pString); }
64- LPCWSTR GetErrorStringW(void) { return static_cast<LPCWSTR>(m_pString); }
65- operator LPCSTR (void) { return GetErrorStringA(); }
66- operator LPCWSTR (void) { return GetErrorStringW(); }
79+ String ToString (void) const { return GetErrorString (m_LastError); }
80+ StringA ToStringA(void) const { return GetErrorStringA(m_LastError); }
81+ StringW ToStringW(void) const { return GetErrorStringW(m_LastError); }
82+ operator LASTERROR (void) const { return m_LastError; }
83+ LASTERROR operator ()(void) const { return m_LastError; }
6784
85+ CLastError& operator = (LASTERROR err) { m_LastError = err; return *this; }
6886 public:
69- // 解放
70- void Release(void) { LocalFree(m_pString); m_pString = nullptr; }
71-public:
7287 // エラー定数からエラー文字列の取得
73- LPCTSTR GetErrorString (DWORD error)
88+ String GetErrorString (LASTERROR error) const
7489 {
7590 #ifdef UNICODE
7691 return GetErrorStringW(error);
@@ -79,35 +94,35 @@
7994 #endif
8095 }
8196 // エラー定数からエラー文字列の取得
82- LPCSTR GetErrorStringA(DWORD error)
97+ StringA GetErrorStringA(LASTERROR error) const
8398 {
84- Release();
99+ LPSTR pString = nullptr;
85100 FormatMessageA(
86- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
101+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
87102 nullptr,
88103 error,
89104 0,
90105 //MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // デフォルト ユーザー言語
91- (LPSTR)&m_pString,
106+ (LPSTR)&pString,
92107 0,
93108 nullptr );
94- return GetErrorStringA();
109+ return StringA(pString);
95110 }
96111
97112 // エラー定数からエラー文字列の取得
98- LPCWSTR GetErrorStringW(DWORD error)
113+ StringW GetErrorStringW(LASTERROR error) const
99114 {
100- Release();
115+ LPWSTR pString = nullptr;
101116 FormatMessageW(
102- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
117+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
103118 nullptr,
104119 error,
105120 0,
106121 //MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // デフォルト ユーザー言語
107- (LPWSTR)&m_pString,
122+ (LPWSTR)&pString,
108123 0,
109124 nullptr );
110- return GetErrorStringW();
125+ return StringW(pString);
111126 }
112127 };
113128
@@ -115,3 +130,4 @@
115130 } // end of namespace iris
116131
117132 #endif
133+
--- trunk/framework/src/fnd/container/FndDuration.h (nonexistent)
+++ trunk/framework/src/fnd/container/FndDuration.h (revision 96)
@@ -0,0 +1,106 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file FndDuration.h
5+ * @brief duration ファイル
6+ *
7+ * @author t.sirayanagi
8+ * @version 1.0
9+ *
10+ * @par copyright
11+ * Copyright (C) 2011 Takazumi Shirayanagi\n
12+ * The new BSD License is applied to this software.
13+ * see iris_LICENSE.txt
14+*/
15+//-----------------------------------------------------------------------
16+//======================================================================
17+#ifndef _IRIS_FndDuration_H_
18+#define _IRIS_FndDuration_H_
19+
20+//======================================================================
21+// include
22+#include "../../iris_object.h"
23+#include "../../iris_debug.h"
24+#include "../../ml/ratio/iml_ratio.hpp"
25+
26+namespace iris {
27+namespace fnd
28+{
29+
30+//======================================================================
31+// class
32+/**
33+ * @brief duration
34+ * @tparam _TN = 値の型
35+ * @tparam _R = ratio
36+*/
37+template<typename _TN, class _R>
38+class CDuration : public IIrisObject
39+{
40+ IRIS_STATIC_ASSERT( iml::is_ratio<_R>::value );
41+
42+ typedef _TN value_type;
43+ typedef _TN *value_ptr;
44+ typedef _TN &value_ref;
45+ typedef _R period;
46+
47+ typedef CDuration<_TN, _R> _Myt;
48+private:
49+ value_type m_rep;
50+
51+public:
52+ /**
53+ * @name コンストラクタ
54+ * @{
55+ */
56+ CDuration(void) {}
57+ CDuration(const value_type& d) : m_rep(d) {}
58+ CDuration(const _Myt& rhs) : m_rep(rhs.m_rep) {}
59+ /**
60+ * @}
61+ */
62+
63+
64+public:
65+ /**
66+ * @brief 値の取得
67+ * @return period 単位の値
68+ */
69+ value_type count(void) { return m_rep; }
70+ const value_type& count(void) const { return m_rep; }
71+
72+public:
73+ /**
74+ * @name operator
75+ * @{
76+ */
77+ _Myt& operator = (const _Myt& rhs) { if( &rhs != this ) this->m_rep = rhs.m_rep; return *this; }
78+
79+ _Myt operator + (void) const { return *this; }
80+ _Myt operator - (void) const { return _Myt(-m_rep); }
81+ _Myt operator ++(int) { return _Myt(m_rep++); }
82+ _Myt& operator ++(void) { ++m_rep; return *this; }
83+ _Myt operator --(int) { return _Myt(m_rep--); }
84+ _Myt& operator --(void) { --m_rep; return *this; }
85+
86+ _Myt& operator +=(const _Myt& d) { m_rep += d.count(); return *this; }
87+ _Myt& operator -=(const _Myt& d) { m_rep -= d.count(); return *this; }
88+
89+ _Myt operator * (const value_type& rhs) const { return _Myt(m_rep * rhs); }
90+ _Myt& operator *=(const value_type& rhs) { m_rep *= rhs; return *this; }
91+ _Myt operator / (const value_type& rhs) const { return _Myt(m_rep / rhs); }
92+ _Myt& operator /=(const value_type& rhs) { m_rep /= rhs; return *this; }
93+ _Myt operator % (const value_type& rhs) const { return _Myt(m_rep % rhs); }
94+ _Myt& operator %=(const value_type& rhs) { m_rep %= rhs; return *this; }
95+ _Myt operator % (const _Myt& rhs) const { return _Myt(m_rep % rhs.count()); }
96+ _Myt& operator %=(const _Myt& rhs) { m_rep %= rhs.count(); return *this; }
97+ /**
98+ * @}
99+ */
100+};
101+
102+} // end of namespace fnd
103+} // end of namespace iris
104+
105+#endif
106+
--- trunk/framework/src/fnd/container/FndScopedPtr.h (revision 95)
+++ trunk/framework/src/fnd/container/FndScopedPtr.h (revision 96)
@@ -8,7 +8,7 @@
88 * @version 1.0
99 *
1010 * @par copyright
11- * Copyright (C) 2009-2010 Takazumi Shirayanagi\n
11+ * Copyright (C) 2009-2011 Takazumi Shirayanagi\n
1212 * The new BSD License is applied to this software.
1313 * see iris_LICENSE.txt
1414 */
@@ -19,7 +19,7 @@
1919
2020 //======================================================================
2121 // include
22-#include "../../iris_object.h"
22+#include "FndLiberator.h"
2323
2424 namespace iris {
2525 namespace fnd
@@ -31,23 +31,24 @@
3131 * @brief スコープポインタクラス
3232 * @tparam _TN = 対象型
3333 */
34-template<typename _TN>
35-class CScopedPtr : public INonCopyable<>
34+template<typename _TN, class _Liberator=CLiberatorObject<_TN>>
35+class CScopedPtr : public _Liberator
3636 {
37- typedef CScopedPtr<_TN> _Myt;
37+ typedef CScopedPtr<_TN, _Liberator> _Myt;
3838 public:
39- typedef _TN value_type;
40- typedef _TN *value_ptr;
41- typedef _TN &value_ref;
39+ typedef _Liberator Liberator;
40+ typedef _TN value_type;
41+ typedef _TN *value_ptr;
42+ typedef _TN &value_ref;
4243 private:
4344 const value_type m_pPtr; //!< ポインタ
4445 public:
4546 /// コンストラクタ
46- CScopedPtr(void) : m_pPtr(nullptr) {}
47+ CScopedPtr(void) : Liberator(nullptr) {}
4748 /// コンストラクタ
48- explicit CScopedPtr(value_type ptr) : m_pPtr(ptr) {}
49+ explicit CScopedPtr(value_type ptr) : Liberator(ptr) {}
4950 /// デストラクタ
50- ~CScopedPtr(void) { delete m_pPtr; }
51+ ~CScopedPtr(void) { reset(nullptr); }
5152
5253 public:
5354 //! rebind
@@ -68,7 +69,7 @@
6869 void reset(value_type ptr)
6970 {
7071 if( ptr == m_pPtr ) return;
71- delete m_pPtr;
72+ _Liberator::liberate();
7273 m_pPtr = ptr;
7374 }
7475 /// swap
--- trunk/framework/src/fnd/container/FndBuffer.h (revision 95)
+++ trunk/framework/src/fnd/container/FndBuffer.h (revision 96)
@@ -58,7 +58,7 @@
5858 /// バッファの確保
5959 bool alloc(u32 size, s32 arg=0)
6060 {
61- resize(size, arg);
61+ return resize(size, arg);
6262 }
6363 /// リサイズ
6464 bool resize(u32 size, s32 arg=0)
--- trunk/framework/src/fnd/container/FndAutoPtr.h (revision 95)
+++ trunk/framework/src/fnd/container/FndAutoPtr.h (revision 96)
@@ -47,8 +47,8 @@
4747 }
4848 /// コンストラクタ
4949 explicit CAutoPtr(value_ptr ptr) : _Liberator(ptr) {}
50- /// コンストラクタ
51- explicit CAutoPtr(_Myt& r) : _Liberator(r.release()) {}
50+ /// コピーコンストラクタ
51+ CAutoPtr(_Myt& r) : _Liberator(r.release()) {}
5252 /// デストラクタ
5353 ~CAutoPtr(void) { reset(nullptr); }
5454
--- trunk/framework/src/ml/detail/iml_detail.hpp (revision 95)
+++ trunk/framework/src/ml/detail/iml_detail.hpp (revision 96)
@@ -8,7 +8,7 @@
88 * @version 1.0
99 *
1010 * @par copyright
11- * Copyright (C) 2010 Takazumi Shirayanagi\n
11+ * Copyright (C) 2010-2011 Takazumi Shirayanagi\n
1212 * The new BSD Limlnse is applied to this software.
1313 * see iris_LICENSE.txt
1414 */
@@ -29,13 +29,13 @@
2929 // true
3030 typedef struct true_type
3131 {
32- enum { value = true };
32+ static const bool value = true;
3333 } true_type;
3434
3535 // false
3636 typedef struct false_type
3737 {
38- enum { value = false };
38+ static const bool value = false;
3939 } false_type;
4040
4141 /**
--- trunk/framework/src/ml/math/iml_mul.hpp (revision 95)
+++ trunk/framework/src/ml/math/iml_mul.hpp (revision 96)
@@ -32,28 +32,28 @@
3232 template<intmax_t _V1, intmax_t _V2>
3333 class static_mul
3434 {
35- template<intmax_t _T1, intmax_t _T2>
35+ template<intmax_t _T1, intmax_t _T2, typename _DMY>
3636 struct mul_impl
3737 {
3838 static const intmax_t value = _T1 * _T2;
3939 };
40- template<intmax_t _T1>
41- struct mul_impl<_T1, 0>
40+ template<intmax_t _T1, typename _DMY>
41+ struct mul_impl<_T1, 0, _DMY>
4242 {
4343 static const intmax_t value = 0;
4444 };
45- template<intmax_t _T2>
46- struct mul_impl<0, _T2>
45+ template<intmax_t _T2, typename _DMY>
46+ struct mul_impl<0, _T2, _DMY>
4747 {
4848 static const intmax_t value = 0;
4949 };
50- template<>
51- struct mul_impl<0, 0>
50+ template<typename _DMY>
51+ struct mul_impl<0, 0, _DMY>
5252 {
5353 static const intmax_t value = 0;
5454 };
5555 public:
56- static const intmax_t value = mul_impl<_V1, _V2>::value;
56+ static const intmax_t value = mul_impl<_V1, _V2, void>::value;
5757 };
5858
5959 } // end of namespace iml
--- trunk/framework/src/ml/ratio/iml_ratio.hpp (revision 95)
+++ trunk/framework/src/ml/ratio/iml_ratio.hpp (revision 96)
@@ -20,6 +20,7 @@
2020 //======================================================================
2121 // include
2222 #include "../../c++0x/cpp0x_static_assert.h"
23+#include "../detail/iml_detail.hpp"
2324 #include "../iml_math.hpp"
2425 #include "../iml_constant.hpp"
2526
@@ -27,6 +28,29 @@
2728 {
2829
2930 //======================================================================
31+// declare
32+template<intmax_t _N, intmax_t _D=1>class ratio;
33+
34+//======================================================================
35+// typedef
36+typedef ratio<INTMAX_C( 1), INTMAX_C(1000000000000000000)> atto;
37+typedef ratio<INTMAX_C( 1), INTMAX_C( 1000000000000000)> femto;
38+typedef ratio<INTMAX_C( 1), INTMAX_C( 1000000000000)> pico;
39+typedef ratio<INTMAX_C( 1), INTMAX_C( 1000000000)> nano;
40+typedef ratio<INTMAX_C( 1), INTMAX_C( 1000000)> micro;
41+typedef ratio<INTMAX_C( 1), INTMAX_C( 1000)> milli;
42+typedef ratio<INTMAX_C( 1), INTMAX_C( 100)> centi;
43+typedef ratio<INTMAX_C( 1), INTMAX_C( 10)> deci;
44+typedef ratio<INTMAX_C( 10), INTMAX_C( 1)> deca;
45+typedef ratio<INTMAX_C( 100), INTMAX_C( 1)> hecto;
46+typedef ratio<INTMAX_C( 1000), INTMAX_C( 1)> kilo;
47+typedef ratio<INTMAX_C( 1000000), INTMAX_C( 1)> mega;
48+typedef ratio<INTMAX_C( 1000000000), INTMAX_C( 1)> giga;
49+typedef ratio<INTMAX_C( 1000000000000), INTMAX_C( 1)> tera;
50+typedef ratio<INTMAX_C( 1000000000000000), INTMAX_C( 1)> peta;
51+typedef ratio<INTMAX_C(1000000000000000000), INTMAX_C( 1)> exa;
52+
53+//======================================================================
3054 // class
3155
3256 template<intmax_t _N, intmax_t _D>
@@ -43,22 +67,24 @@
4367 static const intmax_t den = m_da / m_gcd;
4468
4569 typedef typename ratio<num, den> type;
70+private:
71+ ratio() {}
4672 };
4773
4874 template<class _R1, class _R2>
4975 class ratio_addition
5076 {
51- static const intmax_t den = static_lcm<_R1::den, _R2::den>::value;
77+ static const intmax_t m_lcm_den = static_lcm<_R1::den, _R2::den>::value;
5278 public:
53- typedef typename ratio< _R1::num * den / _R1::den + _R2::num * den / _R2::den, den >::type type;
79+ typedef typename ratio< _R1::num * m_lcm_den / _R1::den + _R2::num * m_lcm_den / _R2::den, m_lcm_den >::type type;
5480 };
5581
5682 template<class _R1, class _R2>
5783 class ratio_substruct
5884 {
59- static const intmax_t den = static_lcm<_R1::den, _R2::den>::value;
85+ static const intmax_t m_lcm_den = static_lcm<_R1::den, _R2::den>::value;
6086 public:
61- typedef typename ratio< _R1::num * den / _R1::den - _R2::num * den / _R2::den, den >::type type;
87+ typedef typename ratio< _R1::num * m_lcm_den / _R1::den - _R2::num * m_lcm_den / _R2::den, m_lcm_den >::type type;
6288 };
6389
6490 template<class _R1, class _R2>
@@ -91,6 +117,81 @@
91117 {
92118 };
93119
120+template<class _R1, class _R2>
121+class ratio_less
122+{
123+ template<class _TR1, class _TR2
124+ , intmax_t _I1 = _TR1::num / _TR1::den, intmax_t _D1 = _TR1::num % _TR1::den
125+ , intmax_t _I2 = _TR2::num / _TR2::den, intmax_t _D2 = _TR2::num % _TR2::den>
126+ struct comp_less_impl : public constant<bool, _I1 < _I2>
127+ {
128+ };
129+
130+ template<class _TR1, class _TR2, intmax_t _I>
131+ struct comp_less_impl<_TR1, _TR2, _I, 0, _I, 0> : public constant<bool, false>
132+ {
133+ };
134+
135+ template<class _TR1, class _TR2, intmax_t _I, intmax_t _D1>
136+ struct comp_less_impl<_TR1, _TR2, _I, _D1, _I, 0> : public constant<bool, false>
137+ {
138+ };
139+
140+ template<class _TR1, class _TR2, intmax_t _I, intmax_t _D2>
141+ struct comp_less_impl<_TR1, _TR2, _I, 0, _I, _D2> : public constant<bool, true>
142+ {
143+ };
144+
145+ template<class _TR1, class _TR2, intmax_t _I, intmax_t _D1, intmax_t _D2>
146+ struct comp_less_impl<_TR1, _TR2, _I, _D1, _I, _D2> : public constant<bool, _D1 < _D2>
147+ {
148+ };
149+
150+ template<class _TR1, class _TR2, intmax_t _S1 = static_sign<_TR1::num>::value, intmax_t _S2 = static_sign<_TR2::num>::value>
151+ struct less_impl : public constant<bool, (_S1 < _S2)>
152+ {
153+ };
154+ template<class _TR1, class _TR2>
155+ struct less_impl<_TR1, _TR2, 1, 1>
156+ {
157+ static const bool value = comp_less_impl<_TR1, _TR2>::value;
158+ };
159+ template<class _TR1, class _TR2>
160+ struct less_impl<_TR1, _TR2, -1, -1>
161+ {
162+ static const bool value = comp_less_impl< ratio<-_TR2::num, _TR2::den>, ratio<-_TR1::num, _TR1::den> >::value;
163+ };
164+
165+public:
166+ static const bool value = less_impl<_R1, _R2>::value;
167+};
168+
169+template<class _R1, class _R2>
170+class ratio_less_equal : public constant<bool, !(ratio_less<_R2, _R1>::value)>
171+{
172+};
173+
174+template<class _R1, class _R2>
175+class ratio_greater : public constant<bool, ratio_less<_R2, _R1>::value>
176+{
177+};
178+
179+template<class _R1, class _R2>
180+class ratio_greater_equal : public constant<bool, !(ratio_less<_R1, _R2>::value)>
181+{
182+};
183+
184+template<typename _TN>
185+class is_ratio
186+{
187+ template<typename _TT>
188+ struct is_ratio_impl : public iml::detail::false_type {};
189+ template<intmax_t _N, intmax_t _D>
190+ struct is_ratio_impl< ratio<_N, _D> > : public iml::detail::true_type {};
191+public:
192+ static const bool value = is_ratio_impl<_TN>::value;
193+};
194+
94195 } // end of namespace iml
95196
96197 #endif
--- trunk/framework/src/iris_limits.h (revision 95)
+++ trunk/framework/src/iris_limits.h (revision 96)
@@ -8,7 +8,7 @@
88 * @version 1.0
99 *
1010 * @par copyright
11- * Copyright (C) 2010 Takazumi Shirayanagi\n
11+ * Copyright (C) 2010-2011 Takazumi Shirayanagi\n
1212 * The new BSD License is applied to this software.
1313 * see iris_LICENSE.txt
1414 */
@@ -18,10 +18,19 @@
1818 #define _IRIS_iris_limits_H_
1919
2020 //======================================================================
21+// define
22+#if !defined(__STDC_LIMIT_MACROS)
23+# define __STDC_LIMIT_MACROS // iris では定義する
24+#endif
25+
26+//======================================================================
2127 // include
2228 #include "iris_compiler.h"
2329 #include <limits.h>
2430
31+//======================================================================
32+// define
33+
2534 //--------------------
2635 // long long
2736 #if !defined(ULLONG_MAX)
@@ -89,4 +98,8 @@
8998 #define IRIS_INTEGRAL_MAX_BITS _INTEGRAL_MAX_BITS
9099
91100
101+#if !defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
102+# define __STDC_LIMIT_MACROS
92103 #endif
104+
105+#endif
Show on old repository browser