source_location.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "source_location.h"
  2. #include <string.h>
  3. namespace NYT {
  4. ////////////////////////////////////////////////////////////////////////////////
  5. const char* TSourceLocation::GetFileName() const
  6. {
  7. return FileName_;
  8. }
  9. int TSourceLocation::GetLine() const
  10. {
  11. return Line_;
  12. }
  13. bool TSourceLocation::IsValid() const
  14. {
  15. return FileName_ != nullptr;
  16. }
  17. bool TSourceLocation::operator<(const TSourceLocation& other) const
  18. {
  19. const char* fileName = FileName_ ? FileName_ : "";
  20. const char* otherFileName = other.FileName_ ? other.FileName_ : "";
  21. int fileNameResult = strcmp(fileName, otherFileName);
  22. if (fileNameResult != 0) {
  23. return fileNameResult < 0;
  24. }
  25. if (Line_ < other.Line_) {
  26. return true;
  27. }
  28. if (Line_ > other.Line_) {
  29. return false;
  30. }
  31. return false;
  32. }
  33. bool TSourceLocation::operator==(const TSourceLocation& other) const
  34. {
  35. const char* fileName = FileName_ ? FileName_ : "";
  36. const char* otherFileName = other.FileName_ ? other.FileName_ : "";
  37. return
  38. strcmp(fileName, otherFileName) == 0 &&
  39. Line_ == other.Line_;
  40. }
  41. ////////////////////////////////////////////////////////////////////////////////
  42. } // namespace NYT