C++????????????CPPFormatLibrary
???????????? ???????[ 2015/9/23 11:40:22 ] ??????????????????? .NET
?????????????д?????????????£???????????????????????????????GitHub??????CPPFormat???????????????????????????????????????????????CPPFormatLibrary????????FL??
??????????????????????????????????????C++????????и?????????????????????C??????sprintf????C++??stringstream?????????????????????????C????????????????sprintf????????????????????????????????????????????????±???????stringstream??Ч??????????С????????????????boost????format????????????Ч???????????й???????д??fastformat???????http://fastformat.sourceforge.net/ ?????????????????????????????????????????????????????????????δ?????????????????д???FL???????????????fastformat???????л????
????FL??fastformat??????????????????????????C++??????????????????????????????.net??????????.net????????????????????????£?http://www.cnblogs.com/zyh-nhy/archive/2007/10/11/921240.html ??fastformat????FL??????Щ??????????????????????????????????fastformat???????{0??5}??????????????????FL???????fastformat??FL????????????.net??format??????????????????.net????????????????δ???????
??????????FL?е????????????????????????????????
1 // Test
2 #include "Format.hpp"
3
4 #include "Format/ProgressTimer.hpp"
5
6 #define TEST_PERFORMANCE_IN_TOOLS 0
7
8 using namespace FormatLibrary;
9
10 #include <iostream>
11 #include <vector>
12 using namespace std;
13
14 void TestProfile()
15 {
16 const int TEST_COUNT = 100000;
17
18 {
19 Profile::ProgressTimer Timer("FL");
20
21 for (int i = 0; i < TEST_COUNT; ++i)
22 {
23 string str;
24 StandardLibrary::FormatTo(str?? "{0}--#--{1??8}--#--{2}"?? 100?? -40.2f?? " String ");
25 StandardLibrary::FormatTo(str?? "{0}--#--{1??8}--#--{1}"?? 100?? -40.2f);
26 StandardLibrary::FormatTo(str?? "{0}--#--{1??8}--#--{3}"?? 100?? -40.2f?? std::string("xxx"));
27 }
28 }
29
30 #if !FL_COMPILER_MSVC
31 #define sprintf_s sprintf
32 #endif
33
34 #if !TEST_PERFORMANCE_IN_TOOLS
35 {
36 Profile::ProgressTimer Timer("CL");
37
38 for (int i = 0; i < TEST_COUNT; ++i)
39 {
40 string str;
41 char szBuf[64];
42 sprintf_s(szBuf?? "%d--#--%8.2f--#--%s"?? 100?? -40.2f?? " String ");
43 str = szBuf;
44 sprintf_s(szBuf?? "%d--#--%8.2f--#--%f"?? 100?? -40.2f?? 0.0f);
45 str = szBuf;
46 sprintf_s(szBuf?? "%d--#--%8.2f--#--%%f"?? 100?? -40.2f);
47 str = szBuf;
48 }
49 }
50 #endif
51 }
52
53 #if FL_PLATFORM_HAS_CPP11 && (FL_COMPILER_MSVC||FL_PLATFORM_MACOS)
54 #include <thread>
55
56 void TestProfileMultiThread()
57 {
58 std::thread t0( TestProfile );
59 std::thread t1( TestProfile );
60 std::thread t2( TestProfile );
61
62 t0.join();
63 t1.join();
64 t2.join();
65 }
66 #endif
67
68 int main()
69 {
70 StandardLibrary::STLGlobalPatternStorageA Storage;
71 Utility::TAutoString<char> TestStr;
72
73 const char* pszTest = "{0}??xxxd{1:d2}={2??3:d2} !! {{}} {0??-5:d8}";
74 Storage.LookupPatterns(pszTest?? strlen(pszTest));
75
76 std::string str;
77 StandardLibrary::FormatTo(str?? "test{0}"?? 10);
78
79 StandardLibrary::FormatTo(str?? "{0}"?? char('c')?? short(2));
80
81 #if FL_COMPILER_MSVC
82 StandardLibrary::FormatTo(str?? "0x{0:x}"?? 100?? DWORD(100));
83 #endif
84
85 std::wstring wstr;
86 StandardLibrary::FormatTo(wstr?? L"Test{1}?? {2:f4}?? {0}?? {0??4}"?? L" X "?? 20?? -10.005f);
87
88 cout << str << endl;
89 wcout << wstr << endl;
90
91 TestProfile();
92
93 #if FL_PLATFORM_HAS_CPP11 && (FL_COMPILER_MSVC||FL_PLATFORM_MACOS)
94 TestProfileMultiThread();
95 #endif
96
97 return 0;
98 }
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11