time_put — Klasatime_put Class
Szablon klasy opisuje obiekt, który może stanowić zestaw reguł ustawień regionalnych w celu kontrolowania konwersji wartości czasu na sekwencje typu CharType
.The class template describes an object that can serve as a locale facet to control conversions of time values to sequences of type CharType
.
SkładniaSyntax
template <class CharType,
class OutputIterator = ostreambuf_iterator<CharType>>
class time_put : public locale::facet;
ParametryParameters
CharTypeCharType
Typ używany w programie do kodowania znaków.The type used within a program to encode characters.
OutputIteratorOutputIterator
Typ iteratora, do którego funkcje czasu put zapisują swoje dane wyjściowe.The type of iterator into which the time put functions write their output.
UwagiRemarks
Podobnie jak w przypadku dowolnego zestawu reguł ustawień regionalnych, identyfikator obiektu statycznego ma początkową przechowywaną wartość zero.As with any locale facet, the static object ID has an initial stored value of zero. Pierwsza próba uzyskania dostępu do przechowywanej wartości przechowuje unikatową wartość dodatnią w identyfikatorze.The first attempt to access its stored value stores a unique positive value in id.
KonstruktoryConstructors
KonstruktorConstructor | OpisDescription |
---|---|
time_puttime_put | Konstruktor dla obiektów typu time_put .The constructor for objects of type time_put . |
TypedefsTypedefs
Nazwa typuType name | OpisDescription |
---|---|
char_typechar_type | Typ opisujący znak używany przez ustawienie regionalne.A type that is used to describe a character used by a locale. |
iter_typeiter_type | Typ, który opisuje iterator danych wyjściowych.A type that describes an output iterator. |
Funkcje członkowskieMember functions
Funkcja członkowskaMember function | OpisDescription |
---|---|
do_putdo_put | Funkcja wirtualna, która wyprowadza informacje o dacie i godzinie jako sekwencję CharType s.A virtual function that outputs time and date information as a sequence of CharType s. |
Ubraniput | Wyprowadza informacje o dacie i godzinie jako sekwencję CharType s.Outputs time and date information as a sequence of CharType s. |
WymaganiaRequirements
Nagłówek:<locale>Header: <locale>
Przestrzeń nazw: stdNamespace: std
time_put:: char_typetime_put::char_type
Typ opisujący znak używany przez ustawienie regionalne.A type that is used to describe a character used by a locale.
typedef CharType char_type;
UwagiRemarks
Typ jest synonimem dla parametru szablonu CharType
.The type is a synonym for the template parameter CharType
.
time_put::d o_puttime_put::do_put
Funkcja wirtualna, która wyprowadza informacje o dacie i godzinie jako sekwencję CharType
s.A virtual function that outputs time and date information as a sequence of CharType
s.
virtual iter_type do_put(
iter_type next,
ios_base& _Iosbase,
const tm* _Pt,
char _Fmt,
char _Mod = 0) const;
ParametryParameters
ponownnext
Iterator danych wyjściowych, w którym sekwencja znaków reprezentująca datę i godzinę ma zostać wstawiona.An output iterator where the sequence of characters representing time and date are to be inserted.
_Iosbase_Iosbase
Nieużywany.Unused.
_Pt_Pt
Informacje o godzinie i dacie, które są wyprowadzane.The time and date information being output.
_Fmt_Fmt
Format danych wyjściowych.The format of the output. Zobacz strftime, wcsftime, _strftime_l, _wcsftime_l, Aby uzyskać prawidłowe wartości.See strftime, wcsftime, _strftime_l, _wcsftime_l for valid values.
_Mod_Mod
Modyfikator dla formatu.A modifier for the format. Zobacz strftime, wcsftime, _strftime_l, _wcsftime_l, Aby uzyskać prawidłowe wartości.See strftime, wcsftime, _strftime_l, _wcsftime_l for valid values.
Wartość zwracanaReturn Value
Iterator do pierwszej pozycji po wstawieniu ostatniego elementu.An iterator to the first position after the last element inserted.
UwagiRemarks
Wirtualna funkcja chroniona składowa generuje elementy sekwencyjne zaczynające się next
od wartości czasu, które są przechowywane w obiekcie * _Pt
typu tm
.The virtual protected member function generates sequential elements beginning at next
from time values stored in the object * _Pt
, of type tm
. Funkcja zwraca iterator wyznaczający następne miejsce do wstawienia elementu poza wygenerowanymi danymi wyjściowymi.The function returns an iterator designating the next place to insert an element beyond the generated output.
Dane wyjściowe są generowane przez te same reguły, które są używane przez strftime
, z ostatnim argumentem _Pt, do generowania serii char
elementów w tablicy.The output is generated by the same rules used by strftime
, with a last argument of _Pt, for generating a series of char
elements into an array. Każdy taki char
element jest założono, że mapuje do równoważnego elementu typu CharType
przez proste, jedno-do-jednego mapowania.Each such char
element is assumed to map to an equivalent element of type CharType
by a simple, one-to-one mapping. Jeśli _Mod jest równe zero, efektywnym formatem jest "% F", gdzie F jest zastępowany przez _Fmt.If _Mod equals zero, the effective format is "%F", where F is replaced by _Fmt. W przeciwnym razie obowiązuje format "% MF", gdzie M jest zastępowany przez _Mod.Otherwise, the effective format is "%MF", where M is replaced by _Mod.
PrzykładExample
Zobacz przykład umieszczaniawywołań do_put
.See the example for put, which calls do_put
.
time_put:: iter_typetime_put::iter_type
Typ, który opisuje iterator danych wyjściowych.A type that describes an output iterator.
typedef OutputIterator iter_type;
UwagiRemarks
Typ jest synonimem dla parametru szablonu OutputIterator
.The type is a synonym for the template parameter OutputIterator
.
time_put::p UTtime_put::put
Wyprowadza informacje o dacie i godzinie jako sekwencję CharType
s.Outputs time and date information as a sequence of CharType
s.
iter_type put(iter_type next,
ios_base& _Iosbase,
char_type _Fill,
const tm* _Pt,
char _Fmt,
char _Mod = 0) const;
iter_type put(iter_type next,
ios_base& _Iosbase,
char_type _Fill,
const tm* _Pt,
const CharType* first,
const CharType* last) const;
ParametryParameters
ponownnext
Iterator danych wyjściowych, w którym sekwencja znaków reprezentująca datę i godzinę ma zostać wstawiona.An output iterator where the sequence of characters representing time and date are to be inserted.
_Iosbase_Iosbase
Nieużywany.Unused.
_Fill_Fill
Znak typu CharType
używany do odstępów.The character of type CharType
used for spacing.
_Pt_Pt
Informacje o godzinie i dacie, które są wyprowadzane.The time and date information being output.
_Fmt_Fmt
Format danych wyjściowych.The format of the output. Zobacz strftime, wcsftime, _strftime_l, _wcsftime_l, Aby uzyskać prawidłowe wartości.See strftime, wcsftime, _strftime_l, _wcsftime_l for valid values.
_Mod_Mod
Modyfikator dla formatu.A modifier for the format. Zobacz strftime, wcsftime, _strftime_l, _wcsftime_l, Aby uzyskać prawidłowe wartości.See strftime, wcsftime, _strftime_l, _wcsftime_l for valid values.
pierwszegofirst
Początek ciągu formatowania dla danych wyjściowych.The beginning of the formatting string for the output. Zobacz strftime, wcsftime, _strftime_l, _wcsftime_l, Aby uzyskać prawidłowe wartości.See strftime, wcsftime, _strftime_l, _wcsftime_l for valid values.
ostatniegolast
Koniec ciągu formatowania dla danych wyjściowych.The end of the formatting string for the output. Zobacz strftime, wcsftime, _strftime_l, _wcsftime_l, Aby uzyskać prawidłowe wartości.See strftime, wcsftime, _strftime_l, _wcsftime_l for valid values.
Wartość zwracanaReturn Value
Iterator do pierwszej pozycji po wstawieniu ostatniego elementu.An iterator to the first position after the last element inserted.
UwagiRemarks
Pierwsza funkcja członkowska zwraca do_put( next
, _Iosbase
,,, _Fill
_Pt
_Fmt
, _Mod
).The first member function returns do_put(next
, _Iosbase
, _Fill
, _Pt
, _Fmt
, _Mod
). Druga funkcja członkowska jest kopiowana do * next
+ + dowolnego elementu w interwale [ first
, last
) innym niż procent (%).The second member function copies to * next
++ any element in the interval [ first
, last
) other than a percent (%). Dla procentu, po którym następuje znak C w interwale [ first
, last
), zamiast tego funkcja oblicza wartość next
= do_put
( next
,,,, _Iosbase
_Fill
_Pt
C, 0) i pomija ostatnich C. Jeśli jednak C jest znakiem kwalifikatora z zestawu EOQ #, po którym następuje znak C2
w interwale [ first
, last
), funkcja zamiast oblicza wartość next
= do_put
( next
,,,, _Iosbase
_Fill
_Pt
C2
, C) i pomija poprzednie C2
.For a percent followed by a character C in the interval [ first
, last
), the function instead evaluates next
= do_put
( next
, _Iosbase
, _Fill
, _Pt
, C, 0) and skips past C. If, however, C is a qualifier character from the set EOQ#, followed by a character C2
in the interval [ first
, last
), the function instead evaluates next
= do_put
( next
, _Iosbase
, _Fill
, _Pt
, C2
, C) and skips past C2
.
PrzykładExample
// time_put_put.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
#include <time.h>
using namespace std;
int main( )
{
locale loc;
basic_stringstream<char> pszPutI;
ios_base::iostate st = 0;
struct tm t;
memset( &t, 0, sizeof( struct tm ) );
t.tm_hour = 5;
t.tm_min = 30;
t.tm_sec = 40;
t.tm_year = 00;
t.tm_mday = 4;
t.tm_mon = 6;
pszPutI.imbue( loc );
char *pattern = "x: %X %x";
use_facet <time_put <char> >
(loc).put(basic_ostream<char>::_Iter(pszPutI.rdbuf( )),
pszPutI, ' ', &t, pattern, pattern+strlen(pattern));
cout << "num_put( ) = " << pszPutI.rdbuf( )->str( ) << endl;
char strftimebuf[255];
strftime(&strftimebuf[0], 255, pattern, &t);
cout << "strftime( ) = " << &strftimebuf[0] << endl;
}
num_put( ) = x: 05:30:40 07/04/00
strftime( ) = x: 05:30:40 07/04/00
time_put:: time_puttime_put::time_put
Konstruktor dla obiektów typu time_put
.Constructor for objects of type time_put
.
explicit time_put(size_t _Refs = 0);
ParametryParameters
_Refs_Refs
Wartość całkowita służąca do określania typu zarządzania pamięcią dla obiektu.Integer value used to specify the type of memory management for the object.
UwagiRemarks
Możliwe wartości parametru _Refs i ich znaczenie są następujące:The possible values for the _Refs parameter and their significance are:
0: okres istnienia obiektu jest zarządzany przez elementy lokalne, które go zawierają.0: The lifetime of the object is managed by the locales that contain it.
1: okres istnienia obiektu musi być zarządzany ręcznie.1: The lifetime of the object must be manually managed.
> 1: te wartości nie są zdefiniowane.> 1: These values are not defined.
Konstruktor inicjuje swój obiekt podstawowy przy użyciu ustawień regionalnych:: facet(_Refs).The constructor initializes its base object with locale::facet(_Refs).
Zobacz teżSee also
<locale>
Klasa time_basetime_base Class
Bezpieczeństwo wątku w standardowej bibliotece języka C++Thread Safety in the C++ Standard Library