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