Читаем C++. Сборник рецептов полностью

 // обратный вызов characters()

 void startElement(

  const XMLCh *const uri,       // URI пространства имен

  const XMLCh *const localname, // имя тега без префикса NS

  const XMLCh *const qname,     // имя тега + префикс NS

  const Attributes &attrs)      // атрибуты элементов

 {

  static XercesString animalList = fromNative("animalList");

  static XercesString animal = fromNative("animal");

  static XercesString vet = fromNative("veterinarian");

  static XercesString trainer = fromNative("trainer");

  static XercesString xmlns =

   fromNative("http://www.feldman-family-circus.com");

  // проверить URI пространства имен

  if (uri != xmlns)

   throw runtime_error(

    string("wrong namespace uri ") + toNative(uri)

   );

  if (localname == animal) {

   // Добавить в список объект Animal; это будет

   // "текущий объект Animal"

   animalList_.push_back(Animal());

  } else if (localname != animalList) {

   Animal& animal = animalList_.back();

   if (localname == vet) {

    // Мы встретили элемент "ветеринар".

    animal.setVeterinarian(contactFromAttributes(attrs));

   } else if (localname == trainer) {

    // Мы встретили элемент "дрессировщик".

    animal.setTrainer(contactFromAttributes(attrs));

   } else {

    // Мы встретили элемент "кличка", "вид животного" или

    // "дата рождения". Их содержимое будет получено

    // при обратном вызове функции characters().

    currentText_.clear();

   }

  }

 }

 // Если текущий элемент представляет кличку, вид животного или дату

 // рождения, используйте хранимый в currentText_ текст для установки

 // соответствующего свойства текущего объекта Animal.

 void endElement(

  const XMLCh *const uri,       // URI пространства имен

  const XMLCh *const localname, // имя тега без префикса NS

  const XMLCh *const qname)     // имя тега + префикс NS

 {

  static XercesString animalList = fromNative("animal-list");

  static XercesString animal = fromNative("animal");

  static XercesString name = fromNative("name");

  static XercesString species = fromNative("species");

  static XercesString dob = fromNative("dateOfBirth");

  if (localname!= animal && localname!= animalList) {

   // currentText_ содержит текст элемента, который был

   // добавлен. Используйте его для установки свойств текущего

   // объекта Animal.

   Animal& animal = animalList_.back();

   if (localname == name) {

    animal setName(toNative(currentText_));

   } else if (localname == species) {

    animal.setSpecies(toNative(currentText_));

   } else if (localname == dob) {

    animal.setDateOfBirth(toNative(currentText_));

   }

  }

 }

 // Получает уведомления, когда встречаются символьные данные

 void characters(const XMLCh* const chars,

  const unsigned int length) {

Перейти на страницу:

Похожие книги

1С: Управление торговлей 8.2
1С: Управление торговлей 8.2

Современные торговые предприятия предлагают своим клиентам широчайший ассортимент товаров, который исчисляется тысячами и десятками тысяч наименований. Причем многие позиции могут реализовываться на разных условиях: предоплата, отсрочка платежи, скидка, наценка, объем партии, и т.д. Клиенты зачастую делятся на категории – VIP-клиент, обычный клиент, постоянный клиент, мелкооптовый клиент, и т.д. Товарные позиции могут комплектоваться и разукомплектовываться, многие товары подлежат обязательной сертификации и гигиеническим исследованиям, некондиционные позиции необходимо списывать, на складах периодически должна проводиться инвентаризация, каждая компания должна иметь свою маркетинговую политику и т.д., вообщем – современное торговое предприятие представляет живой организм, находящийся в постоянном движении.Очевидно, что вся эта кипучая деятельность требует автоматизации. Для решения этой задачи существуют специальные программные средства, и в этой книге мы познакомим вам с самым популярным продуктом, предназначенным для автоматизации деятельности торгового предприятия – «1С Управление торговлей», которое реализовано на новейшей технологической платформе версии 1С 8.2.

Алексей Анатольевич Гладкий

Финансы / Программирование, программы, базы данных
C++ Primer Plus
C++ Primer Plus

C++ Primer Plus is a carefully crafted, complete tutorial on one of the most significant and widely used programming languages today. An accessible and easy-to-use self-study guide, this book is appropriate for both serious students of programming as well as developers already proficient in other languages.The sixth edition of C++ Primer Plus has been updated and expanded to cover the latest developments in C++, including a detailed look at the new C++11 standard.Author and educator Stephen Prata has created an introduction to C++ that is instructive, clear, and insightful. Fundamental programming concepts are explained along with details of the C++ language. Many short, practical examples illustrate just one or two concepts at a time, encouraging readers to master new topics by immediately putting them to use.Review questions and programming exercises at the end of each chapter help readers zero in on the most critical information and digest the most difficult concepts.In C++ Primer Plus, you'll find depth, breadth, and a variety of teaching techniques and tools to enhance your learning:• A new detailed chapter on the changes and additional capabilities introduced in the C++11 standard• Complete, integrated discussion of both basic C language and additional C++ features• Clear guidance about when and why to use a feature• Hands-on learning with concise and simple examples that develop your understanding a concept or two at a time• Hundreds of practical sample programs• Review questions and programming exercises at the end of each chapter to test your understanding• Coverage of generic C++ gives you the greatest possible flexibility• Teaches the ISO standard, including discussions of templates, the Standard Template Library, the string class, exceptions, RTTI, and namespaces

Стивен Прата

Программирование, программы, базы данных