⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orboptions.cc

📁 编译工具
💻 CC
📖 第 1 页 / 共 2 页
字号:
// -*- Mode: C++; -*-//                            Package   : omniORB// orbOptions.cc              Created on: 13/8/2001//                            Author    : Sai Lai Lo (sll)////    Copyright (C) 2001 AT&T Laboratories Cambridge////    This file is part of the omniORB library////    The omniORB library is free software; you can redistribute it and/or//    modify it under the terms of the GNU Library General Public//    License as published by the Free Software Foundation; either//    version 2 of the License, or (at your option) any later version.////    This library is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU//    Library General Public License for more details.////    You should have received a copy of the GNU Library General Public//    License along with this library; if not, write to the Free//    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA//    02111-1307, USA////// Description://	*** PROPRIETORY INTERFACE ***///*  $Log: orbOptions.cc,v $  Revision 1.1.2.14  2005/09/29 11:31:51  dgrisby  For loop scoping problem.  Revision 1.1.2.13  2005/09/19 14:23:56  dgrisby  New traceFile configuration parameter.  Revision 1.1.2.12  2005/09/08 14:26:17  dgrisby  New -ORBconfigFile command line argument.  Revision 1.1.2.11  2005/09/05 14:31:08  dgrisby  SSL transport extensions from Jon Biggar; SSL command line options.  Revision 1.1.2.10  2004/03/30 13:15:28  dgrisby  Remove spurious empty lines in config dump.  Revision 1.1.2.9  2004/02/06 16:17:44  dgrisby  Properly handle large giopMaxMsgSize settings.  Revision 1.1.2.8  2003/11/05 13:00:33  dgrisby  Properly set sequence length in dumpSpecified.  Revision 1.1.2.7  2003/07/26 22:52:22  dgrisby  Avoid spurious gcc warnings when sizeof pointer > sizeof int.  Revision 1.1.2.6  2002/03/18 15:13:09  dpg1  Fix bug with old-style ORBInitRef in config file; look for  -ORBtraceLevel arg before anything else; update Windows registry  key. Correct error message.  Revision 1.1.2.5  2001/10/29 17:44:59  dpg1  Missing loop increment.  Revision 1.1.2.4  2001/10/19 11:06:45  dpg1  Principal support for GIOP 1.0. Correct some spelling mistakes.  Revision 1.1.2.3  2001/08/21 11:03:38  sll  Environment variables to set the configuration parameters must now  prefix with "ORB". For instance, environment variable ORBtraceLevel  corresponds to parameter traceLevel.  orbOptions handlers are now told where an option comes from. This  is necessary to process DefaultInitRef and InitRef correctly.  Revision 1.1.2.2  2001/08/20 08:19:23  sll  Read the new ORB configuration file format. Can still read old format.  Can also set configuration parameters from environment variables.  Revision 1.1.2.1  2001/08/17 17:12:41  sll  Modularise ORB configuration parameters.*/#include <omniORB4/CORBA.h>#include <orbOptions.h>#include <initialiser.h>#include <stdio.h>#include <stdlib.h>#include <errno.h>OMNI_NAMESPACE_BEGIN(omni)////////////////////////////////////////////////////////////////////////orbOptions::Handler* orbOptions::findHandler(const char* k) {  //  if (!pd_handlers_sorted) sortHandlers();  omnivector<orbOptions::Handler*>::iterator i = pd_handlers.begin();  omnivector<orbOptions::Handler*>::iterator last = pd_handlers.end();    for (; i != last; i++) {    if (strcmp((*i)->key(),k) == 0)      return (*i);  }  return 0;}////////////////////////////////////////////////////////////////////////voidorbOptions::sortHandlers() {  // Won't it be nice to just use stl qsort? It is tempting to just  // forget about old C++ compiler and use stl. Until the time has come  // here is a little bit of code to sort the handlers in alphabetical  // order of their key(). The algorithm is shell sort.  int n = pd_handlers.size();  for (int gap=n/2; gap > 0; gap=gap/2 ) {    for (int i=gap; i < n ; i++)      for (int j =i-gap; j>=0; j=j-gap) {	if (strcmp( (pd_handlers[j])->key(),		    (pd_handlers[j+gap])->key() ) > 0) {	  Handler* temp = pd_handlers[j];	  pd_handlers[j] = pd_handlers[j+gap];	  pd_handlers[j+gap] = temp;	}      }  }  pd_handlers_sorted = 1;}////////////////////////////////////////////////////////////////////////orbOptions::orbOptions() : pd_handlers_sorted(0) {}////////////////////////////////////////////////////////////////////////orbOptions::~orbOptions() {  reset();}////////////////////////////////////////////////////////////////////////voidorbOptions::registerHandler(orbOptions::Handler& h) {  OMNIORB_ASSERT(findHandler(h.key()) == 0);  pd_handlers.push_back(&h);  pd_handlers_sorted = 0;}////////////////////////////////////////////////////////////////////////voidorbOptions::reset() {  omnivector<HandlerValuePair*>::iterator i = pd_values.begin();  omnivector<HandlerValuePair*>::iterator last = pd_values.end();  for (; i != last; i++) {    delete (*i);  }  pd_values.erase(pd_values.begin(),last);}////////////////////////////////////////////////////////////////////////voidorbOptions::visit() throw(orbOptions::BadParam) {  omnivector<HandlerValuePair*>::iterator i = pd_values.begin();  omnivector<HandlerValuePair*>::iterator last = pd_values.end();    for (; i != last; i++) {    (*i)->handler_->visit((*i)->value_,(*i)->source_);  }}////////////////////////////////////////////////////////////////////////voidorbOptions::addOption(const char* key,		      const char* value,		      orbOptions::Source source) throw (orbOptions::Unknown,							orbOptions::BadParam) {  if (!pd_handlers_sorted) sortHandlers();  orbOptions::Handler* handler = findHandler(key);  if (!handler) throw orbOptions::Unknown(key,value);  pd_values.push_back(new HandlerValuePair(handler,value,source));}////////////////////////////////////////////////////////////////////////voidorbOptions::addOptions(const char* options[][2]) throw (orbOptions::Unknown,							orbOptions::BadParam) {  for (int i=0; options[i][0]; i++) {    addOption(options[i][0],options[i][1],fromArray);  }}////////////////////////////////////////////////////////////////////////voidorbOptions::move_args(int& argc,char **argv,int idx,int nargs){  if ((idx+nargs) <= argc) {    for (int i=idx+nargs; i < argc; i++) {      argv[i-nargs] = argv[i];    }    argc -= nargs;  }}////////////////////////////////////////////////////////////////////////voidorbOptions::extractInitOptions(int& argc,char** argv)   throw (orbOptions::Unknown,orbOptions::BadParam) {  if (!pd_handlers_sorted) sortHandlers();  omnivector<orbOptions::Handler*>::iterator i = pd_handlers.begin();  omnivector<orbOptions::Handler*>::iterator last = pd_handlers.end();  for (; i != last; i++) {    if (!(*i)->argvYes()) continue;    const char* k = (*i)->key();    int idx = 0;    while (idx < argc) {      // -ORBxxxxxxx ?      if (strlen(argv[idx]) < 4 ||	  !(argv[idx][0] == '-' && argv[idx][1] == 'O' &&	    argv[idx][2] == 'R' && argv[idx][3] == 'B'    )) {		idx++;	continue;      }      if (strcmp(argv[idx]+4,k) != 0) {	idx++;	continue;      }      if (!(*i)->argvHasNoValue()) {	if ((idx+1) >= argc) {	  throw orbOptions::BadParam(k,"<missing>",				     "Expected parameter missing");	}	addOption(k,argv[idx+1],fromArgv);	move_args(argc,argv,idx,2);      }      else {	addOption(k,0,fromArgv);	move_args(argc,argv,idx,1);      }    }  }  // Now any -ORB option left are not supported  {    int idx = 0;    while (idx < argc) {      if ( strlen(argv[idx]) > 4 &&	   (argv[idx][0] == '-' && argv[idx][1] == 'O' &&	    argv[idx][2] == 'R' && argv[idx][3] == 'B'    ) ) {		throw orbOptions::Unknown(argv[idx],"");      }      idx++;    }  }  }////////////////////////////////////////////////////////////////////////voidorbOptions::getTraceLevel(int argc, char** argv)  throw (orbOptions::Unknown,orbOptions::BadParam) {  int i;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -