MCPcopy Create free account
hub / github.com/KLayout/klayout / from_string_file_format

Method from_string_file_format

src/db/db/dbStreamLayers.cc:940–983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

938}
939
940db::LayerMap
941LayerMap::from_string_file_format (const std::string &s)
942{
943 db::LayerMap lm;
944 // NOTE: this should be outside the normal layer index range of a Layout and below
945 // the space reserved for placeholders. With numbers like this we don't get messed
946 // up with existing layers.
947 unsigned int l = std::numeric_limits<unsigned int>::max () / 2;
948
949 int lnr = 0;
950
951 try {
952
953 std::vector<std::string> lines = tl::split (s, "\n");
954
955 for (std::vector<std::string>::const_iterator line = lines.begin (); line != lines.end (); ++line) {
956
957 ++lnr;
958
959 tl::Extractor ex (line->c_str ());
960 if (ex.test ("#") || ex.test ("//")) {
961 // ignore comments
962 } else {
963
964 if (! ex.at_end ()) {
965 lm.add_expr (ex, l);
966 if (ex.test ("#") || ex.test ("//")) {
967 // ignore comments
968 } else {
969 ex.expect_end ();
970 }
971 ++l;
972 }
973
974 }
975
976 }
977
978 } catch (tl::Exception &ex) {
979 throw tl::Exception (ex.msg () + tl::to_string (tr (" in line ")) + tl::to_string (lnr));
980 }
981
982 return lm;
983}
984
985}
986

Callers

nothing calls this directly

Calls 12

maxFunction · 0.85
splitFunction · 0.85
add_exprMethod · 0.80
msgMethod · 0.80
to_stringFunction · 0.70
ExceptionFunction · 0.50
trFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
testMethod · 0.45
at_endMethod · 0.45

Tested by

no test coverage detected