javanano_params.h revision 0e055f079f53b07de3705838a7b4742ce56839f8
1// Protocol Buffers - Google's data interchange format 2// Copyright 2010 Google Inc. All rights reserved. 3// http://code.google.com/p/protobuf/ 4// 5// Redistribution and use in source and binary forms, with or without 6// modification, are permitted provided that the following conditions are 7// met: 8// 9// * Redistributions of source code must retain the above copyright 10// notice, this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above 12// copyright notice, this list of conditions and the following disclaimer 13// in the documentation and/or other materials provided with the 14// distribution. 15// * Neither the name of Google Inc. nor the names of its 16// contributors may be used to endorse or promote products derived from 17// this software without specific prior written permission. 18// 19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31// Author: wink@google.com (Wink Saville) 32 33#ifndef PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_ 34#define PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_ 35 36#include <map> 37#include <google/protobuf/stubs/strutil.h> 38 39namespace google { 40namespace protobuf { 41namespace compiler { 42namespace javanano { 43 44// Parameters for used by the generators 45class Params { 46 public: 47 typedef map<string, string> NameMap; 48 private: 49 string empty_; 50 string base_name_; 51 bool java_multiple_files_; 52 bool store_unknown_fields_; 53 NameMap java_packages_; 54 NameMap java_outer_classnames_; 55 56 public: 57 Params(const string & base_name) : 58 empty_(""), 59 base_name_(base_name), 60 store_unknown_fields_(false), 61 java_multiple_files_(false) { 62 } 63 64 const string& base_name() const { 65 return base_name_; 66 } 67 68 bool has_java_package(const string& file_name) const { 69 return java_packages_.find(file_name) 70 != java_packages_.end(); 71 } 72 void set_java_package(const string& file_name, 73 const string& java_package) { 74 java_packages_[file_name] = java_package; 75 } 76 const string& java_package(const string& file_name) const { 77 NameMap::const_iterator itr; 78 79 itr = java_packages_.find(file_name); 80 if (itr == java_packages_.end()) { 81 return empty_; 82 } else { 83 return itr->second; 84 } 85 } 86 const NameMap& java_packages() { 87 return java_packages_; 88 } 89 90 bool has_java_outer_classname(const string& file_name) const { 91 return java_outer_classnames_.find(file_name) 92 != java_outer_classnames_.end(); 93 } 94 void set_java_outer_classname(const string& file_name, 95 const string& java_outer_classname) { 96 java_outer_classnames_[file_name] = java_outer_classname; 97 } 98 const string& java_outer_classname(const string& file_name) const { 99 NameMap::const_iterator itr; 100 101 itr = java_outer_classnames_.find(file_name); 102 if (itr == java_outer_classnames_.end()) { 103 return empty_; 104 } else { 105 return itr->second; 106 } 107 } 108 const NameMap& java_outer_classnames() { 109 return java_outer_classnames_; 110 } 111 112 void set_store_unknown_fields(bool value) { 113 store_unknown_fields_ = value; 114 } 115 bool store_unknown_fields() const { 116 return store_unknown_fields_; 117 } 118 119 void set_java_multiple_files(bool value) { 120 java_multiple_files_ = value; 121 } 122 bool java_multiple_files() const { 123 return java_multiple_files_; 124 } 125 126}; 127 128} // namespace javanano 129} // namespace compiler 130} // namespace protobuf 131} // namespace google 132#endif // PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_ 133