Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > fa7fad8f194f80107561a85291acd153 > files > 776

lib64boost-devel-doc-1.42.0-3mdv2010.1.x86_64.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template period</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#header.boost.date_time.period_hpp" title="Header &lt;boost/date_time/period.hpp&gt;">
<link rel="prev" href="ymd_order_spec.html" title="Type ymd_order_spec">
<link rel="next" href="period_formatter.html" title="Class template period_formatter">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ymd_order_spec.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.period_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="period_formatter.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="refentry" title="Class template period">
<a name="boost.date_time.period"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template period</span></h2>
<p>boost::date_time::period &#8212; Provides generalized period type useful in date-time systems. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="emphasis"><em>// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.period_hpp" title="Header &lt;boost/date_time/period.hpp&gt;">boost/date_time/period.hpp</a>&gt;

</em></span><span class="bold"><strong>template</strong></span>&lt;<span class="bold"><strong>typename</strong></span> point_rep, <span class="bold"><strong>typename</strong></span> duration_rep&gt; 
<span class="bold"><strong>class</strong></span> <a class="link" href="period.html" title="Class template period">period</a> {
<span class="bold"><strong>public</strong></span>:
  <span class="emphasis"><em>// types</em></span>
  <span class="bold"><strong>typedef</strong></span> point_rep    <a name="boost.date_time.period.point_type"></a>point_type;   
  <span class="bold"><strong>typedef</strong></span> duration_rep <a name="boost.date_time.period.duration_type"></a>duration_type;

  <span class="emphasis"><em>// <a class="link" href="period.html#boost.date_time.periodconstruct-copy-destruct">construct/copy/destruct</a></em></span>
  <a class="link" href="period.html#id355985-bb">period</a>(point_rep, point_rep);
  <a class="link" href="period.html#id392891-bb">period</a>(point_rep, duration_rep);

  <span class="emphasis"><em>// <a class="link" href="period.html#id370525-bb">public member functions</a></em></span>
  <span class="type">point_rep</span> <a class="link" href="period.html#id370528-bb">begin</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">point_rep</span> <a class="link" href="period.html#id349913-bb">end</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">point_rep</span> <a class="link" href="period.html#id387958-bb">last</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">duration_rep</span> <a class="link" href="period.html#id607172-bb">length</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id607182-bb">is_null</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id398706-bb"><span class="bold"><strong>operator</strong></span>==</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id393695-bb"><span class="bold"><strong>operator</strong></span>&lt;</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="period.html#id393715-bb">shift</a>(<span class="bold"><strong>const</strong></span> duration_rep &amp;) ;
  <span class="type"><span class="bold"><strong>void</strong></span></span> <a class="link" href="period.html#id374215-bb">expand</a>(<span class="bold"><strong>const</strong></span> duration_rep &amp;) ;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id335527-bb">contains</a>(<span class="bold"><strong>const</strong></span> point_rep &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id409424-bb">contains</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id360584-bb">intersects</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id396783-bb">is_adjacent</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id366165-bb">is_before</a>(<span class="bold"><strong>const</strong></span> point_rep &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a class="link" href="period.html#id366182-bb">is_after</a>(<span class="bold"><strong>const</strong></span> point_rep &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><a class="link" href="period.html" title="Class template period">period</a></span> <a class="link" href="period.html#id366199-bb">intersection</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><a class="link" href="period.html" title="Class template period">period</a></span> <a class="link" href="period.html#id366221-bb">merge</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><a class="link" href="period.html" title="Class template period">period</a></span> <a class="link" href="period.html#id355953-bb">span</a>(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp;) <span class="bold"><strong>const</strong></span>;
};</pre></div>
<div class="refsect1" title="Description">
<a name="id810921"></a><h2>Description</h2>
<p>This template uses a class to represent a time point within the period and another class to represent a duration. As a result, this class is not appropriate for use when the number and duration representation are the same (eg: in the regular number domain).</p>
<p>A period can be specified by providing either the begining point and a duration or the begining point and the end point( end is NOT part of the period but 1 unit past it. A period will be "invalid" if either end_point &lt;= begin_point or the given duration is &lt;= 0. Any valid period will return false for is_null().</p>
<p>Zero length periods are also considered invalid. Zero length periods are periods where the begining and end points are the same, or, the given duration is zero. For a zero length period, the last point will be one unit less than the begining point.</p>
<p>In the case that the begin and last are the same, the period has a length of one unit.</p>
<p>The best way to handle periods is usually to provide a begining point and a duration. So, day1 + 7 days is a week period which includes all of the first day and 6 more days (eg: Sun to Sat). </p>
<div class="refsect2" title="period public construct/copy/destruct">
<a name="id810960"></a><h3>
<a name="boost.date_time.periodconstruct-copy-destruct"></a><code class="computeroutput">period</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id355985-bb"></a>period(point_rep first_point, point_rep end_point);</pre>create a period from begin to last eg: [begin,end) <p>If end &lt;= begin then the period will be invalid </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id392891-bb"></a>period(point_rep first_point, duration_rep len);</pre>create a period as [begin, begin+len) <p>If len is &lt;= 0 then the period will be invalid </p>
</li>
</ol></div>
</div>
<div class="refsect2" title="period public member functions">
<a name="id811016"></a><h3>
<a name="id370525-bb"></a><code class="computeroutput">period</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="type">point_rep</span> <a name="id370528-bb"></a>begin() <span class="bold"><strong>const</strong></span>;</pre>Return the first element in the period. </li>
<li class="listitem">
<pre class="literallayout"><span class="type">point_rep</span> <a name="id349913-bb"></a>end() <span class="bold"><strong>const</strong></span>;</pre>Return one past the last element. </li>
<li class="listitem">
<pre class="literallayout"><span class="type">point_rep</span> <a name="id387958-bb"></a>last() <span class="bold"><strong>const</strong></span>;</pre>Return the last item in the period. </li>
<li class="listitem">
<pre class="literallayout"><span class="type">duration_rep</span> <a name="id607172-bb"></a>length() <span class="bold"><strong>const</strong></span>;</pre>Return the length of the period. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id607182-bb"></a>is_null() <span class="bold"><strong>const</strong></span>;</pre>True if period is ill formed (length is zero or less). </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id398706-bb"></a><span class="bold"><strong>operator</strong></span>==(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; rhs) <span class="bold"><strong>const</strong></span>;</pre>Equality operator. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id393695-bb"></a><span class="bold"><strong>operator</strong></span>&lt;(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; rhs) <span class="bold"><strong>const</strong></span>;</pre>Strict as defined by rhs.last &lt;= lhs.last. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id393715-bb"></a>shift(<span class="bold"><strong>const</strong></span> duration_rep &amp; d) ;</pre>Shift the start and end by the specified amount. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>void</strong></span></span> <a name="id374215-bb"></a>expand(<span class="bold"><strong>const</strong></span> duration_rep &amp; d) ;</pre>
<p>Expands the size of the period by the duration on both ends.</p>
<p>So before expand </p>
<pre class="programlisting">         [-------]
 ^   ^   ^   ^   ^   ^  ^
 1   2   3   4   5   6  7
 
   *
</pre>
<p> After expand(2) </p>
<pre class="programlisting"> [----------------------]
 ^   ^   ^   ^   ^   ^  ^
 1   2   3   4   5   6  7
 
   *
</pre>
<p> </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id335527-bb"></a>contains(<span class="bold"><strong>const</strong></span> point_rep &amp; point) <span class="bold"><strong>const</strong></span>;</pre>True if the point is inside the period, zero length periods contain no points. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id409424-bb"></a>contains(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; other) <span class="bold"><strong>const</strong></span>;</pre>True if this period fully contains (or equals) the other period. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id360584-bb"></a>intersects(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; other) <span class="bold"><strong>const</strong></span>;</pre>True if the periods overlap in any way. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id396783-bb"></a>is_adjacent(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; other) <span class="bold"><strong>const</strong></span>;</pre>True if periods are next to each other without a gap. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id366165-bb"></a>is_before(<span class="bold"><strong>const</strong></span> point_rep &amp; point) <span class="bold"><strong>const</strong></span>;</pre>True if all of the period is prior to the passed point or end &lt;= t. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id366182-bb"></a>is_after(<span class="bold"><strong>const</strong></span> point_rep &amp; point) <span class="bold"><strong>const</strong></span>;</pre>True if all of the period is prior or t &lt; start. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><a class="link" href="period.html" title="Class template period">period</a></span> <a name="id366199-bb"></a>intersection(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; other) <span class="bold"><strong>const</strong></span>;</pre>Returns the period of intersection or invalid range no intersection. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><a class="link" href="period.html" title="Class template period">period</a></span> <a name="id366221-bb"></a>merge(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; other) <span class="bold"><strong>const</strong></span>;</pre>Returns the union of intersecting periods -- or null period. </li>
<li class="listitem">
<pre class="literallayout"><span class="type"><a class="link" href="period.html" title="Class template period">period</a></span> <a name="id355953-bb"></a>span(<span class="bold"><strong>const</strong></span> <a class="link" href="period.html" title="Class template period">period</a> &amp; other) <span class="bold"><strong>const</strong></span>;</pre>Combine two periods with earliest start and latest end. <p>Combines two periods and any gap between them such that start = min(p1.start, p2.start) end = max(p1.end , p2.end) </p>
<pre class="programlisting">        [---p1---)
                       [---p2---)
 result:
        [-----------p3----------) 
   *
</pre>
<p> </p>
</li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ymd_order_spec.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.period_hpp"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="period_formatter.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>