Added component::getChildComponents() function.

This commit is contained in:
Vincent Richard 2004-12-20 12:33:55 +00:00
parent 854a50bc8c
commit 3217dd9bf9
36 changed files with 206 additions and 0 deletions

View File

@ -248,6 +248,14 @@ const std::vector <address*> addressList::getAddressList()
}
const std::vector <const component*> addressList::getChildComponents() const
{
std::vector <const component*> list;
copy_vector(m_list, list);
return (list);
}
} // vmime

View File

@ -52,6 +52,8 @@ public:
addressList& operator=(const addressList& other);
addressList& operator=(const mailboxList& other);
const std::vector <const component*> getChildComponents() const;
/** Add a address at the end of the list.
*

View File

@ -90,6 +90,19 @@ namespace vmime
c.clear();
}
// Copy one vector to another, with type conversion
template <class T1, class T2>
void copy_vector(T1& v1, T2& v2)
{
const typename T1::size_type count = v1.size();
v2.resize(count);
for (typename T1::size_type i = 0 ; i < count ; ++i)
v2[i] = v1[i];
}
/*

View File

@ -706,4 +706,14 @@ const std::vector <bodyPart*> body::getPartList()
}
const std::vector <const component*> body::getChildComponents() const
{
std::vector <const component*> list;
copy_vector(m_parts, list);
return (list);
}
} // vmime

View File

@ -231,6 +231,8 @@ public:
void copyFrom(const component& other);
body& operator=(const body& other);
const std::vector <const component*> getChildComponents() const;
private:
string m_prologText;

View File

@ -120,5 +120,16 @@ bodyPart* bodyPart::getParentPart() const
}
const std::vector <const component*> bodyPart::getChildComponents() const
{
std::vector <const component*> list;
list.push_back(&m_header);
list.push_back(&m_body);
return (list);
}
} // vmime

View File

@ -77,6 +77,8 @@ public:
void copyFrom(const component& other);
bodyPart& operator=(const bodyPart& other);
const std::vector <const component*> getChildComponents() const;
private:
header m_header;

View File

@ -274,4 +274,10 @@ void charset::copyFrom(const component& other)
}
const std::vector <const component*> charset::getChildComponents() const
{
return std::vector <const component*>();
}
} // vmime

View File

@ -53,6 +53,8 @@ public:
const bool operator==(const charset& value) const;
const bool operator!=(const charset& value) const;
const std::vector <const component*> getChildComponents() const;
/** Returns the default charset used on the system.
*
* This function simply calls <code>platformDependantHandler::getLocaleCharset()</code>

View File

@ -75,4 +75,22 @@ void component::setParsedBounds(const string::size_type start, const string::siz
}
const std::vector <component*> component::getChildComponents()
{
const std::vector <const component*> constList =
const_cast <const component*>(this)->getChildComponents();
std::vector <component*> list;
const std::vector <const component*>::size_type count = constList.size();
list.resize(count);
for (std::vector <const component*>::size_type i = 0 ; i < count ; ++i)
list[i] = const_cast <component*>(constList[i]);
return (list);
}
}

View File

@ -104,6 +104,18 @@ public:
*/
const string::size_type getParsedLength() const;
/** Return the list of children of this component.
*
* @return list of child components
*/
const std::vector <component*> getChildComponents();
/** Return the list of children of this component (const version).
*
* @return list of child components
*/
virtual const std::vector <const component*> getChildComponents() const = 0;
protected:
void setParsedBounds(const string::size_type start, const string::size_type end);

View File

@ -709,6 +709,12 @@ datetime* datetime::clone() const
}
const std::vector <const component*> datetime::getChildComponents() const
{
return std::vector <const component*>();
}
const int datetime::getYear() const { return (m_year); }
const int datetime::getMonth() const { return (m_month); }
const int datetime::getDay() const { return (m_day); }

View File

@ -220,6 +220,8 @@ public:
// Current date and time
static const datetime now();
const std::vector <const component*> getChildComponents() const;
private:
static const int dayOfWeek(const int year, const int month, const int day);

View File

@ -117,4 +117,10 @@ void disposition::setName(const string& name)
}
const std::vector <const component*> disposition::getChildComponents() const
{
return std::vector <const component*>();
}
} // vmime

View File

@ -59,6 +59,8 @@ public:
void copyFrom(const component& other);
disposition& operator=(const disposition& other);
const std::vector <const component*> getChildComponents() const;
disposition& operator=(const string& name);

View File

@ -187,4 +187,10 @@ void encoding::setName(const string& name)
}
const std::vector <const component*> encoding::getChildComponents() const
{
return std::vector <const component*>();
}
} // vmime

View File

