Changeset 11229 for trunk/FACT++/src
- Timestamp:
- 07/01/11 08:38:40 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/argv.cc
r11228 r11229 4 4 5 5 using namespace std; 6 7 template<class T,class S>8 std::ostream &operator<<(std::ostream &out, const pair<T,S> &f)9 {10 out << f.first << "|" << f.second;11 return out;12 }13 template<class T, class S>14 std::istream &operator>>(std::istream &in, pair<T,S> &f)15 {16 char c;17 in >> f.first;18 in >> c;19 if (c!=':')20 return in;21 in >> f.second;22 return in;23 }24 25 typedef pair<int,int> mytype;26 27 28 //Source is OutputStreamable, meaning that an operator<< is defined29 // that takes a std::ostream or std::wostream object on the left hand side30 // and an instance of the argument type on the right.31 32 // Target is InputStreamable, meaning that an operator>> is defined that33 // takes a std::istream or std::wistream object on the left hand side and34 // an instance of the result type on the right.35 36 //Target is CopyConstructible [20.1.3].37 //Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4].38 6 39 7 // -------------------------------------------------------------------------- … … 114 82 ("switch", po_switch(), "include path") 115 83 ("bool", var<bool>()->implicit_value(true), "include path") 116 ("mytype", var<mytype>(), "include path")117 84 ; 118 85 … … 205 172 cout << conf.Has("switch") << " " << conf.Get<bool>("switch") << endl; 206 173 cout << conf.Has("bool") << " " << conf.Get<bool>("bool") << endl; 207 cout << conf.Has("mytype") << " " << conf.Get<mytype>("mytype") << endl;208 174 209 175 return 0; -
trunk/FACT++/src/logtime.cc
r11228 r11229 6 6 #include <iostream> 7 7 8 #include "DimDescriptionService.h"9 10 8 int main(int, const char **) 11 9 { 12 10 // We could use putenv to make the Configure class change the value... 13 11 setenv("DIM_DNS_NODE", "localhost", 0); 14 12 … … 16 14 DimServer::start("TIME"); 17 15 18 usleep(2000000);19 20 DimServer::stop();21 22 return 0;23 24 16 // Some info on the console 25 17 std::cout << "Offering TIME/MESSAGE...\n" << std::endl; 26 27 short s;28 int i;29 long long ll;30 float f;31 DimDescribedService servt("TIME/TEST", "O:1;I:1;C",32 "This is my test command|Char[c]:This is a char| Int This is an int|String[s]:This is a string");33 34 DimDescribedService servs("TIME/SHORT", s, "[a]");35 DimDescribedService servx("TIME/LONGLONG", ll, "|: This is my long long");36 DimDescribedService servi("TIME/INT", i, "|MyInt [ mi ] ");37 DimDescribedService servf("TIME/FLOAT", f, "| MyFloat : This is my float");38 DimDescribedService servc("TIME/TIME", const_cast<char*>(""), "|MyTime[T]:This is my time");39 40 DimCommand cmd("TIME/CMD", "I:2;F:2");41 42 DimDescriptionService des("TIME/CMD", "|range[addr]:From DAC to DAC|values[DAC]:DAC values to be set");43 44 {45 Time t0;46 18 47 19 // Setup a DimService called TIME/MESSAGE … … 51 23 // Send current time 52 24 msg.Message(Time().GetAsStr()); 53 // servx.Update(); 54 /* 55 servs.updateService(); 56 servi.updateService(); 57 servf.updateService(); 58 servc.updateService(); 59 */ 25 60 26 // wait approximately one second 61 usleep(100000); 62 63 // if (t0.UnixTime()-Time().UnixTime()<-5) 64 // break; 27 usleep(1000000); 65 28 } 66 }67 68 DimDescribedService servxx("TIME/XXX", const_cast<char*>(""), "|MyTime[T]:This is my time");69 usleep(10000000);70 29 71 30 return 0; -
trunk/FACT++/src/tools.cc
r11228 r11229 12 12 #include <stdarg.h> 13 13 14 #include <boost/filesystem.hpp> 14 using namespace std; 15 15 16 using namespace std;17 /*18 16 string Tools::Format(const char *fmt, va_list &ap) 19 17 { … … 51 49 return str; 52 50 } 53 */54 51 55 52 // -------------------------------------------------------------------------- … … 57 54 //! This is a static helper to remove leading and trailing whitespaces. 58 55 //! 59 //! @param str56 //! @param buf 60 57 //! a pointer to the char array from which the whitespaces should be 61 58 //! removed … … 76 73 return str.substr(start, end-start+1); 77 74 } 78 79 // --------------------------------------------------------------------------80 //81 //! Splits a string of the form [SERVER/]COMMAND[ arguments]82 //! into SERVER, COMMAND and arguments.83 //!84 //! @param str85 //! string to be splitted86 //!87 //! @returns88 //! a vector<string> with three components. Depending on what is existing89 //! in the string some of the components might be empty.90 //!91 /*92 vector<string> Split(std::string str)93 {94 const size_t p0 = str.find_first_of('/');95 96 size_t p1 = str.find_first_of(' ');97 98 vector<string> v(3);99 100 // string starts with SERVER/COMMAND[ arguments]101 if (p0<p1)102 {103 // SERVER104 v[0] = str.substr(0, p0);105 106 // COMMAND[ arguments)107 str = str.substr(p0+1);108 p1 = str.find_first_of(' ');109 }110 111 // String is of the form: COMMAND[ arguments]112 113 // COMMAND114 v[1] = str.substr(0, p1);115 116 // Has arguments117 if (p1!=string::npos)118 v[2] = str.substr(p1+1);119 120 return v;121 }122 */ -
trunk/FACT++/src/tools.h
r11228 r11229 1 1 #include <string> 2 #include <vector>3 2 4 3 namespace Tools 5 4 { 6 //std::string Format(const char *fmt, va_list &ap);7 //std::string Form(const char *fmt, ...);5 std::string Format(const char *fmt, va_list &ap); 6 std::string Form(const char *fmt, ...); 8 7 std::string Trim(const std::string &str); 9 8 }
Note:
See TracChangeset
for help on using the changeset viewer.