Example #1
0
bool AsnBuf::operator<(const AsnBuf &rhs) const
{
   bool lessThan = true;
   bool firstTime = true;
   ResetMode();
   rhs.ResetMode();
   std::streambuf::int_type ch1;
   std::streambuf::int_type ch2;
   while ( lessThan )
   {
      try
      {
         ch1 = GetUByte();
      }
      catch (BufferException &)
      {
         ch1 = EOF;
      }

      try
      {
         ch2 = rhs.GetUByte();
      }
      catch (BufferException &)
      {
         ch2 = EOF;
      }

      if ((ch1 == EOF) && (ch2 == EOF))
      {
         if (firstTime)
            lessThan = false;
         break;
      } 
      else if (ch2 == EOF)
      {
         lessThan = false;
         break;
      }
      else if (ch1 == EOF)
      {
         break;
      }

      if (ch1 > ch2)
         lessThan = false;
      else if (ch1 < ch2)
         break;

      firstTime = false;
   }
   ResetMode();
   rhs.ResetMode();
   return lessThan;
}
Example #2
0
bool AsnBuf::operator == (const AsnBuf &b) const
{
   bool equal = true;
   ResetMode();
   b.ResetMode();
   std::streambuf::int_type ch1;
   std::streambuf::int_type ch2;
   while ( equal )
   {
      try
      {
         ch1 = GetUByte();
      }
      catch (BufferException &)
      {
         ch1 = EOF;
      }

      try
      {
         ch2 = b.GetUByte();
      }
      catch (BufferException &)
      {
         ch2 = EOF;
      }

      if ((ch1 == EOF) && (ch1 == EOF))
         break;

      if (ch1 != ch2)
         equal = false;
   }
   ResetMode();
   b.ResetMode();
   return equal;
}