00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the dbus-cxx library. * 00006 * * 00007 * The dbus-cxx library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The dbus-cxx library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef DBUSSIGNATURE_H 00020 #define DBUSSIGNATURE_H 00021 00022 #include <ostream> 00023 #include <string> 00024 #include <dbus-cxx/signatureiterator.h> 00025 00026 namespace DBus 00027 { 00028 00032 class Signature 00033 { 00034 public: 00035 00036 typedef SignatureIterator iterator; 00037 00038 typedef const SignatureIterator const_iterator; 00039 00040 typedef std::string::size_type size_type; 00041 00042 static const size_type npos; 00043 00044 Signature(); 00045 00046 Signature( const std::string& s, size_type pos = 0, size_type n = npos ); 00047 00048 Signature( const char* ); 00049 00050 Signature( const char* s, size_type n ); 00051 00052 Signature( size_type n, char c ); 00053 00054 template<class InputIterator> 00055 Signature( InputIterator first, InputIterator last ): m_signature( first, last ) { } 00056 00057 ~Signature(); 00058 00059 operator const std::string&() const; 00060 00061 const std::string& str() const; 00062 00063 Signature& operator=(const std::string& s); 00064 00065 Signature& operator=(const char* s); 00066 00067 bool operator==(const std::string& s) const { return m_signature == s; } 00068 00069 iterator begin(); 00070 00071 const_iterator begin() const; 00072 00073 iterator end(); 00074 00075 const_iterator end() const; 00076 00078 bool is_valid() const; 00079 00081 bool is_singleton() const; 00082 00083 protected: 00084 00085 std::string m_signature; 00086 00087 }; 00088 00089 } 00090 00091 inline 00092 std::ostream& operator<<(std::ostream& sout, const DBus::Signature& sig) 00093 { 00094 sout << sig.str(); 00095 return sout; 00096 } 00097 00098 #endif