text: /*
   * Copyright (c) Facebook, Inc. and its affiliates.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  #pragma once
  
  #include <string>
  #include <unordered_map>
  #include <unordered_set>
  #include <vector>
  
  #include <thrift/compiler/ast/t_program.h>
  #include <thrift/compiler/ast/t_type.h>
  
  namespace apache {
  namespace thrift {
  namespace compiler {
  namespace cpp2 {
  
  std::vector<std::string> get_gen_namespace_components(t_program const& program);
  
  std::string get_gen_namespace(t_program const& program);
  
  /*
   * This determines if a type can be ordered.
   * If the type is using any annotation for cpp2.type or cpp2.template
   * its not considered orderable, and we don't need to generate operator< methods
   */
  bool is_orderable(
      std::unordered_set<t_type const*>& seen,
      std::unordered_map<t_type const*, bool>& memo,
      t_type const& type);
  bool is_orderable(t_type const& type);
  
  /**
   * If the cpp_type is std::unique_ptr<folly::IOBuf> the C++ compiler implicitly
   * assumes this is optional.
   */
  bool is_implicit_ref(const t_type* type);
  
  /**
   * Return the cpp.type/cpp2.type attribute or empty string if nothing set.
   */
  std::string const& get_cpp_type(const t_type* type);
  
  /**
   * Does the field have cpp.ref/cpp2.ref/cpp.ref_type/cpp2.ref_type or is an
   * implicit ref (see @is_implicit_ref).
   */
  bool is_cpp_ref(const t_field* f);
  
  } // namespace cpp2
  } // namespace compiler
  } // namespace thrift
  } // namespace apache
  