EndpointIDOpt.cc

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #include <oasys/util/StringBuffer.h>
00018 #include "EndpointIDOpt.h"
00019 #include "EndpointID.h"
00020 
00021 namespace dtn {
00022 
00023 EndpointIDOpt::EndpointIDOpt(const char* opt, EndpointID* valp,
00024                              const char* valdesc, const char* desc, bool* setp)
00025     : Opt(0, opt, valp, setp, true, valdesc, desc)
00026 {
00027 }
00028 
00029 EndpointIDOpt::EndpointIDOpt(char shortopt, const char* longopt,
00030                              EndpointID* valp,
00031                              const char* valdesc, const char* desc, bool* setp)
00032     : Opt(shortopt, longopt, valp, setp, true, valdesc, desc)
00033 {
00034 }
00035 
00036 int
00037 EndpointIDOpt::set(const char* val, size_t len)
00038 {
00039     std::string s(val, len);
00040     
00041     if (! ((EndpointID*)valp_)->assign(s)) {
00042         return -1;
00043     }
00044     
00045     if (setp_)
00046         *setp_ = true;
00047     
00048     return 0;
00049 }
00050 
00051 void
00052 EndpointIDOpt::get(oasys::StringBuffer* buf)
00053 {
00054     buf->append(((EndpointID*)valp_)->c_str());
00055 }
00056 
00057 } // namespace dtn

Generated on Thu Jun 7 12:54:27 2007 for DTN Reference Implementation by  doxygen 1.5.1