@ -66,6 +66,8 @@ public:
const bool operator==(const encoding& value) const;
const bool operator!=(const encoding& value) const;
const std::vector <const component*> getChildComponents() const;
/** Decide which encoding to use based on the specified data.
*
* \deprecated Use the new decide() method which takes a contentHandler parameter.

View File

@ -510,4 +510,14 @@ const std::vector <headerField*> header::getFieldList()
}
const std::vector <const component*> header::getChildComponents() const
{
std::vector <const component*> list;
copy_vector(m_fields, list);
return (list);
}
} // vmime

View File

@ -214,6 +214,8 @@ public:
void copyFrom(const component& other);
header& operator=(const header& other);
const std::vector <const component*> getChildComponents() const;
private:
std::vector <headerField*> m_fields;

View File

@ -97,4 +97,14 @@ const bool headerField::isCustom() const
}
const std::vector <const component*> headerField::getChildComponents() const
{
std::vector <const component*> list;
list.push_back(&getValue());
return (list);
}
} // vmime

View File

@ -49,6 +49,8 @@ public:
void copyFrom(const component& other);
headerField& operator=(const headerField& other);
const std::vector <const component*> getChildComponents() const;
/** Return the name of this field.
*
* @return field name

View File

@ -504,4 +504,10 @@ void mailbox::setEmail(const string& email)
}
const std::vector <const component*> mailbox::getChildComponents() const
{
return std::vector <const component*>();
}
} // vmime

View File

@ -81,6 +81,8 @@ public:
void clear();
const std::vector <const component*> getChildComponents() const;
const bool isGroup() const;

View File

@ -350,4 +350,15 @@ const std::vector <mailbox*> mailboxGroup::getMailboxList()
}
const std::vector <const component*> mailboxGroup::getChildComponents() const
{
std::vector <const component*> list;
copy_vector(m_list, list);
return (list);
}
} // vmime

View File

@ -48,6 +48,8 @@ public:
mailboxGroup* clone() const;
mailboxGroup& operator=(const component& other);
const std::vector <const component*> getChildComponents() const;
/** Return the name of the group.
*
* @return group name

View File

@ -169,4 +169,10 @@ void mediaType::setFromString(const string& type)
}
const std::vector <const component*> mediaType::getChildComponents() const
{
return std::vector <const component*>();
}
} // vmime

View File

@ -51,6 +51,8 @@ public:
void copyFrom(const component& other);
mediaType& operator=(const mediaType& other);
const std::vector <const component*> getChildComponents() const;
/** Return the media type.
* See the constants in vmime::mediaTypes.
*

View File

@ -227,4 +227,10 @@ void messageId::setRight(const string& right)
}
const std::vector <const component*> messageId::getChildComponents() const
{
return std::vector <const component*>();
}
} // vmime

View File

@ -91,6 +91,8 @@ public:
void copyFrom(const component& other);
messageId& operator=(const messageId& other);
const std::vector <const component*> getChildComponents() const;
private:
string m_left;

View File

@ -149,4 +149,14 @@ void parameter::generateValue(utility::outputStream& os, const string::size_type
}
const std::vector <const component*> parameter::getChildComponents() const
{
std::vector <const component*> list;
list.push_back(&getValue());
return (list);
}
} // vmime

View File

@ -39,6 +39,8 @@ public:
void copyFrom(const component& other);
parameter& operator=(const parameter& other);
const std::vector <const component*> getChildComponents() const;
/** Return the name of the parameter.
*
* @return name of the parameter

View File

@ -334,4 +334,11 @@ std::vector <string>& relay::getWithList()
}
const std::vector <const component*> relay::getChildComponents() const
{
// TODO: should fields inherit from 'component'? (using typeAdapter)
return std::vector <const component*>();
}
} // vmime

View File

@ -47,6 +47,8 @@ public:
void copyFrom(const component& other);
relay& operator=(const relay& other);
const std::vector <const component*> getChildComponents() const;
const string& getFrom() const;
void setFrom(const string& from);

View File

@ -840,4 +840,11 @@ void text::decodeAndUnfold(const string::const_iterator& inStart, const string::
}
const std::vector <const component*> text::getChildComponents() const
{
// TODO: 'word' should inherit from 'component'
return std::vector <const component*>();
}
} // vmime

View File

@ -53,6 +53,8 @@ public:
text& operator=(const component& other);
text& operator=(const text& other);
const std::vector <const component*> getChildComponents() const;
/** Add a word at the end of the list.
*
* @param w word to append

View File

@ -107,6 +107,11 @@ public:
*newLinePos = curLinePos + oss.str().length();
}
const std::vector <const component*> getChildComponents() const
{
return std::vector <const component*>();
}
private:
TYPE m_value;