• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PredatorCZ / PreCore / 461

pending completion
461

push

github-actions-ci

PredatorCZ
update readme

3204 of 6096 relevant lines covered (52.56%)

354.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/include/spike/app/out_context.hpp
1
/*  Spike is universal dedicated module handler
2

3
    Copyright 2021-2023 Lukas Cone
4

5
    Licensed under the Apache License, Version 2.0 (the "License");
6
    you may not use this file except in compliance with the License.
7
    You may obtain a copy of the License at
8

9
        http://www.apache.org/licenses/LICENSE-2.0
10

11
    Unless required by applicable law or agreed to in writing, software
12
    distributed under the License is distributed on an "AS IS" BASIS,
13
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
    See the License for the specific language governing permissions and
15
    limitations under the License.
16
*/
17

18
#pragma once
19
#include "cache.hpp"
20
#include "spike/app_context.hpp"
21
#include "spike/format/ZIP.hpp"
22
#include "spike/io/binwritter.hpp"
23
#include <optional>
24
#include <set>
25
#include <sstream>
26
#include <vector>
27

28
struct CounterLine;
29

30
struct ZIPExtactContext : AppExtractContext {
31
  ZIPExtactContext(const std::string &outFile)
×
32
      : records(outFile), outputFile(outFile), entries(entriesStream),
×
33
        cache(std::in_place) {}
×
34
  ZIPExtactContext(const std::string &outFile, bool)
×
35
      : records(outFile), entries(entriesStream) {}
×
36
  ZIPExtactContext(const ZIPExtactContext &) = delete;
37
  ZIPExtactContext(ZIPExtactContext &&) = delete;
38

39
  void NewFile(const std::string &path) override;
40
  void SendData(std::string_view data) override;
41
  bool RequiresFolders() const override;
42
  void AddFolderPath(const std::string &path) override;
43
  void GenerateFolders() override;
44
  using cache_begin_cb = void (*)();
45
  void FinishZIP(cache_begin_cb cacheBeginCB);
46

47
  std::string prefixPath;
48
  std::function<void()> forEachFile;
49

50
private:
51
  friend struct ZIPMerger;
52
  BinWritter records;
53
  std::string outputFile;
54
  std::stringstream entriesStream;
55
  BinWritterRef entries;
56
  ZIPLocalFile zLocalFile{ZIPLocalFile::ID, 10};
57
  size_t curLocalFileOffset = 0;
58
  size_t numEntries = 0;
59
  size_t curFileSize = 0;
60
  std::string curFileName;
61
  std::optional<CacheGenerator> cache;
62
  std::vector<uint64> fileOffsets;
63
  void FinishFile(bool final = false);
64
};
65

66
struct ZIPMerger {
67
  ZIPMerger(const std::string &outFiles, const std::string &outEntries)
×
68
      : entries(outEntries), records(outFiles), entriesFile(outEntries),
×
69
        outFile(outFiles) {}
×
70
  ZIPMerger() = default;
71
  ZIPMerger(const ZIPMerger &) = delete;
72
  ZIPMerger(ZIPMerger &&) = delete;
73
  using cache_begin_cb = void (*)();
74
  void Merge(ZIPExtactContext &other, const std::string &recordsFile);
75
  void FinishMerge(cache_begin_cb cacheBeginCB);
76

77
private:
78
  BinWritter entries;
79
  BinWritter records;
80
  std::string entriesFile;
81
  std::string outFile;
82
  size_t numEntries = 0;
83
  CacheGenerator cache;
84
};
85

86
struct IOExtractContext : AppExtractContext, BinWritter {
87
  std::string outDir;
88
  std::set<std::string> folderTree;
89
  std::function<void()> forEachFile;
90

91
  IOExtractContext(const std::string &outDir_) : outDir(outDir_) {}
×
92

93
  void NewFile(const std::string &path) override;
94
  void SendData(std::string_view data) override;
95
  bool RequiresFolders() const override;
96
  void AddFolderPath(const std::string &path) override;
97
  void GenerateFolders() override;
98
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc