Rename BinaryRef::isBinary to more descriptive DataIsHexString.
authorSean Silva <silvas@purdue.edu>
Wed, 5 Jun 2013 23:32:31 +0000 (23:32 +0000)
committerSean Silva <silvas@purdue.edu>
Wed, 5 Jun 2013 23:32:31 +0000 (23:32 +0000)
And add a doxygen comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183350 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/YAML.h
lib/Object/YAML.cpp

index 92811b04eb3371b535db87a27f9d4747663e2757..41fe952456e1c9aa7440b3943412b0b9e459534b 100644 (file)
@@ -27,26 +27,27 @@ class BinaryRef {
   /// \brief Either raw binary data, or a string of hex bytes (must always
   /// be an even number of characters).
   ArrayRef<uint8_t> Data;
-  bool isBinary;
+  /// \brief Discriminator between the two states of the `Data` member.
+  bool DataIsHexString;
 
 public:
-  BinaryRef(ArrayRef<uint8_t> Data) : Data(Data), isBinary(true) {}
+  BinaryRef(ArrayRef<uint8_t> Data) : Data(Data), DataIsHexString(false) {}
   BinaryRef(StringRef Data)
       : Data(reinterpret_cast<const uint8_t *>(Data.data()), Data.size()),
-        isBinary(false) {}
-  BinaryRef() : isBinary(false) {}
+        DataIsHexString(true) {}
+  BinaryRef() : DataIsHexString(true) {}
   StringRef getHex() const {
-    assert(!isBinary);
+    assert(DataIsHexString);
     return StringRef(reinterpret_cast<const char *>(Data.data()), Data.size());
   }
   ArrayRef<uint8_t> getBinary() const {
-    assert(isBinary);
+    assert(!DataIsHexString);
     return Data;
   }
   /// \brief The number of bytes that are represented by this BinaryRef.
   /// This is the number of bytes that writeAsBinary() will write.
   ArrayRef<uint8_t>::size_type binary_size() const {
-    if (!isBinary)
+    if (DataIsHexString)
       return Data.size() / 2;
     return Data.size();
   }
@@ -55,7 +56,7 @@ public:
     if (Ref.Data.empty() && Data.empty())
       return true;
 
-    return Ref.isBinary == isBinary && Ref.Data == Data;
+    return Ref.DataIsHexString == DataIsHexString && Ref.Data == Data;
   }
   /// \brief Write the contents (regardless of whether it is binary or a
   /// hex string) as binary to the given raw_ostream.
index b33cf3410f653171ad9f2e7602ec9ca754523509..cf6e616241fc644a044033d76b2950b619b8a0bc 100644 (file)
@@ -51,7 +51,7 @@ StringRef yaml::ScalarTraits<object::yaml::BinaryRef>::input(
 }
 
 void BinaryRef::writeAsBinary(raw_ostream &OS) const {
-  if (isBinary) {
+  if (!DataIsHexString) {
     OS.write((const char *)Data.data(), Data.size());
     return;
   }