Coverage Report

Created: 2026-09-06 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libetonyek/src/lib/contexts/PAG1AnnotationContext.cpp
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/*
3
 * This file is part of the libetonyek project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 */
9
10
#include "PAG1AnnotationContext.h"
11
12
#include <cassert>
13
14
#include "PAGCollector.h"
15
#include "IWORKTextElement.h"
16
#include "IWORKToken.h"
17
#include "PAG1ParserState.h"
18
19
namespace libetonyek
20
{
21
22
PAG1AnnotationContext::PAG1AnnotationContext(PAG1ParserState &state, const CollectFunction_t &collect)
23
0
  : PAG1XMLElementContextBase(state)
24
0
  , m_collect(collect)
25
0
  , m_target()
26
0
{
27
0
}
28
29
void PAG1AnnotationContext::startOfElement()
30
0
{
31
0
  if (isCollector())
32
0
  {
33
0
    assert(!getState().m_currentText);
34
0
    getState().m_currentText = getCollector().createText(getState().m_langManager, true);
35
0
  }
36
0
}
37
38
void PAG1AnnotationContext::attribute(const int name, const char *const value)
39
0
{
40
0
  if (name == (+IWORKToken::NS_URI_SF | IWORKToken::target))
41
0
    m_target = value;
42
0
  else
43
0
    PAG1XMLElementContextBase::attribute(name, value);
44
0
}
45
46
IWORKXMLContextPtr_t PAG1AnnotationContext::element(const int name)
47
0
{
48
0
  if (name == (+IWORKToken::NS_URI_SF | IWORKToken::text))
49
0
    return std::make_shared<IWORKTextElement>(getState());
50
0
  return IWORKXMLContextPtr_t();
51
0
}
52
53
void PAG1AnnotationContext::endOfElement()
54
0
{
55
0
  if (isCollector())
56
0
  {
57
0
    getCollector().collectText(getState().m_currentText);
58
0
    getState().m_currentText.reset();
59
0
    if (m_target)
60
0
      m_collect(get(m_target));
61
0
    else
62
0
    {
63
0
      ETONYEK_DEBUG_MSG(("PAG1AnnotationContext::endOfElement: called without target\n"));
64
0
    }
65
0
  }
66
0
}
67
68
}
69
70
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */