Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 1 | //===- VersionTuple.cpp - Version Number Handling ---------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the VersionTuple class, which represents a version in |
| 11 | // the form major[.minor[.subminor]]. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #include "clang/Basic/VersionTuple.h" |
| 15 | #include "llvm/Support/raw_ostream.h" |
| 16 | |
| 17 | using namespace clang; |
| 18 | |
| 19 | std::string VersionTuple::getAsString() const { |
| 20 | std::string Result; |
| 21 | { |
| 22 | llvm::raw_string_ostream Out(Result); |
| 23 | Out << *this; |
| 24 | } |
| 25 | return Result; |
| 26 | } |
| 27 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 28 | raw_ostream& clang::operator<<(raw_ostream &Out, |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 29 | const VersionTuple &V) { |
| 30 | Out << V.getMajor(); |
| 31 | if (llvm::Optional<unsigned> Minor = V.getMinor()) |
| 32 | Out << '.' << *Minor; |
| 33 | if (llvm::Optional<unsigned> Subminor = V.getSubminor()) |
| 34 | Out << '.' << *Subminor; |
| 35 | return Out; |
| 36 | } |