Stroika Library 3.0d21
 
Loading...
Searching...
No Matches
Activity.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ************************************** Activity ********************************
10 ********************************************************************************
11 */
12 template <convertible_to<Characters::String> STRINGISH_T>
13 constexpr Activity<STRINGISH_T>::Activity (const STRINGISH_T& arg)
14 requires (is_array_v<STRINGISH_T>)
15 {
16 Assert (size (arg) == size (fArg_));
17 for (size_t i = 0; i < size (arg); ++i) {
18 fArg_[i] = arg[i];
19 }
20 }
21 template <convertible_to<Characters::String> STRINGISH_T>
22 constexpr Activity<STRINGISH_T>::Activity (const STRINGISH_T& arg)
23 requires (not is_array_v<STRINGISH_T>)
24 : fArg_{arg}
25 {
26 }
27 template <convertible_to<Characters::String> CTOR_ARG>
28 Characters::String Activity<CTOR_ARG>::AsString () const
29 {
30 return fArg_;
31 }
32
33 /*
34 ********************************************************************************
35 ************************ LazyEvalActivity<CTOR_ARG> ****************************
36 ********************************************************************************
37 */
38 template <typename CTOR_ARG>
39 constexpr LazyEvalActivity<CTOR_ARG>::LazyEvalActivity (const CTOR_ARG& arg)
40 requires (is_invocable_r_v<Characters::String, CTOR_ARG>)
41 : fArg_{arg}
42 {
43 }
44 template <typename CTOR_ARG>
45 Characters::String LazyEvalActivity<CTOR_ARG>::AsString () const
46 {
47 return fArg_ (); // what makes this more efficient is that we can just capture data in a lambda (by reference)
48 // and just invoke that logic during exception processing when we need to convert the activity to a string rep
49 }
50 /*
51 ********************************************************************************
52 *************************** DeclareActivity<ACTIVITY> **************************
53 ********************************************************************************
54 */
55 template <typename ACTIVITY>
56 inline DeclareActivity<ACTIVITY>::DeclareActivity (const ACTIVITY* activity) noexcept
57 : fNewTopOfStackElt_{activity, Private_::Activities_::sTop_}
58 {
59 // no locks needed because the variables are thread local
60 if (activity != nullptr) {
61 Private_::Activities_::sTop_ = &fNewTopOfStackElt_;
62 }
63 }
64 template <typename ACTIVITY>
65 inline DeclareActivity<ACTIVITY>::~DeclareActivity ()
66 {
67 if (fNewTopOfStackElt_.fActivity != nullptr) {
68 // no locks needed because the variables are thread local
69 Assert (Private_::Activities_::sTop_ == &fNewTopOfStackElt_);
70 Private_::Activities_::sTop_ = Private_::Activities_::sTop_->fPrev;
71 }
72 }
73
74}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
constexpr Activity(const STRINGISH_T &arg)
Definition Activity.inl:13