FINAL CUT
sgr_optimizer.h
1 /***********************************************************************
2 * sgr_optimizer.h - Combines SGR (Select Graphic Rendition) attributes *
3 * *
4 * This file is part of the FINAL CUT widget toolkit *
5 * *
6 * Copyright 2019-2023 Markus Gans *
7 * *
8 * FINAL CUT is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation; either version 3 of *
11 * the License, or (at your option) any later version. *
12 * *
13 * FINAL CUT is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this program. If not, see *
20 * <http://www.gnu.org/licenses/>. *
21 ***********************************************************************/
22 
23 /* Standalone class
24  * ════════════════
25  *
26  * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
27  * ▕ SGRoptimizer ▏
28  * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
29  */
30 
31 #ifndef SGR_OPTIMIZER_H
32 #define SGR_OPTIMIZER_H
33 
34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
35  #error "Only <final/final.h> can be included directly."
36 #endif
37 
38 #include <array>
39 #include <string>
40 #include <vector>
41 
42 namespace finalcut
43 {
44 
45 //----------------------------------------------------------------------
46 // class SGRoptimizer
47 //----------------------------------------------------------------------
48 
49 class SGRoptimizer final
50 {
51  public:
52  // Constants
53  static constexpr std::string::size_type ATTR_BUF_SIZE{8192u};
54 
55  // Constructors
56  explicit SGRoptimizer (std::string&);
57 
58  // Method
59  void optimize();
60 
61  private:
62  struct parameter
63  {
64  std::size_t start;
65  std::size_t end;
66  };
67 
68  // Constants
69  static constexpr auto NOT_SET = static_cast<std::size_t>(-1);
70 
71  // Methods
72  void findParameter();
73  auto isSGRStart (std::size_t) -> bool;
74  void combineParameter();
75  void handleSGRterminating ( const std::vector<parameter>::const_iterator, std::size_t&
76  , std::size_t, std::size_t );
77 
78  // Data member
79  std::string& seq;
80  std::vector<parameter> csi_parameter{};
81 };
82 
83 } // namespace finalcut
84 
85 #endif // SGR_OPTIMIZER_H
Definition: class_template.cpp:25
Definition: sgr_optimizer.h:49