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

stringparser.cpp « lang_getter - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e74530dcdc0e56daec40fb6bbaee717a548b89eb (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
#include "stringparser.h"
#include "logging.h"


bool ContentParser::InitSubDOM(QString const & xml, QString const & entry, QString const & tag)
{
  int const i = xml.indexOf(entry);
  if (i == -1)
  {
    m_log.Print(Logging::INFO, QString("Can't find entry: ") + entry);
    return false;
  }

  int const beg = xml.indexOf(QString("<") + tag, i);
  if (beg == -1 || beg < i)
  {
    m_log.Print(Logging::INFO, QString("Can't find tag: ") + tag);
    return false;
  }

  QString last = QString("/") + tag + QString(">");
  int const end = xml.indexOf(last, beg);
  Q_ASSERT ( end != -1 && beg < end );

  if (!m_doc.setContent(xml.mid(beg, end - beg + last.length())))
  {
    m_log.Print(Logging::ERROR, QString("QDomDocument::setContent error"));
    return false;
  }

  m_node = m_doc.documentElement();
  Q_ASSERT ( !m_node.isNull() );
  Q_ASSERT ( m_node.tagName() == tag );

  return true;
}