/[svn]/linuxsampler/trunk/src/network/lscpresultset.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpresultset.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 223 by schoenebeck, Sat Aug 21 11:43:53 2004 UTC revision 1009 by schoenebeck, Thu Jan 4 14:43:02 2007 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6     *   Copyright (C) 2005 - 2007 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 59  LSCPResultSet::LSCPResultSet(String Valu Line 60  LSCPResultSet::LSCPResultSet(String Valu
60  //Values could be of different types for now supports String, int and float.  //Values could be of different types for now supports String, int and float.
61  void LSCPResultSet::Add(String Label, String Value) {  void LSCPResultSet::Add(String Label, String Value) {
62          if (count == -1)          if (count == -1)
63                  throw LinuxSamplerException("Attempting to change already produced resultset");                  throw Exception("Attempting to change already produced resultset");
64          if (result_type != result_type_success)          if (result_type != result_type_success)
65                  throw LinuxSamplerException("Attempting to create illegal resultset");                  throw Exception("Attempting to create illegal resultset");
66          storage = storage + Label + ": " + Value + "\r\n";          storage = storage + Label + ": " + Value + "\r\n";
67          count++;          count = 2; // results in form of "Label: Value" should always be handled as multi line responses
68    }
69    
70    void LSCPResultSet::Add(String Label, const char* pValue) {
71        Add(Label, String(pValue));
72    }
73    
74    //Add SQL resultset row
75    void LSCPResultSet::Add(int columns, char** argv) {
76            for (int i = 0; i < columns; i++)
77            {
78                    storage += argv[i];
79                    if ((i+1) < columns)
80                            storage += "|";
81            }
82            storage += "\r\n";
83            count = 2; //This result is always multiline.
84  }  }
85    
86  void LSCPResultSet::Add(int Value) {  void LSCPResultSet::Add(int Value) {
# Line 75  void LSCPResultSet::Add(String Label, in Line 92  void LSCPResultSet::Add(String Label, in
92  }  }
93    
94  void LSCPResultSet::Add(String Label, float Value) {  void LSCPResultSet::Add(String Label, float Value) {
95          std::stringstream ss; //fixme: had issues with template and float?!      char s[1024];
96          ss << Value;      snprintf(s, 1023, "%.3f", Value);
97          Add(Label, ss.str());      Add(Label, String(s));
98  }  }
99    
100  void LSCPResultSet::Add(String Label, bool Value) {  void LSCPResultSet::Add(String Label, bool Value) {
# Line 88  void LSCPResultSet::Add(String Label, bo Line 105  void LSCPResultSet::Add(String Label, bo
105  //Add a single string to the resultset  //Add a single string to the resultset
106  void LSCPResultSet::Add(String Value) {  void LSCPResultSet::Add(String Value) {
107          if (result_type != result_type_success)          if (result_type != result_type_success)
108                  throw LinuxSamplerException("Attempting to create illegal resultset");                  throw Exception("Attempting to create illegal resultset");
109          if (count == -1)          if (count == -1)
110                  throw LinuxSamplerException("Attempting to change already produced resultset");                  throw Exception("Attempting to change already produced resultset");
111          if (count != 0)          if (count != 0)
112                  throw LinuxSamplerException("Attempting to create illegal resultset");                  throw Exception("Attempting to create illegal resultset");
113          storage = Value + "\r\n";          storage = Value + "\r\n";
114          count = 1;          count = 1;
115  }  }
# Line 103  void LSCPResultSet::Add(String Value) { Line 120  void LSCPResultSet::Add(String Value) {
120  //This method will be used to generate unknown errors only (code 0)  //This method will be used to generate unknown errors only (code 0)
121  //To generate errors with other codes as well as warnings use other methods (below).  //To generate errors with other codes as well as warnings use other methods (below).
122  //Because this is an unknown error, this method will also print message to the stderr.  //Because this is an unknown error, this method will also print message to the stderr.
123  void LSCPResultSet::Error(LinuxSamplerException e) {  void LSCPResultSet::Error(Exception e) {
124          e.PrintMessage();          e.PrintMessage();
125          Error(e.Message());          Error(e.Message());
126  }  }

Legend:
Removed from v.223  
changed lines
  Added in v.1009

  ViewVC Help
Powered by ViewVC