BasicUsageEnvironment/BasicUsageEnvironment.cpp

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // Copyright (c) 1996-2012 Live Networks, Inc.  All rights reserved.
00017 // Basic Usage Environment: for a simple, non-scripted, console application
00018 // Implementation
00019 
00020 #include "BasicUsageEnvironment.hh"
00021 #include <stdio.h>
00022 
00024 
00025 #if defined(__WIN32__) || defined(_WIN32)
00026 extern "C" int initializeWinsockIfNecessary();
00027 #endif
00028 
00029 BasicUsageEnvironment::BasicUsageEnvironment(TaskScheduler& taskScheduler)
00030 : BasicUsageEnvironment0(taskScheduler) {
00031 #if defined(__WIN32__) || defined(_WIN32)
00032   if (!initializeWinsockIfNecessary()) {
00033     setResultErrMsg("Failed to initialize 'winsock': ");
00034     reportBackgroundError();
00035     internalError();
00036   }
00037 #endif
00038 }
00039 
00040 BasicUsageEnvironment::~BasicUsageEnvironment() {
00041 }
00042 
00043 BasicUsageEnvironment*
00044 BasicUsageEnvironment::createNew(TaskScheduler& taskScheduler) {
00045   return new BasicUsageEnvironment(taskScheduler);
00046 }
00047 
00048 int BasicUsageEnvironment::getErrno() const {
00049 #if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE)
00050   return WSAGetLastError();
00051 #else
00052   return errno;
00053 #endif
00054 }
00055 
00056 UsageEnvironment& BasicUsageEnvironment::operator<<(char const* str) {
00057   if (str == NULL) str = "(NULL)"; // sanity check
00058   fprintf(stderr, "%s", str);
00059   return *this;
00060 }
00061 
00062 UsageEnvironment& BasicUsageEnvironment::operator<<(int i) {
00063   fprintf(stderr, "%d", i);
00064   return *this;
00065 }
00066 
00067 UsageEnvironment& BasicUsageEnvironment::operator<<(unsigned u) {
00068   fprintf(stderr, "%u", u);
00069   return *this;
00070 }
00071 
00072 UsageEnvironment& BasicUsageEnvironment::operator<<(double d) {
00073   fprintf(stderr, "%f", d);
00074   return *this;
00075 }
00076 
00077 UsageEnvironment& BasicUsageEnvironment::operator<<(void* p) {
00078   fprintf(stderr, "%p", p);
00079   return *this;
00080 }

Generated on Thu Feb 2 23:51:29 2012 for live by  doxygen 1.5.2