| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/commandqueue.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "commandqueue.h"cxx . . $ `<file>/src/core/commandqueue.h`/ |
| 5 | |
| 6 | #include <QByteArray> |
| 7 | #include <algorithm> |
| 8 | #include <filesystem> |
| 9 | #include <iterator> |
| 10 | #include <spdlog/spdlog.h> |
| 11 | #include <utility> |
| 12 | |
| 13 | CommandQueuecxx . . $ CommandQueue#::CommandQueuecxx . . $ CommandQueue#CommandQueue(7173eb3e5e1c41a0).(stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<stdcxx . . $ std/::stringcxx . . $ std/string#> &&multiCommandFiles) noexcept |
| 14 | : multiCommandFiles_cxx . . $ CommandQueue#multiCommandFiles_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(multiCommandFiles)) |
| 15 | { |
| 16 | commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(50); |
| 17 | } |
| 18 | |
| 19 | bool CommandQueuecxx . . $ CommandQueue#::hasCommandQueuedForcxx . . $ CommandQueue#hasCommandQueuedFor(7c222eea44a24d43).(stdcxx . . $ std/::stringcxx . . $ std/string# const &file) |
| 20 | { |
| 21 | // find the last queued command for the file |
| 22 | auto it = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).(commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crbegincxx . . $ std/vector#crbegin(7ffd9c4e53ea04dd).(), commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crendcxx . . $ std/vector#crend(7ffd9c4e53ea04dd).(), |
| 23 | [&](auto const &v) { return v.first == file; }); |
| 24 | return it != commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crendcxx . . $ std/vector#crend(7ffd9c4e53ea04dd).(); |
| 25 | } |
| 26 | |
| 27 | void CommandQueuecxx . . $ CommandQueue#::addcxx . . $ CommandQueue#add(358a66d3ce188717).(stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#> &&cmd) |
| 28 | { |
| 29 | // find the last queued command for the file |
| 30 | auto lastIt = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).(commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crbegincxx . . $ std/vector#crbegin(7ffd9c4e53ea04dd).(), commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crendcxx . . $ std/vector#crend(7ffd9c4e53ea04dd).(), |
| 31 | [&](auto const &v) { return v.first == cmd.firstcxx . . $ std/pair#first.; }); |
| 32 | |
| 33 | if (lastIt != commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crendcxx . . $ std/vector#crend(7ffd9c4e53ea04dd).() && lastIt->cxx . . $ std/reverse_iterator#`operator->`(a68f0626e749d9f6).secondcxx . . $ std/pair#second. ==cxx . . $ std/`operator==`(5ea818b58063a774). cmd.secondcxx . . $ std/pair#second.) |
| 34 | return; // command already queued |
| 35 | |
| 36 | // insert command at the end by default |
| 37 | auto insertIt = commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(); |
| 38 | |
| 39 | // when a different command is already queued for that file... |
| 40 | if (lastIt != commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().crendcxx . . $ std/vector#crend(7ffd9c4e53ea04dd).()) { |
| 41 | |
| 42 | auto file = stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#(cmd.firstcxx . . $ std/pair#first.).filenamecxx . . $ std/filesystem/__cxx11/path#filename(159787a050b29eb0).(); |
| 43 | if (multiCommandFiles_cxx . . $ CommandQueue#multiCommandFiles_..containscxx . . $ std/unordered_set#contains(258174a872aadb09).(file)) { |
| 44 | // insert it after the last queued command for that particular file |
| 45 | insertIt =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(f272f0205960ab01). lastIt.basecxx . . $ std/reverse_iterator#base(6a6a6650700d410).(); |
| 46 | } |
| 47 | else { |
| 48 | // remove the previous queued command |
| 49 | commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().erasecxx . . $ std/vector#erase(351407f384f345bc).(stdcxx . . $ std/::prevcxx . . $ std/prev(31d62cd24490f169).(lastIt.basecxx . . $ std/reverse_iterator#base(6a6a6650700d410).())); |
| 50 | insertIt =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(f272f0205960ab01). commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(); // refresh iterator |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().emplacecxx . . $ std/vector#emplace(f067880028bce17f).(insertIt, stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cmd)); |
| 55 | } |
| 56 | |
| 57 | QByteArraycxx . . $ QByteArray# CommandQueuecxx . . $ CommandQueue#::toRawDatacxx . . $ CommandQueue#toRawData(b3c286cec66e09f4).() |
| 58 | { |
| 59 | QByteArraycxx . . $ QByteArray# datacxx . . $ QByteArray#QByteArray(ced63f7c635d850d).; |
| 60 | for (auto const &[path, value] : commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).()) { |
| 61 | data +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). path.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); |
| 62 | data +=cxx . . $ QByteArray#`operator+=`(1815c0e4073627df). '\0'; |
| 63 | data +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). value.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(); |
| 64 | data +=cxx . . $ QByteArray#`operator+=`(1815c0e4073627df). '\0'; |
| 65 | } |
| 66 | |
| 67 | commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).().clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 68 | return datacxx . . $ QByteArray#QByteArray(9f1b912973d89fea).; |
| 69 | } |
| 70 | |
| 71 | void CommandQueuecxx . . $ CommandQueue#::logCommandscxx . . $ CommandQueue#logCommands(83f5f38750778ac8).() const |
| 72 | { |
| 73 | for (auto const &[path, value] : commands_cxx . . $ CommandQueue#commands_.) |
| 74 | SPDLOG_INFOcxx . . $ `<external>/13613935168682455490/spdlog.h:320:13`!("{}: {}", path, value); |
| 75 | } |
| 76 | |
| 77 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> &CommandQueuecxx . . $ CommandQueue#::commandscxx . . $ CommandQueue#commands(d258e1be62a8acf4).() |
| 78 | { |
| 79 | return commands_cxx . . $ CommandQueue#commands_.; |
| 80 | } |