about summary refs log tree commit diff stats
path: root/010vm.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-07 15:49:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-07 15:49:40 -0700
commit05d177737c980aad2fcdb54765433e02021ab1e0 (patch)
tree3b146349a2674db7e585f396bfb5eb0062c4ccd9 /010vm.cc
parent0487a30e7078861ed7de42bdb21b5c71fb9b54a1 (diff)
downloadmu-05d177737c980aad2fcdb54765433e02021ab1e0.tar.gz
1299 - stop using [] in any vector
Useful check:

  $ grep "[^ '\"]\[[^\"]" *.cc \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |grep '[^ ]\['
Diffstat (limited to '010vm.cc')
-rw-r--r--010vm.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/010vm.cc b/010vm.cc
index 38fc582c..3bccbf5e 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -181,13 +181,13 @@ reagent::reagent(string s) :value(0), initialized(false) {
     properties.push_back(pair<string, vector<string> >(name, values));
   }
   // structures for the first row of properties
-  name = properties[0].first;
-  for (index_t i = 0; i < properties[0].second.size(); ++i) {
-    types.push_back(Type_number[properties[0].second[i]]);
+  name = properties.at(0).first;
+  for (index_t i = 0; i < properties.at(0).second.size(); ++i) {
+    types.push_back(Type_number[properties.at(0).second.at(i)]);
   }
   if (name == "_" && types.empty()) {
     types.push_back(0);
-    properties[0].second.push_back("dummy");
+    properties.at(0).second.push_back("dummy");
   }
 }
 reagent::reagent() :value(0), initialized(false) {
@@ -200,16 +200,16 @@ string reagent::to_string() const {
   ostringstream out;
   out << "{name: \"" << name << "\", value: " << value << ", type: ";
   for (index_t i = 0; i < types.size(); ++i) {
-    out << types[i];
+    out << types.at(i);
     if (i < types.size()-1) out << "-";
   }
   if (!properties.empty()) {
     out << ", properties: [";
     for (index_t i = 0; i < properties.size(); ++i) {
-      out << "\"" << properties[i].first << "\": ";
-      for (index_t j = 0; j < properties[i].second.size(); ++j) {
-        out << "\"" << properties[i].second[j] << "\"";
-        if (j < properties[i].second.size()-1) out << ":";
+      out << "\"" << properties.at(i).first << "\": ";
+      for (index_t j = 0; j < properties.at(i).second.size(); ++j) {
+        out << "\"" << properties.at(i).second.at(j) << "\"";
+        if (j < properties.at(i).second.size()-1) out << ":";
       }
       if (i < properties.size()-1) out << ", ";
       else out << "]";
@@ -224,13 +224,13 @@ string instruction::to_string() const {
   ostringstream out;
   for (index_t i = 0; i < products.size(); ++i) {
     if (i > 0) out << ", ";
-    out << products[i].to_string();
+    out << products.at(i).to_string();
   }
   if (!products.empty()) out << " <- ";
   out << name << '/' << operation << ' ';
   for (index_t i = 0; i < ingredients.size(); ++i) {
     if (i > 0) out << ", ";
-    out << ingredients[i].to_string();
+    out << ingredients.at(i).to_string();
   }
   return out.str();
 }