brew/Library/Homebrew/cxxstdlib.rb

37 lines
891 B
Ruby
Raw Normal View History

2024-09-26 13:30:37 -04:00
# typed: strong
# frozen_string_literal: true
require "compilers"
2020-08-14 03:39:31 +02:00
# Combination of C++ standard library and compiler.
class CxxStdlib
2024-09-26 13:30:37 -04:00
sig { params(type: T.nilable(Symbol), compiler: T.any(Symbol, String)).returns(CxxStdlib) }
def self.create(type, compiler)
2020-12-01 17:04:59 +00:00
raise ArgumentError, "Invalid C++ stdlib type: #{type}" if type && [:libstdcxx, :libcxx].exclude?(type)
2018-09-17 02:45:00 +02:00
CxxStdlib.new(type, compiler)
end
2024-09-26 13:30:37 -04:00
sig { returns(T.nilable(Symbol)) }
attr_reader :type
2024-09-26 13:30:37 -04:00
sig { returns(Symbol) }
attr_reader :compiler
sig { params(type: T.nilable(Symbol), compiler: T.any(Symbol, String)).void }
def initialize(type, compiler)
@type = type
2024-09-26 13:30:37 -04:00
@compiler = T.let(compiler.to_sym, Symbol)
end
2024-09-26 13:30:37 -04:00
sig { returns(String) }
def type_string
type.to_s.gsub(/cxx$/, "c++")
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
2014-08-03 15:28:26 -05:00
def inspect
"#<#{self.class.name}: #{compiler} #{type}>"
end
end