/[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 120 by senkov, Sat Jun 12 07:29:37 2004 UTC revision 1424 by schoenebeck, Sun Oct 14 22:00:17 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 36  Line 37 
37   * ******************************************************/   * ******************************************************/
38    
39  #include "lscpresultset.h"  #include "lscpresultset.h"
40    #include <iomanip>
41    #include "../common/global_private.h"
42    
43  //Construct an empty resultset  //Construct an empty resultset
44  //Default index is -1 meaning the resultset doesn't have an index  //Default index is -1 meaning the resultset doesn't have an index
# Line 59  LSCPResultSet::LSCPResultSet(String Valu Line 62  LSCPResultSet::LSCPResultSet(String Valu
62  //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.
63  void LSCPResultSet::Add(String Label, String Value) {  void LSCPResultSet::Add(String Label, String Value) {
64          if (count == -1)          if (count == -1)
65                  throw LinuxSamplerException("Attempting to change already produced resultset");                  throw Exception("Attempting to change already produced resultset");
66          if (result_type != result_type_success)          if (result_type != result_type_success)
67                  throw LinuxSamplerException("Attempting to create illegal resultset");                  throw Exception("Attempting to create illegal resultset");
68          storage = storage + Label + ": " + Value + "\r\n";          storage = storage + Label + ": " + Value + "\r\n";
69          count++;          count = 2; // results in form of "Label: Value" should always be handled as multi line responses
70    }
71    
72    void LSCPResultSet::Add(String Label, const char* pValue) {
73        Add(Label, String(pValue));
74    }
75    
76    //Add SQL resultset row
77    void LSCPResultSet::Add(int columns, char** argv) {
78            for (int i = 0; i < columns; i++)
79            {
80                    storage += argv[i];
81                    if ((i+1) < columns)
82                            storage += "|";
83            }
84            storage += "\r\n";
85            count = 2; //This result is always multiline.
86  }  }
87    
88  void LSCPResultSet::Add(int Value) {  void LSCPResultSet::Add(int Value) {
# Line 75  void LSCPResultSet::Add(String Label, in Line 94  void LSCPResultSet::Add(String Label, in
94  }  }
95    
96  void LSCPResultSet::Add(String Label, float Value) {  void LSCPResultSet::Add(String Label, float Value) {
97          std::stringstream ss; //fixme: had issues with template and float?!      std::stringstream ss;
98          ss << Value;      ss.imbue(std::locale::classic());
99          Add(Label, ss.str());      ss << std::fixed << std::setprecision(3) << Value;
100        Add(Label, ss.str());
101    }
102    
103    void LSCPResultSet::Add(String Label, bool Value) {
104        String s = (Value) ? "true" : "false";
105        Add(Label, s);
106  }  }
107    
108  //Add a single string to the resultset  //Add a single string to the resultset
109  void LSCPResultSet::Add(String Value) {  void LSCPResultSet::Add(String Value) {
110          if (result_type != result_type_success)          if (result_type != result_type_success)
111                  throw LinuxSamplerException("Attempting to create illegal resultset");                  throw Exception("Attempting to create illegal resultset");
112          if (count == -1)          if (count == -1)
113                  throw LinuxSamplerException("Attempting to change already produced resultset");                  throw Exception("Attempting to change already produced resultset");
114          if (count != 0)          if (count != 0)
115                  throw LinuxSamplerException("Attempting to create illegal resultset");                  throw Exception("Attempting to create illegal resultset");
116          storage = Value + "\r\n";          storage = Value + "\r\n";
117          count = 1;          count = 1;
118  }  }
# Line 98  void LSCPResultSet::Add(String Value) { Line 123  void LSCPResultSet::Add(String Value) {
123  //This method will be used to generate unknown errors only (code 0)  //This method will be used to generate unknown errors only (code 0)
124  //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).
125  //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.
126  void LSCPResultSet::Error(LinuxSamplerException e) {  void LSCPResultSet::Error(Exception e) {
127          e.PrintMessage();          e.PrintMessage();
128          Error(e.Message());          Error(e.Message());
129  }  }

Legend:
Removed from v.120  
changed lines
  Added in v.1424

  ViewVC Help
Powered by ViewVC