/[debian]/mimetic/branches/upstream/current/mimetic/fieldparam.cxx
ViewVC logotype

Contents of /mimetic/branches/upstream/current/mimetic/fieldparam.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 128 - (show annotations)
Sat Feb 25 16:49:20 2006 UTC (15 years, 5 months ago) by gregoa
File size: 2116 byte(s)
[svn-inject] Installing original source of mimetic
1 /***************************************************************************
2 copyright : (C) 2002-2005 by Stefano Barbato
3 email : stefano@codesink.org
4
5 $Id: fieldparam.cxx,v 1.2 2005/02/23 10:26:14 tat Exp $
6 ***************************************************************************/
7
8 /***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16 #include <mimetic/fieldparam.h>
17 #include <mimetic/utils.h>
18
19 namespace mimetic
20 {
21
22 using namespace std;
23
24 FieldParam::FieldParam()
25 {
26 }
27
28 FieldParam::FieldParam(const string& lpv)
29 {
30 string::const_iterator bit = lpv.begin(), eit = lpv.end();
31 for( ; bit != eit; ++bit)
32 {
33 if(*bit == '=')
34 {
35 string n(lpv.begin(), bit), v(++bit, eit);
36 m_name = remove_external_blanks(n);
37 m_value = remove_dquote(remove_external_blanks(v));
38 break;
39 }
40 }
41 }
42
43 FieldParam::FieldParam(const string& n, const string& v)
44 {
45 name(n);
46 value(v);
47 }
48
49 const istring& FieldParam::name() const
50 {
51 return m_name;
52 }
53
54 const string& FieldParam::value() const
55 {
56 return m_value;
57 }
58
59 void FieldParam::name(const string& n)
60 {
61 m_name = n;
62 }
63
64 void FieldParam::value(const string& v)
65 {
66 m_value = v;
67 }
68
69 ostream& operator<<(ostream& os, const FieldParam& p)
70 {
71 os << p.name() << "=";
72 const string& val = p.value();
73 if(val.find_first_of("()\\<>\"@,;:/[]?=") != string::npos)
74 return os << "\"" << val << "\"";
75 else
76 return os << val;
77 }
78
79 }

  ViewVC Help
Powered by ViewVC 1.1.26