Welcome to mirror list, hosted at ThFree Co, Russian Federation.

glyph_usage_tracker.hpp « utils « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ee92268ef28a2fd730ae293864835d7e211185b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include "drape/drape_diagnostics.hpp"

#include "base/string_utils.hpp"

#include "std/map.hpp"
#include "std/set.hpp"
#include "std/list.hpp"
#include "std/mutex.hpp"
#include "std/string.hpp"
#include "std/unordered_set.hpp"

namespace dp
{

class GlyphUsageTracker
{
public:
  struct UnexpectedGlyphData
  {
    size_t m_counter = 0;
    size_t m_group = 0;
    set<size_t> m_expectedGroups;
  };
  using UnexpectedGlyphs = map<strings::UniChar, UnexpectedGlyphData>;
  using InvalidGlyphs = map<strings::UniChar, size_t>;

  struct GlyphUsageStatistic
  {
    string ToString() const;

    InvalidGlyphs m_invalidGlyphs;
    UnexpectedGlyphs m_unexpectedGlyphs;
  };

  static GlyphUsageTracker & Instance();

  void AddInvalidGlyph(strings::UniString const & str, strings::UniChar const & c);
  void AddUnexpectedGlyph(strings::UniString const & str, strings::UniChar const & c,
                          size_t const group, size_t const expectedGroup);

  GlyphUsageStatistic Report();

private:
  GlyphUsageTracker() = default;
  GlyphUsageTracker(GlyphUsageTracker const & rhs) = delete;
  GlyphUsageTracker(GlyphUsageTracker && rhs) = delete;

private:
  GlyphUsageStatistic m_glyphStat;
  unordered_set<string> m_processedStrings;

  mutex m_mutex;
};

} // namespace dp