モダンな?::GetWindowText

  • ずっとこの有名な関数をC++にするとどうなるのか考えていた
  • 今のところの結論、WindowTextはRangeである・・・ダウンロード

[]#include[] []<pstade/tomato/window/window_text.hpp>[]
[]#include[] []<pstade/oven/sequence_cast.hpp>[]

[]void[] []test[][]()[]
[]{[]
[]using[] []namespace[] []pstade[][];[]

[]HWND[] []hWnd[][] = ::[][]GetForegroundWindow[][]();[]

[] {[]
[]tomato[][]::[][]window_text[] []text[][]([][]hWnd[][]);[]
[]std[][]::[][]basic_string[][]<[][]TCHAR[][]> [][]str[][];[]
[]std[][]::[][]copy[][]([][]boost[][]::[][]begin[][]([][]text[][]), [][]boost[][]::[][]end[][]([][]text[][]), [][]std[][]::[][]back_inserter[][]([][]str[][]));[]
[]std[][]::[][]cout[][] << [][]str[][] << [][]std[][]::[][]endl[][];[]
[] }[]

[] {[]
[]tomato[][]::[][]window_text[] []text[][]([][]hWnd[][]);[]
[]boost[][]::[][]to_upper[][]([][]text[][]);[]
[]std[][]::[][]cout[][] << [][]text[][].[][]c_str[][]() << [][]std[][]::[][]endl[][];[]
[] }[]

[] {[]
[]typedef[] []std[][]::[][]basic_string[][]<[][]TCHAR[][]> [][]tstring[][];[]
[]// oven::sequenceは昨日のテクニックをboost::copy_rangeに適用したもの[]
[]tstring[] []str[][] = [][]oven[][]::[][]sequence[][]([][]tomato[][]::[][]window_text[][]([][]hWnd[][]));[]
[]std[][]::[][]cout[][] << [][]str[][] << [][]std[][]::[][]endl[][];[]
[] }[]

[] {[]
[]std[][]::[][]cout[][] << [][]tomato[][]::[][]window_text[][]([][]hWnd[][]).[][]c_str[][]() << [][]std[][]::[][]endl[][];[]
[] }[]
[]}[]