RW Foundations Caturday drop :
v220312 edition
Anime Catgrill Meidos will surely be
wildly popular once they become real Anon
and we must all diligently strive forward towards that day!! :^)
We made changes in this drop that have some improvements to error-detection with the dolldrops process. And, for the first time, a bit of error-
correction too. A new function for
RW Bumpmaster in this drop is
pull_json_retry(). It will actually make another go of it, if the dolldrop turns out invalid for some reason.
This size-checks enhancement serves a dual-purpose;
a) be more efficient with bandwidth resources, and
b) perform general due-diligence to help avoid unintentional misuse issues. In our testing things seem to be working pretty well so far with it.
===
So, last drop we were talking about the functions that load up the structure for holding a thread's info. Namely, both it's OP data, as well as all post's data for that thread -- and into just a single object (which now can easily be passed around and processed). We load up a container-full of these things, and return
that back to the caller. Now it's time to take a spin at printing all this lovely text out to the console.
As you recall, we last left off at the top_bump_thrds() function. And so we pick back up with it again; but this time on the
other side, and
calling it from the Bumpmaster demo's main():
>main_bumpmaster.cpp snippet
// load a new container with catalog's Page 1 threads + posts; in bump-order
auto const top_thrds = bump.top_bump_thrds(cat_json, thrd_lim, site, board);
// cycle the top threads (& print their data)
size_t t_idx{0}; //
for (auto const& t : top_thrds) { //
puts("\n\n --=^=--\n");
cout << " Bump " << ++t_idx // prt thrd's data
<< "\n =======================================\n" //
<< setw(8) << setfill(' ') << t.id << " : " //
<< t.subj << "\n\n' " << t.msg << " '\n"; //
// calc starting post's thread index
auto const sz = static_cast<int>(t.posts.size()); // cast avoids overflow
auto const start{sz - post_lim}; // for this subtraction
// cycle the latest posts (& print their data)
for (auto p_idx{(start >= 0 ? start : 0)}; // ensure we have valid index,
p_idx < sz; ++p_idx) { // (as sz might be < post_lim)
auto const& p = t.posts[p_idx]; // index to post,
cout << '\n' // prt post's data
<< setw(33) << setfill(' ') << "r " << (p_idx + 1)
<< "\n ------------------------------------\n"
<< setw(8) << setfill(' ') << p.id << " : " << p.date << "\n' "
<< p.msg << " '\n";
}
}
This code takes that container object (we named
top_thrds since it's about the Page One threads) and traverses each element in it, one-by-one, via that C++ range-for loop (each of these elements happen to be one of those
Thread Structures we talked about). We name these simply as
t (for thread). Such a terse name is OK for this context, since it's a small scope inside the loop, and it's also a good symmetry with
p (for post, which we'll name later).
First thing we do is print out the thread struct's first 3 fields,
id, subj, & msg along with a few little formatting tweaks. Next, we calculate the starting printout-post's index inside the thread. We do this b/c we just want to print the
latest 5 posts to the terminal, not all of them. You might recognize that this is pretty much how a standard IB index page works.
Anyway, to get the correct starting index for post printouts, we just subtract the post-limit count (5), from
size() of the
posts container field in the thread struct (that 'open-ended' one). Remember that in C and most other programming languages, array indices start at
0. So, say there were 20 posts altogether, we'd begin printouts with index 15 (post #16), then index 16 (post #17), and so on to index 19 (post #20).
Finally, we just print out the 5 post's 3 fields,
id, date, & msg, again with some little formatting tweaks. That's it, we're done with that thread printout. Lather, rinse, repeat for the next 9 threads. Then repeat the whole cycle for all the board listed in this 'open-ended' container of URI strings:
// container of various IB URI strings
// -try other boards you like, Anon! :^)
// clang-format off
vector<string> const board_uris{
// NOTE: currently supporting only Lynxchan sites (for v220312)
"https://alogs.space/robowaifu/",
"https://alogs.space/pdfs/",
"https://prolikewoah.com/geimu/",
"https://late.city/late/",
"https://anon.cafe/christian/",
};
Congrats Anon! Over the past three drops, we've created a handy multi-board offline text reader for IBs. It's both lightweight on resources and
fast. BTW, you may need to increase your terminal's output buffer size, since this could easily grow to thousands of lines of text if you add lots of boards into your list. Later we'll add what
BUMP does to allow other, non-Lynxchan boards as well.
Well we hope you're getting lots of bright ideas and clever robowaifu-making insights, and are moving forward day-by-day towards your goals with her.
Keep your dreams alive Anon! :^)
Cheers.
===
>version.log
v.220312
---------------
-check Json validity on pull_json_retry() calls; bumpmaster
-add pull_json_retry(); bumpmaster
-mv to tuple<bool, Json> ret, pull_json_drop(); bumpmaster
-add do_catalog() member funcs; bumpmaster, dolldrop
-begin checking dolldrop sizes
chkd_pull_g(); dolldrop
pull_json_drop(); bumpmaster
-add sz_match(); bumpmaster
-add chk_dropsizes(); mailstop_util
-add set_sz(), get_sz() wrappers; mailstop_util
-add 'sz' field, Dropdata; mailstop_util
-mv to fs::path filenames; general
>rw_bumpmaster-v220312.tar.xz.sha256sum
57018697c25c6f137505e71aed2fe4f7d88169e8e1fa02fc487713ab6316cee6 *rw_bumpmaster-v220312.tar.xz
>backup drop
https://files.catbox.moe/9rrvst.7z