File: hello.cpp

package info (click to toggle)
gemmi 0.5.7%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,344 kB
  • sloc: cpp: 48,972; python: 4,352; ansic: 3,428; sh: 302; makefile: 69; f90: 42; javascript: 12
file content (21 lines) | stat: -rw-r--r-- 631 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <set>
#include <gemmi/cif.hpp>

namespace cif = gemmi::cif;

int main(int argc, char* argv[]) {
  std::set<std::string> greeted;
  if (argc != 2) return 1;
  try {
    cif::Document doc = cif::read_file(argv[1]);
    cif::Block& block = doc.sole_block(); // mmCIF has exactly one block
    for (const std::string &s : block.find_loop("_atom_site.type_symbol"))
      if (greeted.insert(s).second) // insert() returns pair<iterator,bool>
        std::cout << "Hello " << s << std::endl;
  } catch (std::exception& e) {
    std::cerr << "Oops. " << e.what() << std::endl;
    return 1;
  }
  return 0;
}