Stroika是現代,便攜式,C ++應用程序框架。它通過提供安全,靈活的,構建塊以及其他有用的庫中的包裝來使編寫C ++應用程序更容易,從而幫助他們更加毫無用處地一起工作。
String a = u8" abc " ;
String b = u32 " abc " ;
CallFunction (a+b);
// trim whitespace, and convert to u16string for some legacy API
std::u16string uuu = (a+b).Trim ().As<u16string>();
// tokenize
String t{ " ABC DEF G " };
Assert (t.Tokenize ()[1] == "DEF"); // most Stroika types automatically support formattable<>
DbgTrace ( " v = {} " _f, v); // to a tracelog file, or debugger
cerr << " v = {} " _f (v) << endl; // OR iostreams (unicode mapped automatically) // nb: String is an Iterable<Character>,
// despite internally representing the characters very differently
bool IsAllWhitespace (String s) const
{
return not s. Find ([] (Character c) -> bool { return not c. IsWhitespace (); });
}
Iterable< int > c { 1 , 2 , 2 , 5 , 9 , 4 , 5 , 6 };
EXPECT_TRUE (c.Distinct ().SetEquals ({ 1 , 2 , 4 , 5 , 6 , 9 }));
Iterable< int > c { 3 , 4 , 7 };
// Map iterates over 'c' and produces the template argument container
// automatically by appending the result of each lambda application
EXPECT_EQ ((c.Map<vector<String>> ([] ( int i) { return " {} " _f (i); }), vector<String>{ " 3 " , " 4 " , " 7 " }));牛(抄寫案通常可以顯著提高大多數常見情況的性能)
由訪問模式定義的API,例如stack = push/pop,sequence = array樣訪問,map = {from:to},等等
代表性透明度
Stroika提供了豐富的容器拱形和數據結構的隱含。
extern void f (Set< int >);
// use the default Set<> representation - the best for type 'int'
Set< int > s{ 1 , 2 , 3 };
f (s); // data not actually copied - Stroika containers use 'copy-on-write (COW)'
s = Concrete::SortedSet_SkipList< int >{s}; // Use a skiplist to represent the set
f (s); // call f the same way regardless of data structure used for implementation
// set equality not order dependent (regardless of data structure)
Assert (s == { 2 , 3 , 1 }); 有關更多詳細信息,請參見容器樣本
MyClass someObject = ...;
VariantValue v = mapper.FromObject (someObject); // Map object to a VariantValue
// Serialize using any serialization writer defined in
// Stroika::Foundation::DataExchange::Variant (we selected JSON)
Streams::MemoryStream:: Ptr <byte> tmpStream = Streams::MemoryStream::New<byte> ();
Variant::JSON::Writer{}.Write (v, tmpStream);
// You can persist these to file if you wish
{
using namespace IO ::FileSystem ;
FileOutputStream:: Ptr tmpFileStream =
FileOutputStream::New ( WellKnownLocations::GetTemporary () / " t.txt " );
Variant::JSON::Writer{}. Write (v, tmpFileStream);
}有關更多詳細信息,請參見序列化樣本
Route{ " variables/(.+) " _RegEx,
// explicit message handler
[ this ] (Message& m, const String& varName) {
WriteResponse (m. rwResponse (), kVariables_ , kMapper . FromObject ( fWSImpl_ -> Variables_GET (varName)));
}},
Route{HTTP::MethodsRegEx:: kPost , " plus " _RegEx,
// automatically map high level functions via ObjectVariantMapper
ObjectRequestHandler::Factory{ kBinaryOpObjRequestOptions_ ,
[ this ] (Number arg1, Number arg2) { return fWSImpl_ -> plus (arg1, arg2); }}},有關更多詳細信息,請參見Web服務示例。
進行壓縮,加密,IO,網絡,數據處理,所有這些都毫無貼合
// @todo INCOMPLETE - BAD EXAMPLE---
const OpenSSL::DerivedKey kDerivedKey =
OpenSSL::EVP_BytesToKey{ OpenSSL::CipherAlgorithms::kAES_256_CBC (), OpenSSL::DigestAlgorithms:: kMD5 , " password " };
const Memory::BLOB srcText =
Memory::BLOB::FromHex ( " 2d ... " ); // ...
// EncodeAES takes a stream, and produces a stream
// which can be chained with the gzip Transformer, which takes a stream, and produces a
Compression::GZip::Compress::New ().Transform (EncodeAES ( kDerivedKey , srcText.As<Streams::InputStream:: Ptr <byte>> (), AESOptions::e256_CBC))從風格上講,Stroika與標準的C ++庫,Boost和許多其他C ++庫不同,因為它(相對)包含了基於模板的通用性的對象面向的抽象(請參閱stroika-apprace-apprace-to-performance.md)。類型層次結構的抽象更適合人們推理方式,模板和概念(雖然強大)可以輕巧而模糊的程序員意圖。此外,Stroika強調將接口與實現的分離:仔細記錄標題中的接口,並將實現分離到其他文件。
Stroika由2層組成:基礎,該基礎提供適用於大多數應用程序的建築塊類,以及一系列特定域的框架,這些框架在不同域中提供了豐富的代碼集合。

框架取決於基礎;基礎模塊經常相互取決於彼此;但是,基礎層代碼在基礎之外沒有依賴項(標準C ++庫除外,並且所選或引用的各種第三頁製品庫,例如OpenSSL)。
不想閱讀 - 只想編碼。逐步說明,在幾分鐘內(少於下載/編譯時間)在計算機上構建您的第一個基於Stroika的應用程序,這會有所不同)。
斯特羅卡的最大優勢也是它最大的弱點:
Stroika V3在主動開發中(不穩定),需要C ++ 20或更高版本。
Stroika v2.1是穩定的(在維護中),需要C ++ 17或更高版本。版本2.1還有條件地支持許多C ++ 20功能(例如,如果有的話,例如三向繁殖等)。
Stroika v2.0非常穩定,需要C ++ 14或更高版本。 Stroika v2.0用於為各種開源和商業應用提供動力。
Linux,MacOS,Windows
Stroika V3
TBD,但到目前為止,看起來像VS2K22(17.9)或更高版本,在Windows,Xcode 15(.2)或更高版本上,在MacOS上,G ++ 11或更高版本,以及Clang ++ 15或更高版本。
Stroika v2.1
在X86,ARM(+M1),GCC 8 THRU GCC 12,Clang 6 Thru Clang 14,Visual Studio.net 2017,Visual Studio.net 2019和Visual Studio.NET 2022,Xcode 13、14、15測試。
Stroika v2.0
在X86,ARM,GCC 5到達GCC 8,clang 3 thru Clang 6,Xcode 8 thru 9中測試。
github動作
| 分支 | 地位 | |
|---|---|---|
| V3釋放 | ![]() | .github/workflows/build-n-test.yml |
| v3-dev | ![]() | .github/workflows/build-n-test.yml |
有關個人發布更改的更多詳細信息,請參見:
repartion-notes.md
“入門”,構建說明,設計和其他文檔:
文件/
瀏覽樣品也是一個好方法:
樣品/
請在以下網址報告錯誤/問題:
http://stroika-bugs.sophists.com