summaryrefslogtreecommitdiffstats
path: root/tools/gn/lib_file.cc
blob: 86eacb29c1299801001e5897d0be4a9bd2bfa0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "tools/gn/lib_file.h"

#include "base/logging.h"

LibFile::LibFile() {}

LibFile::LibFile(const SourceFile& source_file) : source_file_(source_file) {}

LibFile::LibFile(const base::StringPiece& lib_name)
    : name_(lib_name.data(), lib_name.size()) {
  DCHECK(!lib_name.empty());
}

void LibFile::Swap(LibFile* other) {
  name_.swap(other->name_);
  source_file_.swap(other->source_file_);
}

const std::string& LibFile::value() const {
  return is_source_file() ? source_file_.value() : name_;
}

const SourceFile& LibFile::source_file() const {
  DCHECK(is_source_file());
  return source_file_;
}